I am having an exception that I don't understand in my Flutter app. Here is the code :
main.dart:
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Qatar22',
debugShowCheckedModeBanner: false,
theme: new ThemeData(
accentColor: Colors.black,
indicatorColor: Colors.black,
highlightColor: Colors.black,
bottomAppBarColor: Colors.black,
primaryColor: Color(0xFFffffff),
primaryColorDark: Color(0xffffff)),
home: SplashScreen(),
routes: <String, WidgetBuilder>{
SPLASH_SCREEN: (BuildContext context) => SplashScreen(),
FEED_SCREEN: (BuildContext context) => FeedScreen(),
PROGRAM_SCREEN: (BuildContext context) => ProgramScreen(),
},
);
}
}
FeedScreen:
class FeedScreen extends StatefulWidget {
@override
State<FeedScreen> createState() => _FeedScreenState();
}
/// This is the private State class that goes with MyStatefulWidget.
class _FeedScreenState extends State<FeedScreen> {
int _selectedIndex = 0;
final List<Widget> _widgetOptions = [FeedScreen(), ProgramScreen()];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Gallery'),
),
body: Center(
child: _widgetOptions.elementAt(_selectedIndex),
),
bottomNavigationBar: BottomNavigationBar(
items: [
BottomNavigationBarItem(
icon: Icon(CupertinoIcons.news_solid),
label: 'Feed',
),
BottomNavigationBarItem(
icon: Icon(CupertinoIcons.sportscourt_fill),
label: 'Program',
)
],
currentIndex: _selectedIndex,
selectedItemColor: Colors.red.shade900,
onTap: (index) {
switch (index) {
case 0:
Navigator.pushNamed(context, FEED_SCREEN);
break;
case 1:
Navigator.pushNamed(context, PROGRAM_SCREEN);
break;
}
}),
);
}
}
and I am getting this exception:
The following JSRangeError was thrown building NotificationListener<LayoutChangedNotification>:
Invalid argument: Maximum call stack size exceededThe relevant error-causing widget was:
Scaffold file:///home/project/lib/screens/feed/feed-screen.dart:21:12
Would you help me please as I am new to Flutter.