Filter by Widgets


WebView example

This Article is posted by seven.srikanth at 22-08-2018 09:02:19


Below example will help you to create a Webview in Flutter, which will load on a Button click.
The final App output is going to look as below,
Once the New Project is created you need to add the below flutter_webview_plugin package into the pubspec.yaml file.
flutter_webview_plugin: ^0.3.0+2
And then Save to get the Packages.
One the Packages are updated, add the below code to your main.dart code file in lib folder and run the program.
import 'package:flutter/material.dart';
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
void main() {
runApp(new MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
var title = 'Webview Demo';
return new MaterialApp(
title: title,
routes: {
'/widget': (_) => new WebviewScaffold(
url: "https:\\FlutterCentral.com",
appBar: new AppBar(
title: const Text('Widget Webview'),
),
withZoom: false,
withLocalStorage: true,
)
},
home: new MyAppHomePage(),
);
}
}
class MyAppHomePage extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyAppHomePage> {
void _opennewpage() {
Navigator.of(context).pushNamed('/widget');
}
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: AppBar(
title: Text("Sample App"),
),
body: new Center(
child: new RaisedButton(
child: Text('Open Link'),
onPressed: () {
_opennewpage();
}
) ,
)
);
}
}
Hope this is helpful.
Thanks,
Srikanth
Related Articles:
-> Move to next Tab on Button Click in Flutter https://fluttercentral.com/Articles/Post/1054 ;
-> List of Cards from a JSON source in Flutter https://fluttercentral.com/Articles/Post/55 -> SliverAppBar Widget in Flutter https://fluttercentral.com/Articles/Post/51
-> Flutter Stepper Widget - Change State in Response to Input https://fluttercentral.com/Articles/Post/44
2 Comments
Login to comment.
Recent Comments

obozhdi at 28-01-2019

This shit wont work.

Login to Reply.

seven.s at 05-03-2019

Hi Obozhdi, I've rechecked the program and its running fine. However, I have observed there will be a slight confusion in the way it is written and it is corrected now.





Recent articles

Error: The name 'RangeSlider' is defined in the libraries 'package:flutter/src/material/range_slider.dart' and 'package:flutter_range_slider/src/flutter_range_slider.dart'.

Check out this article on Error: The name 'RangeSlider' is defined in the libraries 'package:flutter/src/material/range_slider.dart' and 'package:flutter_range_slider/src/flutter_range_slider.dart'.

Read full post

How to create a persistent bottom sheet in Flutter?

Check out this article on How to create a persistent bottom sheet in Flutter?

Read full post

How to draw a Decorative Horizontal line in Flutter?

Check out this article on How to draw a Decorative Horizontal line in Flutter?

Read full post

How to fetch an Image from Internet in Flutter

Check out this article on How to fetch an Image from Internet in Flutter

Read full post

ListView with Images from the Internet

Check out this article on ListView with Images from the Internet

Read full post

How to show Tooltip in Flutter?

Check out this article on How to show Tooltip in Flutter?

Read full post

How to create BottomNavigationBar in flutter?

Check out this article on How to create BottomNavigationBar in flutter?

Read full post

How to add actions to Appbar?

Check out this article on How to add actions to Appbar?

Read full post

How to open dart devtools in VS code?

Check out this article on How to open dart devtools in VS code?

Read full post

Accessibility features in flutter

Check out this article on Accessibility features in flutter

Read full post

© 2018 - Fluttercentral | Email to me - Seven.srikanth@gmail.com

Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License , and code samples are licensed under the BSD License.