hubble_sdk 0.4.1 copy "hubble_sdk: ^0.4.1" to clipboard
hubble_sdk: ^0.4.1 copied to clipboard

unlisted

Hubble Money - A rewarding platform for your purchases

Hubble's SDK for flutter #

Getting Started #

Please contact us at myhubble.money/support for more information.

Installation #

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

dependencies:
  hubble_sdk: {current_latest_version}

Usage example #


import 'package:hubble_sdk/hubble_sdk.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

class _SampleApp extends StatefulWidget {
  const _SampleApp();

  @override
  State<_SampleApp> createState() => _SampleAppState();
}

class _SampleAppState extends State<_SampleApp> {
  void openSDK(BuildContext context) {
    HubbleSDKController.open(
      context,
      clientSecret: _clientSecret,
      clientId: _clientId,
      authToken: _token,
      pageLoadingIndicatorBuilder: (context, color, scale) {
        return Center(
          child: SizedBox(
            width: 50,
            height: 50,
            child: CircularProgressIndicator(
              color: color,
            ),
          ),
        );
      },
    );
  }

  var _token = 'somethigfn';
  var _clientId = 'something';
  var _clientSecret = 'secretGivenByHubble';

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      routes: <String, WidgetBuilder>{
        '/': (BuildContext context) {
          return Scaffold(
            backgroundColor: Colors.white,
            appBar: AppBar(
              title: const Text('Hubble SDK Example'),
            ),
            body: Center(
                child: Column(
              mainAxisSize: MainAxisSize.min,
              children: [
                Container(
                  margin: const EdgeInsets.all(8),
                  padding: const EdgeInsets.all(8),
                  decoration: BoxDecoration(
                    border: Border.all(
                      color: Colors.black,
                    ),
                    borderRadius: BorderRadius.circular(4),
                  ),
                  child: TextFormField(
                    initialValue: _token,
                    onChanged: (value) {
                      _token = value;
                    },
                    decoration: const InputDecoration(
                      border: InputBorder.none,
                      hintText: 'Enter token',
                    ),
                  ),
                ),
                Container(
                  margin: const EdgeInsets.all(8),
                  padding: const EdgeInsets.all(8),
                  decoration: BoxDecoration(
                    border: Border.all(
                      color: Colors.black,
                    ),
                    borderRadius: BorderRadius.circular(4),
                  ),
                  child: TextFormField(
                    initialValue: _clientId,
                    onChanged: (value) {
                      _clientId = value;
                    },
                    decoration: const InputDecoration(
                      border: InputBorder.none,
                      hintText: 'Enter client id',
                    ),
                  ),
                ),
                Container(
                  margin: const EdgeInsets.all(8),
                  padding: const EdgeInsets.all(8),
                  decoration: BoxDecoration(
                    border: Border.all(
                      color: Colors.black,
                    ),
                    borderRadius: BorderRadius.circular(4),
                  ),
                  child: TextFormField(
                    initialValue: _clientSecret,
                    onChanged: (value) {
                      _clientSecret = value;
                    },
                    decoration: const InputDecoration(
                      border: InputBorder.none,
                      hintText: 'Enter client secret',
                    ),
                  ),
                ),
                ElevatedButton(
                  onPressed: () {
                    openSDK(context);
                  },
                  child: const Text('Launch SDK (material page)'),
                ),
                ElevatedButton(
                  onPressed: () async {
                    openSDK(context);
                  },
                  child: const Text('Launch SDK (Page builder)'),
                ),
              ],
            )),
          );
        },
      },
    );
  }
}

UPI Intent #

To enable UPI Intent, add the following to your AndroidManifest.xml file:

<manifest ... > 
    ...
    <queries>
        <package android:name="com.phonepe.app" />
        <package android:name="net.one97.paytm" />
        <package android:name="com.google.android.apps.nbu.paisa.user" />
        <package android:name="in.org.npci.upiapp" />
        <package android:name="in.amazon.mShop.android.shopping" />
        <package android:name="com.dreamplug.androidapp" />
        ...

in iOS, add the following to your Info.plist file:

	<key>LSApplicationQueriesSchemes</key>
	<array>
		<string>phonepe</string>
		<string>paytm</string>
		<string>paytmmp</string>
		<string>tez</string>
		<string>credpay</string>
		<string>upi</string>
		<string>BHIM</string>
		<string>ppesim</string>
	</array>