flutter_marionette 0.2.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 51

Marionette for Flutter #

Marionette is a library which provides a high-level API to control a WebView.

The goal is to have the API closely mirror that of Puppeteer.

Other platforms: Swift (macOS/iOS), JavaScript (Node)

Usage #

import 'package:flutter_marionette/marionette.dart';

() async {
  final page = Marionette();

  await page.goto("https://www.google.com/");
  await page.type("input[name='q']", "LinusU Marionette")
  await Future.wait([page.waitForNavigation(), page.click("input[type='submit']")]);


iOS #

To be able to use Marionette on iOS, you need to give Marionette a hook to your view hierarchy. Otherwise the WKWebView will get suspended by the OS, and your Promises will never settle.

This is accomplished by using the setGlobalUIHook function before instantiating any Marionette instances.


If you have a non-modified Flutter application, this should be added to ios/Runner/AppDelegate.swift, in the application(_:didFinishLaunchingWithOptions:) function.

--- a/ios/Runner/AppDelegate.swift
+++ b/ios/Runner/AppDelegate.swift
@@ -1,5 +1,6 @@
 import UIKit
 import Flutter
+import flutter_marionette

 @objc class AppDelegate: FlutterAppDelegate {
   override func application(
     _ application: UIApplication,
     didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
   ) -> Bool {
+    SwiftFlutterMarionettePlugin.setGlobalUIHook(window: UIApplication.shared.windows.first!)
     GeneratedPluginRegistrant.register(with: self)
     return super.application(application, didFinishLaunchingWithOptions: launchOptions)


// Can be called from anywhere, e.g. your AppDelegate
SwiftFlutterMarionettePlugin.setGlobalUIHook(window: UIApplication.shared.windows.first!)

App Extension:

// From within your root view controller
SwiftFlutterMarionettePlugin.setGlobalUIHook(viewController: self)

0.2.0 #

  • 💥 Avoid app extension restricted APIs

    Migration Guide:

    You now need to specifically need to opt in to registering the WKWebView with the first window of the shared application. The reasoning for this is that it's a restricted API that isn't available when writing an App Extension.

    Look at the added section in the readme for the two lines of code you need to add to your AppDelegate.

0.1.0 #

  • 🎉 Add initial implementation


import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter_marionette/marionette.dart';

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

class MyApp extends StatefulWidget {
  _MyAppState createState() => _MyAppState();

class _MyAppState extends State<MyApp> {
  String _result = '...';

  void initState() {

  Future<void> evaluate() async {
    final page = Marionette();
    final result = await page.evaluate("'Hello, World!'");
    setState(() { _result = result; });

  Future<void> scrape() async {
    setState(() { _result = "init"; });
    final page = Marionette();

    setState(() { _result = "goto"; });
    await page.goto("https://example.com/");

    setState(() { _result = "evaluate"; });
    final result = await page.evaluate("document.querySelector('h1').textContent");

    setState(() { _result = result; });

  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
                child: Text('test'),
                onPressed: () { this.scrape(); },

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  flutter_marionette: ^0.2.0

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:flutter_marionette/marionette.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jul 7, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because of import path [package:flutter_marionette/marionette.dart] that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because of import path [package:flutter_marionette/marionette.dart] that declares support for platforms: android, ios

Package does not support Flutter platform web

Because of import path [package:flutter_marionette/marionette.dart] that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because of import path [package:flutter_marionette/marionette.dart] that declares support for platforms: android, ios

Package not compatible with SDK dart

because of import path [flutter_marionette] that is in a package requiring null.

Health issues and suggestions

Document public APIs. (-1 points)

15 out of 15 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/marionette.dart.

Run flutter format to format lib/marionette.dart.

Maintenance suggestions

Package is getting outdated. (-23.84 points)

The package was last published 64 weeks ago.

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.1
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies