Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to give the initial url dynamically ? #2

Open
bhoomesh950 opened this issue May 14, 2019 · 2 comments
Open

How to give the initial url dynamically ? #2

bhoomesh950 opened this issue May 14, 2019 · 2 comments

Comments

@bhoomesh950
Copy link

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,
),
)
,
);
}

}
`

@rishavsharma5902
Copy link

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;
});
}

@jimneylee
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants