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

outdated

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 'package:mpcheckout_example/cart.dart';

// Make it global
late Mpcheckout mp;

void main() {
  /// initialize credentials
  mp = Mpcheckout.initialize(
      clientID: 'clientID', publicKey: 'publicKey', accesToken: 'accesToken');
  runApp(MaterialApp(home: MyApp()));
}

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

class _MyAppState extends State<MyApp> {
  final List<Items> items = [
    Items(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(Items(
                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, http, json_annotation

More

Packages that depend on mpcheckout