moneybutton_flutter_web 0.1.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 42

moneybutton_flutter_web #

An experimental MoneyButton plugin for Flutter Web

Usage #

MoneyButton(Map options, (optional) {width: double yourWidth}) #

Displaying Money Buttons onscreen is very buggy because of an issue displaying iframes in Flutter web. You can use Invisible Money Button for the time being

Options is passed as is to the MoneyButton javascript api. Callbacks are not supported.

example:

container(
  child:MoneyButton({"to": "jonathanaird@moneybutton.com", "amount": 1, "currency": "USD"}, width:300)
  )

Invisible Money Button #

To use invisible money button, include the Money Button script tag in your index.html file:
<script src="https://www.moneybutton.com/moneybutton.js"></script>

This package includes a polyfill for the official api with the one difference being that you use IMB(options) instead of moneyButton.IMB(options);

Example:

var imb = IMB({'clientIdentifier':'your identifier','suggestedAmount':{'amount':'1','currency':'USD'},'onNewPermissionGranted':(String token){print(token);}});

[0.1.1] - swipe future now returns nested Map instead of js object #

[0.1.0] - Added support for invisible moneybutton #

[0.0.1] - An experimental moneybutton plugin for flutter web #

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:moneybutton_flutter_web/moneybutton_flutter_web.dart';
import 'package:upstate/upstate.dart';

void main() {
  runApp(StateWidget(state: StateObject({'IMB': null}), child: MyApp()));
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;
  StateObject state;
  void _incrementCounter() {

    if (_counter == 0) {
      state['IMB'].value = IMB({
        'clientIdentifier': 'a4764ce4c09db65ddb90a02701fd2d53',
        'suggestedAmount': {'amount': '1', 'currency': 'USD'},
        'onNewPermissionGranted': (String token) {
          print(token);
        }
      });
    } else if (_counter == 1) {
      state['IMB'].value.askForPermission({
        'suggestedAmount': {'amount': '1', 'currency': 'USD'}
      });
    } else if (_counter == 2) {
      state['IMB'].value.amountLeft().then((result) => print(result));
    } else {
      state['IMB'].value.swipe({
        'to': 'canyouhandleme@handcash.io',
        'amount': '0.01',
        'currency': 'USD'
      }).then((res) => print(res));
    }

    //  ..swipe({'to':'cheers@moneybutton.com','amount':'0.01','currency':'USD'});

    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    state = StateObject.of(context);
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headline4,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  moneybutton_flutter_web: ^0.1.1

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:moneybutton_flutter_web/moneybutton_flutter_web.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
93
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
42
Learn more about scoring.

We analyzed this package on Jul 9, 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:moneybutton_flutter_web/moneybutton_flutter_web.dart, package:easy_web_view/easy_web_view.dart, package:easy_web_view/src/mobile.dart, package:webview_flutter/webview_flutter.dart] that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because of import path [package:moneybutton_flutter_web/moneybutton_flutter_web.dart, package:easy_web_view/easy_web_view.dart, package:easy_web_view/src/mobile.dart, package:webview_flutter/webview_flutter.dart] that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because of import path [package:moneybutton_flutter_web/moneybutton_flutter_web.dart, package:easy_web_view/easy_web_view.dart, package:easy_web_view/src/mobile.dart, package:easy_web_view/src/impl.dart, package:url_launcher/url_launcher.dart] that declares support for platforms: android, ios, linux, macos, web

Package not compatible with SDK dart

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

Package not compatible with runtime flutter-native on android

Because of the import of dart:js via the import chain package:moneybutton_flutter_web/moneybutton_flutter_web.dartpackage:moneybutton_flutter_web/src/moneyButton.js.dartpackage:js/js.dartdart:js

Package not compatible with runtime flutter-native on ios

Because of the import of dart:js via the import chain package:moneybutton_flutter_web/moneybutton_flutter_web.dartpackage:moneybutton_flutter_web/src/moneyButton.js.dartpackage:js/js.dartdart:js

Health issues and suggestions

Fix lib/moneybutton_flutter_web.dart. (-5.95 points)

Analysis of lib/moneybutton_flutter_web.dart reported 1 warning, 2 hints:

line 33 col 16: The parameter 'onLoaded' is required.

line 12 col 7: This class (or a class that this class inherits from) is marked as '@immutable', but one or more of its instance fields aren't final: MoneyButton.key, MoneyButton.url, MoneyButton.width, MoneyButton.viewType

line 103 col 6: The declaration '_getKeysOfObject' isn't referenced.

Fix lib/src/moneyButton.js.dart. (-1 points)

Analysis of lib/src/moneyButton.js.dart reported 2 hints:

line 3 col 9: Name libraries using lowercase_with_underscores.

line 4 col 8: Unused import: 'dart:js'.

Maintenance issues and suggestions

Use constrained dependencies. (-20 points)

The pubspec.yaml contains 1 dependency without version constraints. Specify version ranges for the following dependencies: js.

The package description is too short. (-10 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.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
easy_web_view ^1.2.0 1.3.0
flutter 0.0.0
js any 0.6.2
Transitive dependencies
args 1.6.0
charcode 1.1.3
collection 1.14.12 1.14.13
csslib 0.16.1
cupertino_icons 0.1.3
flutter_markdown 0.3.5 0.4.2
flutter_web_plugins 0.0.0
html 0.14.0+3
html2md 0.5.1
http 0.12.1
http_parser 3.1.4
markdown 2.1.5
meta 1.1.8 1.2.1
path 1.7.0
pedantic 1.9.0 1.9.1
platform_detect 1.4.0
plugin_platform_interface 1.0.2
pub_semver 1.4.4
sky_engine 0.0.99
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6 1.2.0
url_launcher 5.5.0
url_launcher_linux 0.0.1+1
url_launcher_macos 0.0.1+7
url_launcher_platform_interface 1.0.7
url_launcher_web 0.1.2
vector_math 2.0.8 2.1.0-nullsafety
webview_flutter 0.3.22+1
Dev dependencies
flutter_test