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

Webview can't show anything and infinity loop #265

Open
zrg-team opened this issue Dec 9, 2018 · 1 comment
Open

Webview can't show anything and infinity loop #265

zrg-team opened this issue Dec 9, 2018 · 1 comment

Comments

@zrg-team
Copy link

zrg-team commented Dec 9, 2018

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<ViewComponent> {
  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 ?

@DigNZ
Copy link

DigNZ commented Dec 13, 2018

I'm having the same issue. I've noticed that the webview does load if the location permissions dialog popups up over it, but once that is granted it will not load subsequent times. Also I've noticed from the server logs that the request is not hitting the server when the loading indicator is showing.
Finally hidden: true and hidden: false both show the loading indicator, there is no change in behaviour.

Plugin version 0.3.0+2.

All works as expected on Android.

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

2 participants