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

ChromeSafariBrowser: The getter 'android' was called on null #300

Closed
hallidev opened this issue Mar 4, 2020 · 1 comment
Closed

ChromeSafariBrowser: The getter 'android' was called on null #300

hallidev opened this issue Mar 4, 2020 · 1 comment

Comments

@hallidev
Copy link

hallidev commented Mar 4, 2020

Environment

Flutter version: Flutter 1.12.13+hotfix.8 • channel stable
Plugin version: Direct from git (couldn't get pub package running) -
flutter_inappwebview:
git:
url: https://github.com/pichillilorenzo/flutter_inappwebview.git
Android version: 10 (Emulator)
iOS version:
Xcode version:
Device information: Pixel 3

Description

The following is just a copy / paste from the ChromeSafariBrowser section of readme.md. Using this and running in a fresh Flutter app results in "The getter 'android' was called on null"

import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';

class MyInAppBrowser extends InAppBrowser {

  @override
  Future onLoadStart(String url) async {
    print("\n\nStarted $url\n\n");
  }

  @override
  Future onLoadStop(String url) async {
    print("\n\nStopped $url\n\n");
  }

  @override
  void onLoadError(String url, int code, String message) {
    print("\n\nCan't load $url.. Error: $message\n\n");
  }

  @override
  void onExit() {
    print("\n\nBrowser closed!\n\n");
  }

}

class MyChromeSafariBrowser extends ChromeSafariBrowser {
  
  MyChromeSafariBrowser(browserFallback) : super(bFallback: browserFallback);

  @override
  void onOpened() {
    print("ChromeSafari browser opened");
  }

  @override
  void onLoaded() {
    print("ChromeSafari browser loaded");
  }

  @override
  void onClosed() {
    print("ChromeSafari browser closed");
  }
}

void main() => runApp(new MyApp());

class MyApp extends StatefulWidget {
  final ChromeSafariBrowser browser = new MyChromeSafariBrowser(new MyInAppBrowser());
  
  @override
  _MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State<MyApp> {

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('ChromeSafariBrowser Example'),
        ),
        body: Center(
          child: RaisedButton(
              onPressed: () async {
                await widget.browser.open(
                    url: "https://flutter.dev/",
                    options: ChromeSafariBrowserClassOptions(
                        android: AndroidChromeCustomTabsOptions(addShareButton: false),
                        ios: IosSafariOptions(barCollapsingEnabled: true)));
              },
              child: Text("Open Chrome Safari Browser")),
        ),
      ),
    );
  }
}

Expected behavior:

ChromeSafariBrowser opens

Current behavior:

Exception is thrown, browser doesn't open

Steps to reproduce

  1. Create new flutter app
  2. Paste in the above code
  3. Run, click "open" button
@hallidev
Copy link
Author

Was my fault - was missing ChromeSafariBrowserClassOptions

This was referenced Jul 6, 2020
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

1 participant