pub package api doc

A logs router. The messages can be routed to:

  • Terminal
  • Flash messages
  • Snackbar messages


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})


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