cielo 0.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 34

cieloecommerce #

A new Flutter package project.

Getting Started #

This project is a starting point for a Dart package, a library module containing code that can be shared easily across multiple Flutter or Dart projects.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

[0.0.1] - TODO: Add release date. #

  • TODO: Describe initial release.

example/lib/main.dart

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

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {


    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
  
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  final CieloEcommerce cielo = CieloEcommerce(
      environment: Environment.SANDBOX,
      merchant: Merchant(
        merchantId: "933fc4e5-ddfd-4cba-a6de-4c07232d73c6",
        merchantKey: "KDRTLNYFNKMXHBSAVREHOZHBHWSWWYIXWWNQWRCN",
      ));

  _incrementCounter() async {
    print("Iniciando pagamento....");
    Sale sale = Sale(
      merchantOrderId: "123",
      customer: Customer(
        name: "Comprador crédito simples"
      ),
      payment: Payment(
        type: TypePayment.CreditCard,
        amount: 7777,
        installments: 1,
        softDescriptor: "Pagame",
        creditCard: CreditCard(
          cardNumber: "1234123412341231",
          holder: "Teste Holder",
          expirationDate: "12/2030",
          securityCode: "123",
          brand: "Visa",
        )
      )
    );

    try{
    var response = await cielo.createSale(sale);
    print(response.payment.paymentId);

    } catch(e){
      print("ERRO!!");
      print(e);

    }

    


  }

  @override
  Widget build(BuildContext context) {
    // This method is rerun every time setState is called, for instance as done
    // by the _incrementCounter method above.
    //
    // The Flutter framework has been optimized to make rerunning build methods
    // fast, so that you can just rebuild anything that needs updating rather
    // than having to individually change instances of widgets.
    return Scaffold(
      appBar: AppBar(
        // Here we take the value from the MyHomePage object that was created by
        // the App.build method, and use it to set our appbar title.
        title: Text(widget.title),
      ),
      body: Center(
        // Center is a layout widget. It takes a single child and positions it
        // in the middle of the parent.
        child: Column(
          // Column is also layout widget. It takes a list of children and
          // arranges them vertically. By default, it sizes itself to fit its
          // children horizontally, and tries to be as tall as its parent.
          //
          // Invoke "debug painting" (press "p" in the console, choose the
          // "Toggle Debug Paint" action from the Flutter Inspector in Android
          // Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
          // to see the wireframe for each widget.
          //
          // Column has various properties to control how it sizes itself and
          // how it positions its children. Here we use mainAxisAlignment to
          // center the children vertically; the main axis here is the vertical
          // axis because Columns are vertical (the cross axis would be
          // horizontal).
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.display1,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  cielo: ^0.0.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:cielo/cielo.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
7
Health:
Code health derived from static analysis. [more]
96
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
9
Overall:
Weighted score of the above. [more]
34
Learn more about scoring.

We analyzed this package on Jul 8, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

because of import path [cielo] that is in a package requiring null.

Package not compatible with runtime flutter-web on web

Because of the import of dart:io via the import chain package:cielo/cielo.dartpackage:cielo/cielo_ecommerce.dartpackage:dio/dio.dartpackage:dio/src/dio_http_headers.dartdart:io

Health issues and suggestions

Document public APIs. (-1 points)

160 out of 160 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix lib/cielo_ecommerce.dart. (-1 points)

Analysis of lib/cielo_ecommerce.dart reported 2 hints:

line 20 col 3: The class 'Future' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

line 28 col 3: The class 'Future' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

Fix lib/src/Environment.dart. (-1 points)

Analysis of lib/src/Environment.dart reported 2 hints:

line 3 col 25: Name non-constant identifiers using lowerCamelCase.

line 4 col 25: Name non-constant identifiers using lowerCamelCase.

Fix lib/src/Payment.dart. (-1 points)

Analysis of lib/src/Payment.dart reported 2 hints:

line 85 col 17: Name non-constant identifiers using lowerCamelCase.

line 86 col 17: Name non-constant identifiers using lowerCamelCase.

Fix additional 7 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/cielo.dart (Run flutter format to format lib/cielo.dart.)
  • lib/src/Address.dart (Run flutter format to format lib/src/Address.dart.)
  • lib/src/CreditCard.dart (Run flutter format to format lib/src/CreditCard.dart.)
  • lib/src/Customer.dart (Run flutter format to format lib/src/Customer.dart.)
  • lib/src/Link.dart (Run flutter format to format lib/src/Link.dart.)
  • lib/src/Merchant.dart (Run flutter format to format lib/src/Merchant.dart.)
  • lib/src/Sale.dart (Run flutter format to format lib/src/Sale.dart.)

Maintenance issues and suggestions

Support latest dependencies. (-20 points)

The version constraint in pubspec.yaml does not support the latest published versions for 2 dependencies (dio, json_annotation).

Package is getting outdated. (-40.55 points)

The package was last published 73 weeks ago.

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
dio ^2.0.0 2.2.2 3.0.9
flutter 0.0.0
json_annotation ^2.0.0 2.4.0 3.0.1
Transitive dependencies
collection 1.14.12 1.14.13
cookie_jar 1.0.1
meta 1.1.8 1.2.1
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
build_runner ^1.0.0
flutter_test
json_serializable ^2.0.0