err 0.8.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 81

Err #

pub package api doc

A logs router. The messages can be routed to:

  • Terminal
  • Flash messages
  • Snackbar messages

Configuration #

Configure the log levels's routes: available routes: console, screen, notifications or black hole. All the logs routed to the black hole will be silently swallowed: use it this to disable a route.

All routes default to console.

   import 'package:err/err.dart';

   var logger = ErrRouter(
      criticalRoute: [ErrRoute.console, ErrRoute.screen],
      errorRoute: [ErrRoute.screen, ErrRoute.console],
      warningRoute: [ErrRoute.screen, ErrRoute.console],
      infoRoute: [ErrRoute.screen],
      debugRoute: [ErrRoute.blackHole]);

Screen route #

Flash messages #

The flash messages are toast messages. They stay one second on the screen

   void initState() {
      logger.debugFlash("Init state");

Available flash messages:

infoFlash(String msg): an information message. Stays for 1 second on screen.

debugFlash(String msg): a debug message. Stays for 1 second on screen.

warningFlash(String msg): a warning message. Stays for 3 seconds on screen.

errorFlash(String msg): an error message. Stays for 5 seconds on screen.

flash(String msg): alias for debugFlash


Snackbar messages #

The snackbar messages need a BuildContext

   logger.infoScreen("File uploaded in $elapsed s", context: context);
   logger.debugScreen("A debug message", context: context);
   try {
   } catch(ex) {
         err: ex,
         msg: "Something wrong happened",
         context: context);  

Available messages #

criticalScreen(String msg, {@required BuildContext context, dynamic err})

errorScreen(String msg, {@required BuildContext context, dynamic err})

warningScreen(String msg, {@required BuildContext context,dynamic err, bool short})

infoScreen(String msg, {@required BuildContext context,dynamic err, bool short})

debugScreen(String msg, {@required BuildContext context,dynamic err, bool short})

Parameters: #

msg : a text message

err : an error or exception

short : if enabled the message will stay on screen for 5 seconds. If not it will stay until dismissed

context : the build context required for screen messages


Console route #

critical(String msg, {dynamic err})

error(String msg)

warning(String msg, {dynamic err})

info(String msg)

debug(String msg, {dynamic err})


By default the terminal output is configured for black and white. If your terminal supports colorized unicode emoticons use this parameter:

   var logger = ErrRouter(
      // ...
      terminalColors: true);


On device console #

A console log is available on the device. To enable it:

    // ...
    deviceConsole: true

Navigate to DeviceConsolePage(logger) to see the console on the device

Libraries used #

Changelog #

0.8.0 #

  • Add an errorFlash method
  • Add on device console option
  • Refactoring
  • Use pedantic for static anlytics

0.7.3 #

  • Add an errorFlash method

0.7.2 #

  • Fix the infoScreen short parameter
  • Set short messages duration to 5 seconds

0.7.1 #

Fix infoFlash and debugFlash

0.7.0 #

  • Breaking change: fix some functions in the api to be easier to use

  • Use more strict linting rules

0.6.0 #

Remove the notifications route to avoid permissions issues

0.5.0 #

Breaking change: the context parameter is now positionnal for the main methods

Feature: add the notification route

0.4.0 #

Add sync functions

0.3.0 #

Breaking change: the api has been simplified with a more efficient syntax

0.2.0 #

Improve the terminal output

0.1.0 #

Initial release


Example #

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Err example',
      home: MyHomePage(),

class _MyHomePageState extends State<MyHomePage> {

var logger = ErrRouter(
    criticalRoute: [ErrRoute.console, ErrRoute.screen],
    errorRoute: [ErrRoute.screen, ErrRoute.console],
    warningRoute: [ErrRoute.screen, ErrRoute.console],
    infoRoute: [ErrRoute.screen, ErrRoute.console],
    debugRoute: [ErrRoute.screen, ErrRoute.console]);

  void initState() {
    logger.debugFlash("Init state");

  bool firstBuildDone = false;

  Widget build(BuildContext context) {
    if (!firstBuildDone)
      logger.debugFlash("First build").then((_) {
        firstBuildDone = true;
    return Scaffold(
        body: Padding(
            padding: EdgeInsets.all(25.0),
            child: ListView(
              children: <Widget>[
                  child: Text("Info flash message"),
                  onPressed: () => logger.infoFlash("An info flash message"),
                    child: Text("Info regular message"),
                    onPressed: () =>
              "An info message", context: context)),
                    child: Text("Warning message"),
                    onPressed: () => logger.warning("Hey, this is warning!",
                        context: context)),
                    child: Text("Error message"),
                    onPressed: () =>
                        logger.error("Something went wrong", context: context)),
                    child: Text("Critical message from exception"),
                    onPressed: () {
                      try {
                      } catch (e) {
                            msg: "Something went really wrong",
                            err: e,
                            context: context);
                    child: Text("Debug message"),
                    onPressed: () =>
                        logger.debug("Debug info message", context: context)),

  _doWrong() {
    List<String> li;

class MyHomePage extends StatefulWidget {
  _MyHomePageState createState() => _MyHomePageState();

Use this package as a library

1. Depend on it

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

  err: ^0.8.0

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

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

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

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 (logger).


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
cupertino_icons ^0.1.2 0.1.3
flushbar ^1.8.2 1.9.1
flutter 0.0.0
fluttertoast ^3.1.0 3.1.3
logger ^0.7.0+2 0.7.0+2 0.8.3
pedantic ^1.7.0 1.9.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies