mpcheckout 1.1.2 copy "mpcheckout: ^1.1.2" to clipboard
mpcheckout: ^1.1.2 copied to clipboard

PlatformAndroid

An unofficial package of MercadoPago Mobile Checkout.

example/lib/main.dart

import 'dart:math';

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

import 'cart.dart';

/// [mp] instance (make it global)
late Mpcheckout mp;

void main() {
  /// initialize credentials
  mp = Mpcheckout.initialize(
    clientID: const String.fromEnvironment("CLIENT_ID"),
    publicKey: const String.fromEnvironment("PUBLIC_KEY"),
    accesToken: const String.fromEnvironment("ACCESS_TOKEN"),
  );
  runApp(MaterialApp(home: MyApp()));
}

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

class _MyAppState extends State<MyApp> {
  final List<Item> items = [
    Item(
      title: 'Articulo de prueba 1',
      quantity: 1,
      unitPrice: 150,
    ),
  ];

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('MercadoPagoSDK'),
        centerTitle: true,
        actions: [
          IconButton(
            onPressed: () => Navigator.push(
              context,
              MaterialPageRoute(
                builder: (_) => CartScreen(
                  items: items,
                ),
              ),
            ),
            icon: Icon(
              Icons.shopping_bag_outlined,
            ),
          )
        ],
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          children: [
            ...items
                .map(
                  (item) => ListTile(
                    title: Text(item.title! + ' x${item.quantity}u'),
                    trailing: Text('\$${item.unitPrice}'),
                  ),
                )
                .toList(),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          setState(
            () {
              items.add(
                Item(
                  title: 'Articulo de prueba ${items.length + 1}',
                  quantity: 1,
                  unitPrice: Random().nextInt(350),
                ),
              );
            },
          );
        },
        child: Icon(Icons.add),
      ),
    );
  }
}
5
likes
110
pub points
26%
popularity
screenshot

Publisher

unverified uploader

An unofficial package of MercadoPago Mobile Checkout.

Repository (GitHub)
View/report issues

Documentation

API reference

Funding

Consider supporting this project:

cafecito.app

License

MIT (LICENSE)

Dependencies

flutter, freezed_annotation, http, json_annotation

More

Packages that depend on mpcheckout