import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:zhiying_base_widget/pages/home_page/home_page.dart'; import 'package:zhiying_base_widget/register.dart'; void main() { FlutterError.onError = (FlutterErrorDetails details) { FlutterError.dumpErrorToConsole(details); print(details.exceptionAsString()); // if (kReleaseMode) exit(1); }; runApp(MyApp()); } class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); } class _MyAppState extends State { Widget getErrorWidget(BuildContext context, FlutterErrorDetails error) { return Center( child: Text( "走神了~\n${error.exceptionAsString()}", style: Theme.of(context).textTheme.title.copyWith(color: Colors.redAccent), ), ); } @override void initState() { super.initState(); print('初始化~~~~'); BaseWidgetRegister.init(); } @override Widget build(BuildContext context) { ErrorWidget.builder = (FlutterErrorDetails errorDetails) { return getErrorWidget(context, errorDetails); }; return MaterialApp( home: HomePage(), ); } }