build method

  1. @nonVirtual
  2. @override
Widget build(
  1. BuildContext context
)
override

The build methods should not be overridden, otherwise Lowder may not work properly.

Implementation

@nonVirtual
@override
Widget build(BuildContext context) {
  final providers = <BlocProvider>[
    BlocProvider<GlobalBloc>(create: (c) => widget.createBloc(), lazy: false)
  ];
  if (Lowder.editorMode) {
    providers.add(
        BlocProvider<EditorBloc>(create: (c) => EditorBloc(), lazy: false));
  }

  var goHome = false;
  final rootWidget = StatefulBuilder(
    builder: (context, setState) {
      if (!goHome) {
        return PopScope(
          canPop: false,
          onPopInvoked: (didPop) async {
            await load();
            setState(() => goHome = true);
          },
          child: widget.getInitialScreen(context),
        );
      }
      return buildBody(context);
    },
  );

  return MultiBlocProvider(
    providers: providers,
    child: Builder(
        builder: (context) =>
            widget.buildApp(Lowder.navigatorKey, rootWidget)),
  );
}