Skip to content

Instantly share code, notes, and snippets.

@RyanDsilva
Last active June 26, 2022 09:16
Show Gist options
  • Select an option

  • Save RyanDsilva/627104709ac85c6d2007e694fc7b326d to your computer and use it in GitHub Desktop.

Select an option

Save RyanDsilva/627104709ac85c6d2007e694fc7b326d to your computer and use it in GitHub Desktop.
Custom Error Widget
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