基础组件库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

55 rivejä
1.4 KiB

  1. import 'package:flutter/foundation.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:zhiying_base_widget/pages/home_page/home_page.dart';
  4. import 'package:provider/provider.dart';
  5. import 'package:zhiying_base_widget/register.dart';
  6. import 'package:zhiying_comm/zhiying_comm.dart';
  7. void main() {
  8. FlutterError.onError = (FlutterErrorDetails details) {
  9. FlutterError.dumpErrorToConsole(details);
  10. print(details.exceptionAsString());
  11. // if (kReleaseMode) exit(1);
  12. };
  13. runApp(MyApp());
  14. }
  15. class MyApp extends StatefulWidget {
  16. @override
  17. _MyAppState createState() => _MyAppState();
  18. }
  19. class _MyAppState extends State<MyApp> {
  20. Widget getErrorWidget(BuildContext context, FlutterErrorDetails error) {
  21. return Center(
  22. child: Text(
  23. "走神了~\n${error.exceptionAsString()}",
  24. style:
  25. Theme.of(context).textTheme.title.copyWith(color: Colors.redAccent),
  26. ),
  27. );
  28. }
  29. @override
  30. void initState() {
  31. super.initState();
  32. print('初始化~~~~');
  33. BaseWidgetRegister.init();
  34. }
  35. @override
  36. Widget build(BuildContext context) {
  37. ErrorWidget.builder = (FlutterErrorDetails errorDetails) {
  38. return getErrorWidget(context, errorDetails);
  39. };
  40. return MultiProvider(
  41. providers: [
  42. ChangeNotifierProvider.value(value: UserInfoNotifier()),
  43. ],
  44. child: MaterialApp(
  45. home: HomePage(),
  46. ),
  47. );
  48. }
  49. }