flutter_mono_widget 0.0.2 copy "flutter_mono_widget: ^0.0.2" to clipboard
flutter_mono_widget: ^0.0.2 copied to clipboard

A new Flutter package project.

example/lib/main.dart

import 'dart:developer';

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

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Mono Widget',
      theme: ThemeData(primarySwatch: Colors.blue),
      home: const MyHomePage(title: 'Flutter Mono Widget Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);
  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  String _apiKey = 'YOUR_MONO_KEY';

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            TextButton(
              onPressed: () async {
                final String? code = await Navigator.of(context).push(
                  MaterialPageRoute(
                    builder: (_) => FlutterMonoConnectWidget(apiKey: _apiKey),
                  ),
                );

                debugPrint('code is : $code');
              },
              child: const Text('connect Widget'),
            ),
            const SizedBox(height: 20),
            TextButton(
              onPressed: () {
                Navigator.of(context).push(
                  MaterialPageRoute(
                    builder: (_) => FlutterMonoPaymentWidget(
                      apiKey: _apiKey,
                      amountInKobo: 200 * 100, // amount in kobo
                      description: 'Testing payments',
                      reference:
                          '${DateTime.now().microsecondsSinceEpoch}_reference_123',
                      transactionReference:
                          '${DateTime.now().microsecondsSinceEpoch}_transactionReference_123',
                      onSuccess: (Map<String, dynamic>? data) {
                        log('data response: $data');
                      },
                    ),
                  ),
                );
              },
              child: const Text('One Time Payment'),
            ),
            const SizedBox(height: 20),
          ],
        ),
      ),
    );
  }
}
0
likes
120
pub points
0%
popularity

Publisher

unverified uploader

A new Flutter package project.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, webview_flutter

More

Packages that depend on flutter_mono_widget