Skip to content

Instantly share code, notes, and snippets.

@malloy045
Created April 12, 2019 12:55
Show Gist options
  • Save malloy045/ac2eb564c7413f0203a516b52c1a0302 to your computer and use it in GitHub Desktop.
Save malloy045/ac2eb564c7413f0203a516b52c1a0302 to your computer and use it in GitHub Desktop.
flutter_webview_plugin basic example
import 'package:flutter/material.dart';
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
class Login extends StatefulWidget {
Login({Key key}) : super(key: key);
@override
_MyLoginPageState createState() => _MyLoginPageState();
}
class _MyLoginPageState extends State<Login> {
String _statusText = "Signing you in...";
@override
initState() {
super.initState();
FlutterWebviewPlugin webView = new FlutterWebviewPlugin();
webView.onHttpError.listen((error) {
print("HTTP error: Code = ${error.code}");
});
webView.onUrlChanged.listen((url) {
print("URL changed: URL = $url");
});
webView.onStateChanged.listen((state) {
print("State changed: URL = ${state.url}");
});
webView.launch("https://google.com", hidden: false).then((data) {
print("Webview launch");
});
webView.show();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.blue,
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(_statusText,
style: TextStyle(
color: Colors.white,
fontSize: 20
)
),
Container(
padding: EdgeInsets.all(15.0),
child: CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(Colors.white)
)
)
]
)
)
);
}
}
@EdoardoVignati
Copy link

Thanks, good gist.

Could you also provide a way to avoid status bar overlapping?

Image here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment