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

WebviewScaffold exception after clicking back icon #89

Open
dimoreira opened this issue May 31, 2018 · 4 comments
Open

WebviewScaffold exception after clicking back icon #89

dimoreira opened this issue May 31, 2018 · 4 comments
Labels

Comments

@dimoreira
Copy link

After open the webview with an appBar, I click on the back button and receive a exception from:

File: broadcast_stream_controller.dart

Exception:

screen shot 2018-05-30 at 21 06 04

My Code:

onTap: () {
  Navigator.push(
    context,
    new MaterialPageRoute(
      builder: (context) => new WebviewScaffold(
        url: widget.recipe.linkUrl,
        appBar: new AppBar(title: new Text(widget.recipe.title)),
      ),
    ),
  );
},
@lejard-h lejard-h added the bug label Jun 2, 2018
@salujaharkirat
Copy link

Even I am facing this issue with following code:-

import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';


String selectedUrl = "https://flutter.io";


class Webview extends StatefulWidget {
  @override
  _WebviewState createState() => new _WebviewState();
}

class _WebviewState extends State<Webview> {
  final flutterWebviewPlugin = new FlutterWebviewPlugin();

  StreamSubscription<String> _onUrlChanged;
  StreamSubscription _onDestroy;

  @override
  initState() {
    super.initState();
    // Add a listener to on url changed
    _onUrlChanged = flutterWebviewPlugin.onUrlChanged.listen((String url) {
      print(url);
      if (mounted) {
        print(url);
      }
    });
    _onDestroy = flutterWebviewPlugin.onDestroy.listen((_) {
    });
  }

  @override
    void dispose() {
    // Every listener should be canceled, the same should be done with this stream.
    _onDestroy.cancel();
    _onUrlChanged.cancel();
    flutterWebviewPlugin.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return new Container(
      child: new RaisedButton(
        child: new Text("press me"),
        onPressed: () {
          flutterWebviewPlugin.launch(selectedUrl);
        }
      )
    );
  }
}

@jacobimpson
Copy link

For now rolling back to 0.1.5 fixes this issue. Hopefully we will see a fix for this in the next release.

@agriirga
Copy link

agriirga commented Aug 25, 2018

i had exactly same problem,
any solution for this ? @dimoreira

@dimoreira
Copy link
Author

@agriirga I just used the url_launcher forcing a webview preview (works for my use case):

void _launchUrl(String url, BuildContext context) async {
    if (await canLaunch(url)) {
      await launch(url, forceWebView: true);
    } else {
      showDialog(
        context: context,
        builder: (BuildContext context) {
          return new AlertDialog(
            title: new Text('Sprintime'),
            content: new Text('Could not launch the recipe url'),
          );
        },
      );
    }
  }

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

No branches or pull requests

5 participants