fluttercommunity / fluttercommunity/flutter_webview_plugin
Webview can't show anything and infinity loop
- Dominant language
- Java
- Stars
- 1.5k
- Forks
- 938
- PR merge metrics
- No merged PRs in 30d
Description
```dart
import 'package:flutter/material.dart';
// import 'package:flutter_html_view/flutter_html_view.dart';
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
import 'package:cat_dog/modules/dashboard/actions.dart';
class ViewComponent extends StatefulWidget {
final dynamic news;
const ViewComponent({
Key key,
this.news
}) : super(key: key);
@override
_ViewComponentState createState() => new _ViewComponentState();
}
class _ViewComponentState extends State {
String html = '';
final flutterWebviewPlugin = new FlutterWebviewPlugin();
@override
void initState() {
super.initState();
getDefailNews(widget.news['url']).then((result) {
print(result);
// setState(() {
// html = result;
// });
flutterWebviewPlugin.launch(new Uri.dataFromString('', mimeType: 'text/html', parameters: { 'charset': 'utf-8' }).toString(), hidden: false);
});
}
@override
Widget build(BuildContext context) {
return new Center(
// child: new SingleChildScrollView(
// child: new Center(
// child: new HtmlView(
// data: html,
// baseURL: "", // optional, type String
// onLaunchFail: (url) { // optional, type Function
// print("launch $url failed");
// }
// )
// ),
// )
child: new WebviewScaffold(
url: new Uri.dataFromString('', mimeType: 'text/html', parameters: { 'charset': 'utf-8' }).toString(),
appBar: new AppBar(
title: Text(widget.news['heading']),
),
withZoom: true,
withLocalStorage: true,
hidden: false,
initialChild: Container(
child: const Center(
child: Text('Waiting.....'),
),
),
),
);
}
}
```
Navigation
```
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => ViewPage(news: item),
),
);
```
Result:
Function initState inifinity loop => webview can't show anything
Can you guy explain what wrong with my code ?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.