Giter VIP home page Giter VIP logo

flutter_error's Introduction

Flutter Error Page

I'm sure you've seen this!

Do you know how to customize this error screen?

🐛 Debug Mode 📱 Release Mode

You have certainly come across this red screen while developing applications, and you should also know that in release mode it turns grey.

Can you imagine your users seeing this unfriendly screen?

There is the solution for this, and I'll show you.


How to make

When an error occurs, the ErrorWidget.builder is called; and by default the behaviour is what we already know.

But we can customize this, returning a widget of our own.

return MaterialApp(
  title: 'Flutter Error Page',
  home: const MyHomePage(),
  builder: (context, widget) {
    ErrorWidget.builder = (FlutterErrorDetails errorDetails) {
      return CustomError(errorDetails: errorDetails); // the custom widget
    };

    return widget ?? const SizedBox.shrink();
  },
);

Just return it in this callback.

And on it, you can do absolutely whatever you want (remember to consider the constraints, available space, e.g) - happen at the most unexpected moment. 😆

return const MyAppCard(
  color: Colors.red,
  text: 'Um erro ocorreu.',
);

How will it be

Expected Default Error Release Error Debug and/or Release with custom widget

So, did you know this strategy?

Star ⭐️ this project if you liked it, and share it! 🚀

flutter_error's People

Contributors

felipecastrosales avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

flutter_error's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.