upi_chooser 0.0.5 copy "upi_chooser: ^0.0.5" to clipboard
upi_chooser: ^0.0.5 copied to clipboard

Flutter plugin to get the list of UPI apps that are installed on the device.

example/lib/main.dart

import 'dart:async';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:upi_chooser/upi_apps.dart';
import 'package:upi_chooser/upi_chooser.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'UPI Apps',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'UPI Apps'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});
  final String title;
  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  List<UpiApps>? upiAppsData;
  final upiChooser = UpiChooser();

  @override
  void initState() {
    WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
      fetchUpiAppsData();
    });
    super.initState();
  }

  Future<void> fetchUpiAppsData() async {
    upiAppsData = await upiChooser.getUpiAppList();
    setState(() {});
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: upiAppsData == null
          ? const Center(child: CircularProgressIndicator())
          : GridView.builder(
              padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 20),
              shrinkWrap: true,
              itemCount: upiAppsData!.length,
              gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
                crossAxisSpacing: 20,
                mainAxisSpacing: 20,
                childAspectRatio: 1.2,
                crossAxisCount: 3,
              ),
              itemBuilder: (BuildContext context, int index) {
                return SizedBox(
                  height: 60,
                  width: 60,
                  child: Card(
                    child: Container(
                      decoration: BoxDecoration(
                        color: Colors.white,
                        borderRadius: BorderRadius.circular(12),
                      ),
                      child: InkWell(
                        onTap: () async {                    
                          upiChooser.launchUpiChooser(
                            Platform.isIOS
                                ? upiAppsData![index].scheme!
                                : upiAppsData![index].appUri!,
                            'jhon@testupi',
                            "Jhon",
                            "308720457203456",
                            "100",
                            mid: 'J687D7E',
                            orgid: '000000',
                          );
                        },
                        child: Center(
                          child: Column(
                            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                            children: [
                              Expanded(
                                child: Image.network(
                                  upiAppsData![index].iconUrl!,
                                  width: 58,
                                ),
                              ),
                              Text('${upiAppsData![index].displayName}'),
                              const SizedBox(height: 6),
                            ],
                          ),
                        ),
                      ),
                    ),
                  ),
                );
              },
            ),
    );
  }
}
10
likes
110
pub points
75%
popularity
screenshot

Publisher

unverified uploader

Flutter plugin to get the list of UPI apps that are installed on the device.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

appcheck, flutter, plugin_platform_interface, url_launcher

More

Packages that depend on upi_chooser