Created
April 12, 2019 12:55
-
-
Save malloy045/ac2eb564c7413f0203a516b52c1a0302 to your computer and use it in GitHub Desktop.
flutter_webview_plugin basic example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
) | |
) | |
] | |
) | |
) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, good gist.
Could you also provide a way to avoid status bar overlapping?
Image here