Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR DART

flutter custom error widget

 ErrorWidget.builder = (FlutterErrorDetails details) {
    return YourCustomWidget(
      details: details,
    );
  };
  runApp(const MyApp());
  
  
  
  //YourCustomWidget
  
  class YourCustomWidget extends StatelessWidget {
  const YourCustomWidget({
    Key? key,
    required this.details,
  }) : super(key: key);
  final FlutterErrorDetails details;
  @override
  Widget build(BuildContext context) {
    return Material(
      child: SafeArea(
        child: Container(
          color: Colors.green,
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text(
                details.exception.toString(),
                style: const TextStyle(
                  fontWeight: FontWeight.bold,
                  color: white,
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
 
PREVIOUS NEXT
Tagged: #flutter #custom #error #widget
ADD COMMENT
Topic
Name
2+5 =