Issue on webview_flutter

361 views
Skip to first unread message

rajkumar.ga...@gmail.com

unread,
Apr 23, 2019, 7:03:47 AM4/23/19
to Flutter Dev
Hi

   I'm working with flutter webview. I had generated an url and assigned it to a variable in one controller.And need to call that variable in other controller(StateFulWidget) getting an error "Invalid constant value.dart(invalid_constant)".  can you please share the solution for this problem.

   My actual code is 

body : const WebView(
initialUrl: urlForView,
javascriptMode: JavascriptMode.unrestricted,
),);



Steven McDowall

unread,
Apr 23, 2019, 7:08:02 AM4/23/19
to rajkumar.ga...@gmail.com, Flutter Dev

The code you shared is probably not the code we need to see .. it's out of context.. need to see maybe the code for all the controllers and how you pass the URL to the StatefulWidget, etc. 

Also, it is unlikely that WebView is a const .. since you are passing (or trying to use) a variable named urlForView  ... ?? 

Any time you use ANY variables within the definition of a "Widget" it is NOT a const .. however, certain parameters WITHIN the invocation of the Widget could be const's.  In this case, the javascriptMode maybe shoul dbe:

...
  javascriptMode: const JavascriptMode.unrestricted,   
...

But that's just a guess.. but certainly remove the "const" from the "const WebView" .. 



--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

rajkumar.ga...@gmail.com

unread,
Apr 23, 2019, 7:29:16 AM4/23/19
to Flutter Dev
Thank you.Error was cleared.
To unsubscribe from this group and stop receiving emails from it, send an email to flutt...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages