mobile_pay_app_switch_flutter 0.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 44

mobile_pay_flutter #

A Flutter plugin for MobilePay AppSwitch.

iOS #

Follow the instructions given by Mobile Pay here. Add needed keys to your .plist file.

0.0.1 #

Initial version supporting Mobile Pay App Switch 2.2.0.


import 'dart:io';

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

import 'package:flutter/services.dart';
import 'package:mobile_pay_app_switch_flutter/mobile_pay_app_switch_flutter.dart';

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

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

class _MyAppState extends State<MyApp> {
  bool _mobilePlayInstalled = false;
  bool _loading = false;
  MobilePayResult _paymentResult;

  void initState() {

  Future<void> initMobilePay() async {
    bool mobilePlayInstalled;

    MobilePay().init("APPFI0000000000", MobilePayCountry.FINLAND, "mbtest");

    try {
      mobilePlayInstalled = await MobilePay().isMobilePayInstalled;
    } on PlatformException {
      mobilePlayInstalled = false;

    if (!mounted) return;

    setState(() {
      _mobilePlayInstalled = mobilePlayInstalled;

  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Mobile Pay Example'),
        body: Center(
          child: Column(
            children: <Widget>[
              Text('Mobile Pay Installed: $_mobilePlayInstalled\n'),
                child: Text("Pay"),
                onPressed: initiatePayment,
              if (_loading) CircularProgressIndicator(),
              if (_paymentResult != null) buildPaymentResult()

  initiatePayment() async {
    if (_mobilePlayInstalled) {
      setState(() {
        _loading = true;
      try {
        final result = await MobilePay()
            .createPayment(productPrice: 10.5, orderId: "fkjgjkdffgdj");
        setState(() {
          _paymentResult = result;
      } catch (e) {
      } finally {
        setState(() {
          _loading = false;
    } else
      await MobilePay().downloadMobilePay();

  Widget buildPaymentResult() {
    if (_paymentResult.isCanceled)
      return Text(
        "Transaction canceled",
        style: Theme.of(context).textTheme.display2,
    if (_paymentResult.isFailure)
      return Column(
        children: <Widget>[
            "Transaction failure",
            style: Theme.of(context).textTheme.display2,
          Text("${_paymentResult.errorCode}: ${_paymentResult.errorMessage}")

    return Column(
      children: <Widget>[
          "Transaction successfully done",
          style: Theme.of(context).textTheme.display2,
        Text("${_paymentResult.amountWithdrawnFromCard} €"),

Use this package as a library

1. Depend on it

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

  mobile_pay_app_switch_flutter: ^0.0.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:mobile_pay_app_switch_flutter/mobile_pay_app_switch_flutter.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 2, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.9+1
  • Flutter: 1.17.3

Analysis suggestions

Package does not support Flutter platform linux

Because of import path [package:mobile_pay_app_switch_flutter/mobile_pay_app_switch_flutter.dart]

Package does not support Flutter platform macos

Because of import path [package:mobile_pay_app_switch_flutter/mobile_pay_app_switch_flutter.dart]

Package does not support Flutter platform web

Because of import path [package:mobile_pay_app_switch_flutter/mobile_pay_app_switch_flutter.dart]

Package does not support Flutter platform windows

Because of import path [package:mobile_pay_app_switch_flutter/mobile_pay_app_switch_flutter.dart]

Package not compatible with SDK dart

because of import path [mobile_pay_app_switch_flutter]

Maintenance suggestions

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 is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.


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.0
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies