wiki_browser icon indicating copy to clipboard operation
wiki_browser copied to clipboard

How to give the initial url dynamically ?

Open bhoomesh950 opened this issue 6 years ago • 2 comments

Am getting error Invalid constant value ?? am new to Flutter

`import 'package:flutter/material.dart'; import 'package:webview_flutter/webview_flutter.dart'; import './Model/Model.dart';

class WebViewScreen extends StatelessWidget{

final WebData data;

WebViewScreen({this.data}); @override Widget build(BuildContext context) { return new Scaffold( appBar: AppBar( backgroundColor: Colors.orange, title: Text(data.navigationName), ), body:new Container( color: Colors.blueAccent, child: const WebView( // here am getting error invalid constant value initialUrl:data.url, javascriptMode: JavascriptMode.unrestricted, ), ) , ); }

} `

bhoomesh950 avatar May 14 '19 05:05 bhoomesh950

I faced the same problem and resolve it by just removing the const keyword from the body like this. Hope it helps'

var webviewurl;

@override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( centerTitle: true, title: Text('Your title'), ), body: WebView(

    initialUrl:  webviewurl,
    javascriptMode: JavascriptMode.unrestricted,
  ),
);

}

@override void initState() { super.initState(); setState(() { webviewurl = widget.selectedurl; }); }

rishavsharma5902 avatar Mar 03 '20 06:03 rishavsharma5902

I met the same problem, just remove const Webview, and it works. the answer is here: https://groups.google.com/forum/#!topic/flutter-dev/9EDgqWAvlQ8 Hope to help some guys

jimneylee avatar Apr 30 '20 06:04 jimneylee