@@ -84,7 +84,7 @@ class MyApp extends StatelessWidget {
8484}
8585
8686class MyHomePage extends StatefulWidget {
87- const MyHomePage ({Key key, this .title}) : super (key: key);
87+ const MyHomePage ({Key ? key, required this .title}) : super (key: key);
8888
8989 final String title;
9090
@@ -97,21 +97,21 @@ class _MyHomePageState extends State<MyHomePage> {
9797 final flutterWebViewPlugin = FlutterWebviewPlugin ();
9898
9999 // On destroy stream
100- StreamSubscription _onDestroy;
100+ late StreamSubscription _onDestroy;
101101
102102 // On urlChanged stream
103- StreamSubscription <String > _onUrlChanged;
103+ late StreamSubscription <String > _onUrlChanged;
104104
105105 // On urlChanged stream
106- StreamSubscription <WebViewStateChanged > _onStateChanged;
106+ late StreamSubscription <WebViewStateChanged > _onStateChanged;
107107
108- StreamSubscription <WebViewHttpError > _onHttpError;
108+ late StreamSubscription <WebViewHttpError > _onHttpError;
109109
110- StreamSubscription <double > _onProgressChanged;
110+ late StreamSubscription <double > _onProgressChanged;
111111
112- StreamSubscription <double > _onScrollYChanged;
112+ late StreamSubscription <double > _onScrollYChanged;
113113
114- StreamSubscription <double > _onScrollXChanged;
114+ late StreamSubscription <double > _onScrollXChanged;
115115
116116 final _urlCtrl = TextEditingController (text: selectedUrl);
117117
@@ -135,8 +135,8 @@ class _MyHomePageState extends State<MyHomePage> {
135135 _onDestroy = flutterWebViewPlugin.onDestroy.listen ((_) {
136136 if (mounted) {
137137 // Actions like show a info toast.
138- _scaffoldKey.currentState. showSnackBar (
139- const SnackBar (content: const Text ('Webview Destroyed' )));
138+ ScaffoldMessenger . of (context)
139+ . showSnackBar ( const SnackBar (content: Text ('Webview Destroyed' )));
140140 }
141141 });
142142
@@ -226,7 +226,7 @@ class _MyHomePageState extends State<MyHomePage> {
226226 padding: const EdgeInsets .all (24.0 ),
227227 child: TextField (controller: _urlCtrl),
228228 ),
229- RaisedButton (
229+ ElevatedButton (
230230 onPressed: () {
231231 flutterWebViewPlugin.launch (
232232 selectedUrl,
@@ -239,19 +239,19 @@ class _MyHomePageState extends State<MyHomePage> {
239239 },
240240 child: const Text ('Open Webview (rect)' ),
241241 ),
242- RaisedButton (
242+ ElevatedButton (
243243 onPressed: () {
244244 flutterWebViewPlugin.launch (selectedUrl, hidden: true );
245245 },
246246 child: const Text ('Open "hidden" Webview' ),
247247 ),
248- RaisedButton (
248+ ElevatedButton (
249249 onPressed: () {
250250 flutterWebViewPlugin.launch (selectedUrl);
251251 },
252252 child: const Text ('Open Fullscreen Webview' ),
253253 ),
254- RaisedButton (
254+ ElevatedButton (
255255 onPressed: () {
256256 Navigator .of (context).pushNamed ('/widget' );
257257 },
@@ -261,30 +261,31 @@ class _MyHomePageState extends State<MyHomePage> {
261261 padding: const EdgeInsets .all (24.0 ),
262262 child: TextField (controller: _codeCtrl),
263263 ),
264- RaisedButton (
264+ ElevatedButton (
265265 onPressed: () {
266266 final future =
267267 flutterWebViewPlugin.evalJavascript (_codeCtrl.text);
268- future.then ((String result) {
268+ future.then ((String ? result) {
269269 setState (() {
270270 _history.add ('eval: $result ' );
271271 });
272272 });
273273 },
274274 child: const Text ('Eval some javascript' ),
275275 ),
276- RaisedButton (
276+ ElevatedButton (
277277 onPressed: () {
278- final future = flutterWebViewPlugin.evalJavascript ('alert("Hello World");' );
279- future.then ((String result) {
278+ final future = flutterWebViewPlugin
279+ .evalJavascript ('alert("Hello World");' );
280+ future.then ((String ? result) {
280281 setState (() {
281282 _history.add ('eval: $result ' );
282283 });
283284 });
284285 },
285286 child: const Text ('Eval javascript alert()' ),
286287 ),
287- RaisedButton (
288+ ElevatedButton (
288289 onPressed: () {
289290 setState (() {
290291 _history.clear ();
@@ -293,7 +294,7 @@ class _MyHomePageState extends State<MyHomePage> {
293294 },
294295 child: const Text ('Close' ),
295296 ),
296- RaisedButton (
297+ ElevatedButton (
297298 onPressed: () {
298299 flutterWebViewPlugin.getCookies ().then ((m) {
299300 setState (() {
0 commit comments