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

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: (context) => CartScreen(
                            items: items,
                          ))),
              icon: Icon(Icons.shopping_bag_outlined))
        ],
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          children: [
            ...items
                .map((e) => ListTile(
                      title: Text(e.title! + ' x${e.quantity}u'),
                      trailing: Text('\$${e.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
0
pub points
36%
popularity

Publisher

unverified uploader

An unofficial package of MercadoPago Mobile Checkout.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, freezed_annotation, http, json_annotation

More

Packages that depend on mpcheckout