djalmautil 1.0.5

  • Readme
  • Changelog
  • Example
  • Installing
  • 61

djalma_util #

Um pacote para facilitar a chamada de métodos que são comumente chamados nos projetos.

ColorToMaterial(hex) #

Converte uma Color para MaterialColor passando o hexadecimal de seis caracteres.

  • push(context, screen, RouteType.Material ou Cupertino);
  • pushReplacement(context, screen, RouteType.Material ou RouteType.Cupertino);
  • pop(context);
  • pushAndRemoveUntil(context, screen, RouteType.Material ou RouteType.Cupertino);

customSnackBar(key, message, cor, duration) #

dateFormatter() #

Formata a data vinda do DateTime para o Brasil. Sem dateFormatter: 1969-07-20 20:18:04 0000 Com dateFormatter: 20/07/1969 20:18

firebaseErrorCheck(exception) #

Lê e já retorna a mensagem de erro em português pronta para o usuário da falha.

getFullAddressByCep(cep) #

Busca o endereço completo do usuário pelo CEP.

MediaQuery com menos código #

  • getHeight(context) - Pega a altura da tela.

  • getWidth(context) - Pega a largura da tela.

getOrientation(context) #

Método para recuperar a orientação da tela.

formatPrice(int) #

Útil para formatar preço como int vindo do Firestore e deixar pronto para mostrar num Text().

formatPriceToFirestore() #

Útil para salvar valores em dinheiro em String no Firestore.

showCustomDialog #

Método pronto para abrir Dialog com opção de sim e não, opção não fecha ao tocar e opção sim excecuta o método enviado por parametro.

removeSpecialCharacters(text) #

Remove caracteres especiais de uma String e substitui por vazio.

[1.0.0] - Primeiro release. #

  • Primeiro release

[1.0.1] - Atualizado o readme. #

  • Atualizado o readme

[1.0.2] - Atualizado o método getFullAddressByCep. #

  • O método getFullAddressByCep recebe o cep, e opcionalmente o parametro number, que já traz o endereço com o numero e complemento caso adicionado.

[1.0.3] - Adiconado novos métodos. #

  • Adicionado método getOrientation e atualizado o método de busca de CEP.

[1.0.4] - Atualiação no parametro routeType. #

  • Parametro routeType nos métodos de navegação será opcional, se não informado será usado MaterialPageRoute.

[1.0.5] - Removido OneSignal Helper. #

  • Removido OneSignal Helper.

example/lib/main.dart

import 'package:djalmautil/djalmautil.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:search_cep/search_cep.dart';

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

class MyApp extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Djalma Util',
      theme: ThemeData(
        primarySwatch: colorToMaterialColor("5e35b1"),
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'Djalma Util'),
    );
  }
}

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

  final String title;

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

class _MyHomePageState extends State<MyHomePage> {

  final scaffoldKey = GlobalKey<ScaffoldState>();
  final TextEditingController cepController = TextEditingController();

  @override
  Widget build(BuildContext context) {

    Widget customButton(String text, Function function){

      return SizedBox(
        height: 60,
        child: RaisedButton(
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(5)
          ),
          color: Theme.of(context).primaryColor,
          child: Text(text, style: TextStyle(color: Colors.white),),
          onPressed: function,
        ),
      );

    }

    Widget spaceBetween(){
      return SizedBox(height: 20,);
    }

