Flutter WebView | WebView in Flutter

Hi, In this Flutter tutorial I am going to explain how to make flutter basic browser using webview widget.

Flutter WebView is used to display a web page in flutter. The web page can be loaded from the same application or URL. It is used to display online content in the flutter widget.

Incorporating the WebView plugin into your app is extremely simple. It’s just a widget like any other: WebView(initialUrl: ‘https://flutter.io'). You can also optionally enable or disable JavaScript in your WebView with the javascriptMode parameter. By default, JavaScript in your WebView is disabled, so to enable it you’d construct a WebView like so:

Firstly i am going to add same dependencies.

  url_launcher: ^3.0.0
  flutter_webview_plugin: ^0.2.1+2
  share: ^0.6.3+5
  swipedetector: ^1.2.0

And import package then right your code like that:-
import 'package:flutter/material.dart'; import 'dart:async'; import 'package:flutter_webview_plugin/flutter_webview_plugin.dart'; import 'package:share/share.dart'; import 'package:swipedetector/swipedetector.dart'; void main() { runApp( MaterialApp( debugShowCheckedModeBanner: false, home: HomePage(), theme: ThemeData( primarySwatch: Colors.purple, ), )); } class HomePage extends StatefulWidget { @override _HomePageState createState() => _HomePageState(); } class _HomePageState extends State<HomePage> { final flutterWebviewPlugin = new FlutterWebviewPlugin(); canLaunch(String url) {} launch(String url, {bool forceSafariVC, bool forceWebView}) {} Future launchURL(String url) async{ if (await canLaunch(url)){ await launch(url, forceSafariVC: true, forceWebView: true); }else{ print("Can't Launch url"); } } @override Widget build(BuildContext context) { return Container( child: SwipeDetector( onSwipeDown: () { setState(() { }); }, child: WebviewScaffold(url:'https://fluttertute.blogspot.com/', withJavascript: true, withZoom: true, withLocalStorage: true, appBar: AppBar( backgroundColor: Colors.blue[600], title: Text('FlutterTute'), actions: <Widget>[ IconButton( icon: Icon( Icons.share, color: Colors.white, ), onPressed:(){ Share.share('https://drive.google.com/file/d/1TRnfO3ng2G3kxQxa8hQ9k3yNzHUdGeg9/view?usp=sharing'); } ) ], ), ), ), ); } }

Comments

Popular posts from this blog

Auto slide image with indicator in flutter

Flutter Architecture | Flutter - Architecture Application

Automatic Scrolling Image in flutter