flutter_square_pos 1.0.1
flutter_square_pos: ^1.0.1 copied to clipboard

A new flutter plugin project.

flutter_square_pos #

A flutter plugin to use square POS(point of sale) api.

Square supports sdk of POS for Andoid and iOS but not supported for flutter. This library bundles them for flutter.

Setup #

Common #


Add flutter_square_pos to depencency in pubspec.yaml of your project.

  flutter_square_pos: ^1.0.0

Define applicationId of square on code of your app

Get Application ID from developper dashboard and define it on your app.

For example on main.dart.

var squareApplicationId = 'sq0idp-sEIatSPRxB2uxxxxxxx';

Android #

Register Android app info to square account

Fingerprint and package name are required.

Andorid | Register your application

This plugin uses uni_links for iOS but Android also need to support it. To build it, set minSdkVersion as 23 in android/build.gradle of your project.

android {
    defaultConfig {
        minSdkVersion 23 // required to set

iOS #

Activate url scheme

iOS | Add your URL schemes

Register iOS app info to square account

Bunde id and URL scheme are required.

iOS | Register your application

Define url schema in dart code

For example on main.dart.

var squareCallbackURL = 'your-ios-url-scheme://';

Usage #

Import #

import 'package:flutter_square_pos/flutter_square_pos.dart';

createClient #

Call createClient once.

This sample calls createClient on initState.

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

class _MyAppState extends State<MyApp> {
  void initState() {

startTransaction #

By calling startTransaction, you can get client_transaction_id or error information.

int amount = 809;
String currency = 'JPY';
Map<String, String> result = await FlutterSquarePos.startTransaction(
    tenderTypes: ['CARD', 'CARD_ON_FILE', 'CASH', 'OTHER'])
    callbackURL: squareCallbackURL, // Required for iOS
    skipReceipt: true); // skipReceipt support only for iOS
if (result.containsKey("errorCode")) {
  setState(() {
    _result = result["errorCode"];
    context: this.context,
    builder: (context) => AlertDialog(
      title: Text(result["errorCode"] ?? ""),
      content: Text(result["errorMessage"] ?? ""),
      actions: [
            child: Text('close'),
            onPressed: () => Navigator.pop(context, false))
} else {
  setState(() {
    _result = result["clientTransactionId"];

License #


References #