0

As of my understanding, I know that the stateful widget build method can be called multiple times.

I don't understand why the Root widget MaterialApp is called multiple times even I have used a stateless widget.

Here is the code

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await SharedPref.init();

  Bloc.observer = BSCTaxObserver();
  runApp(BSC());
}

class BSC extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    print('*** Root widget called ***');
    return MultiBlocProvider(
      providers: [
        BlocProvider<DocumentsBloc>(
          create: (context) => DocumentsBloc(APIService()),
        ),
        BlocProvider<FileUploadBloc>(
          create: (context) => FileUploadBloc(APIService()),
        ),
        BlocProvider<PdfBloc>(
          create: (context) => PdfBloc(APIService()),
        ),
        BlocProvider<AccountBloc>(
            create: (context) => AccountBloc(APIService()))
      ],
      child: MaterialApp(
        debugShowCheckedModeBanner: false,
        title: AppStrings.appName,
        builder: BotToastInit(),
        navigatorObservers: [BotToastNavigatorObserver()],
        theme: ThemeData(
          textTheme: GoogleFonts.poppinsTextTheme(),
          primaryColor: AppColors.primaryColor,
          primaryColorDark: AppColors.primaryDark,
          primaryColorLight: AppColors.primaryLight,
          primarySwatch: Colors.indigo,
          visualDensity: VisualDensity.adaptivePlatformDensity,
        ),
        home: LoginScreen(),
        
      ),
    );
  }
}

Here is log

enter image description here

Thanks in advance

Jigar Fumakiya
  • 2,039
  • 1
  • 8
  • 21

0 Answers0