    return Scaffold(
      key: scaffoldKey,
      appBar: AppBar(
        title: Text(widget.title),
        centerTitle: true,
      ),
      body: Container(
        padding: const EdgeInsets.all(16),
        child: SingleChildScrollView(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.stretch,
            mainAxisAlignment: MainAxisAlignment.start,
            children: [

              Text(
                "O uso de colorToMaterialColor para transformar uma Color em MaterialColor foi usando no main"
                    "dentro do ThemeData, primarySwatch, ja que ele só aceita MaterialColor e não Color"
              ),

              spaceBetween(),

              customButton(
                "push(context, Screen(), RouteType.Material ou RouteType.Cupertino)",
                (){push(context, Page2(),);}
              ),

              spaceBetween(),

              customButton("customSnackBar", (){
                customSnackBar(
                    scaffoldKey: scaffoldKey,
                    message: "Teste Custom SnackBar de 5 Segundos",
                    color: Colors.blue,
                );
              }),

              spaceBetween(),

              Text("dateFormatter ${dateFormatter(DateTime.now().toString())}"),

              spaceBetween(),

              Text("Chamando firebaseErrorCheck(erro), no lugar do 'erro', passe a Exception"
                  "do Try e Catch do Firebase que retorna a mensagem de erro automatico"),

              spaceBetween(),

              TextFormField(
                 controller: cepController,
                decoration: InputDecoration(
                  hintText: "Digite o CEP",
                  border: OutlineInputBorder()
                ),
              ),

              FlatButton(
                shape: RoundedRectangleBorder(
                  side: BorderSide(
                    color: Colors.black
                  )
                ),
                onPressed: () async{

                  if(cepController.text.isNotEmpty){
                    CepInfo cepInfo = await getFullAddressByCep(cep: cepController.text);

                    if(cepInfo != null){

                      setState(() {
                        cepController.text = "";
                      });

                    } else {
                      customSnackBar(
                          scaffoldKey: scaffoldKey,
                          message: "Endereço não localizado, verifique o CEP digitado!",
                          color: Colors.blue
                      );
                    }

                  }

                },
                child: Text(" getFullAddressByCep(cep)"),
              ),

              spaceBetween(),

              customButton(
                  "getHeight",
                  (){
                    customSnackBar(
                        scaffoldKey: scaffoldKey,
                        message: "${getHeight(context)}",
                        color: Colors.blue,
                        duration: Duration(seconds: 2)
                    );
                  }
              ),

              spaceBetween(),

              customButton(
                  "getWidth",
                  (){
                    customSnackBar(
                        scaffoldKey: scaffoldKey,
                        message: "${getWidth(context)}",
                        color: Colors.blue,
                        duration: Duration(seconds: 2)
                    );
                  }
              ),

              spaceBetween(),

              customButton(
                  "getOrientation",
                      (){
                    customSnackBar(
                        scaffoldKey: scaffoldKey,
                        message: "${getOrientation(context)}",
                        color: Colors.blue,
                        duration: Duration(seconds: 2)
                    );
                  }
              ),

              spaceBetween(),

              Text("formatPrice(valor): ${formatPrice(1000)}"),

              spaceBetween(),

              customButton(
                  "showCustomDialog",
                  (){
                    showCustomDialog(
                      title: "Custom Dialog",
                      message: "Mostrando Custom Dialog",
                      voidCallback: (){},
                      context: context
                    );
                  }
              ),

              spaceBetween(),

              Text("removeSpecialCharacters(Preço) ${removeSpecialCharacters("Preço")}"),

            ],
          ),
        ),
      ),
    );
  }
}

class Page2 extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Page 2"),
        centerTitle: true,
      ),
      body: Container(
        child: Center(
          child: SizedBox(
            height: 50,
            child: RaisedButton(
              color: Theme.of(context).primaryColor,
              child: Text("Calling pop(context)"),
              onPressed: (){

                pop(context);

              },
            ),
          ),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  djalmautil: ^1.0.5

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:djalmautil/djalmautil.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
29
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
81
Overall:
Weighted score of the above. [more]
61
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

Because:

  • djalmautil that is a package requiring null.

Health suggestions

Format lib/src/color_to_materialcolor.dart.

Run flutter format to format lib/src/color_to_materialcolor.dart.

Format lib/src/custom_navigator.dart.

Run flutter format to format lib/src/custom_navigator.dart.

Format lib/src/custom_snackbar.dart.

Run flutter format to format lib/src/custom_snackbar.dart.

Fix additional 8 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/date_formatter.dart (Run flutter format to format lib/src/date_formatter.dart.)
  • lib/src/firebase_error_check.dart (Run flutter format to format lib/src/firebase_error_check.dart.)
  • lib/src/get_address.dart (Run flutter format to format lib/src/get_address.dart.)
  • lib/src/media_query.dart (Run flutter format to format lib/src/media_query.dart.)
  • lib/src/onesignal_helper.dart (Run flutter format to format lib/src/onesignal_helper.dart.)
  • lib/src/price_formatter.dart (Run flutter format to format lib/src/price_formatter.dart.)
  • lib/src/remove_special_characters.dart (Run flutter format to format lib/src/remove_special_characters.dart.)
  • lib/src/show_custom_dialog.dart (Run flutter format to format lib/src/show_custom_dialog.dart.)

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (search_cep).

The package description is too short. (-9 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.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
dio >=3.0.9 <4.0.0 3.0.9
flutter 0.0.0
intl >=0.16.1 <1.0.0 0.16.1
money2 >=1.3.0 <2.0.0 1.4.0 2.0.0-nonnullable.1
search_cep >=1.0.4 <2.0.0 1.0.4 3.0.0+1
Transitive dependencies
charcode 1.1.3
collection 1.14.12 1.14.13
convert 2.1.1
http 0.12.1
http_parser 3.1.4
meta 1.1.8 1.2.2
path 1.7.0
pedantic 1.9.0 1.9.2
petitparser 3.0.4
sky_engine 0.0.99
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
xml 4.2.0
xml2json 4.3.0
Dev dependencies
flutter_test