flutter_base_plus 1.3.0 copy "flutter_base_plus: ^1.3.0" to clipboard
flutter_base_plus: ^1.3.0 copied to clipboard

Flutter基础库:包含路由、Flutter应用初始化

example/lib/main.dart

import 'package:flutter_base_plus/flutter_base_plus.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';

import 'app_routers.dart';
import 'dialog/custom_loading_widget.dart';
import 'dialog/custom_toast_widget.dart';

void main() {
  // 先创建
  WidgetsFlutterBinding.ensureInitialized();
  runApp(MyApp());
}

class MyApp extends BaseAppRoot {
  late final DateTime startDateTime;

  MyApp({Key? key})
      : super(
          key: key,
          config: AppConfig(
              theme: ThemeData(
                primarySwatch: Colors.blue,
              ),
              routers: AppRouters().routers,
              homeName: "page_1",
              observers: [FlutterSmartDialog.observer, TestNavigatorObserver()],
              transitionBuilder: FlutterSmartDialog.init(
                //default toast widget
                toastBuilder: (String msg, AlignmentGeometry alignment) {
                  return CustomToastWidget(msg: msg, alignment: alignment);
                },
                //default loading widget
                loadingBuilder: (String msg, Color background) {
                  return CustomLoadingWidget(msg: msg, background: background);
                },
              ),
          ),
        ) {
    startDateTime = DateTime.now();
  }

  @override
  void buildFinishCallBack() {
    debugPrint(
        'MyApp.buildFinishCallBack:${DateTime.now().millisecondsSinceEpoch - startDateTime.millisecondsSinceEpoch} ms');
  }
}

/// 测试用路由观察者
class TestNavigatorObserver extends NavigatorObserver {
  @override
  void didPush(Route<dynamic> route, Route<dynamic>? previousRoute) {}

  @override
  void didReplace({Route<dynamic>? newRoute, Route<dynamic>? oldRoute}) {}

  @override
  void didRemove(Route<dynamic> route, Route<dynamic>? previousRoute) {}

  @override
  void didPop(Route<dynamic> route, Route<dynamic>? previousRoute) async {}
}
1
likes
125
points
20
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter基础库:包含路由、Flutter应用初始化

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_base_plus