A global key was used multiple times inside one widgets child list A global key was used multiple times inside one widgets child list dart dart

A global key was used multiple times inside one widgets child list


In my case this error happened because I had a initialRoute property set, while instead I should set the home property:

class RouteTestApp extends StatelessWidget {  @override  Widget build(BuildContext context) {    return MaterialApp(      title: 'Demo',      //initialRoute: '/', //remove this      home: FirstScreen(),  //this is the calling screen      routes: {        ExtractArgumentsScreen.routeName: (context) => ExtractArgumentsScreen(),      },    );  }}


Try stop and rerun you application instead of hot reloading. That solved my problem.


In my case, I run the flutter app without addinghome: BottomNavBar().after getting an error I added home: BottomNavBar() and give hot reload (Command + s) which reproduce this error (A global key was used multiple times inside one widget child list).Then I just reconnect my target device and run again, which fixed my issue.

class MyApp extends StatelessWidget {  @override  Widget build(BuildContext context) {    return MaterialApp(      debugShowCheckedModeBanner: false,      theme: ThemeData(        brightness:Brightness.light,        primaryColor: Colors.white,        accentColor: Colors.blue,        fontFamily: 'Poppins',        appBarTheme: AppBarTheme(          centerTitle: true,        ),      ),      home: BottomNavBar(),    );  }}