Last active
June 26, 2022 09:16
-
-
Save RyanDsilva/627104709ac85c6d2007e694fc7b326d to your computer and use it in GitHub Desktop.
Custom Error Widget
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| return MaterialApp( | |
| title: 'Flutter App', | |
| builder: (context, widget) { | |
| ErrorWidget.builder = (FlutterErrorDetails errorDetails) { | |
| return CustomErrorWidget(errorDetails: errorDetails); | |
| }; | |
| return widget ?? const Scaffold(); | |
| }, | |
| ... | |
| ... | |
| class CustomErrorWidget extends StatelessWidget { | |
| final FlutterErrorDetails errorDetails; | |
| const CustomErrorWidget({ | |
| Key? key, | |
| required this.errorDetails, | |
| }) : super(key: key); | |
| @override | |
| Widget build(BuildContext context) { | |
| return const Card( | |
| color: Colors.red, | |
| margin: EdgeInsets.zero, | |
| child: Padding( | |
| padding: EdgeInsets.all(8.0), | |
| child: Text( | |
| "Something is not right here...", | |
| style: TextStyle( | |
| color: Colors.white, | |
| fontWeight: FontWeight.bold, | |
| ), | |
| ), | |
| ), | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment