About 6 months ago, the code was working just fine, and then this exception occurred. i don't know what to do about it because I tried to fix it by making it nullable but it didn't work So what should I do? the code is a bottom navigation bar this is a picture of the exception :
the code :
import 'package:blackboard/view/Teacher/AddSheetTeacher.dart';
import 'package:blackboard/view/Teacher/CoursesTeacher.dart';
import 'package:blackboard/view/Teacher/HSTeacher.dart';
import 'package:blackboard/view/Teacher/CoursesTeacher1.dart';
import 'package:flutter/material.dart';
import 'package:blackboard/view/Teacher/HomeScreenTeacher.dart';
import 'package:blackboard/view/Teacher/YourCoursesTeacher.dart';
import 'package:blackboard/view/Teacher/ProfileTeacher.dart';
class dashboard extends StatefulWidget {
@override
State<dashboard> createState() => _dashboardState();
}
class _dashboardState extends State<dashboard> {
int _currentIndex = 0;
List screens = [CoursesT, HomeScreenTeacher(), HomeScreen()];
void _updateIndex(int value) {
setState(() {
_currentIndex = value;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: screens[_currentIndex],
bottomNavigationBar: BottomNavigationBar(
backgroundColor: Colors.transparent,
elevation: 0,
type: BottomNavigationBarType.fixed,
currentIndex: _currentIndex,
onTap: (_updateIndex),
selectedItemColor: Colors.purple.shade700,
selectedFontSize: 13,
unselectedFontSize: 13,
iconSize: 30,
items: [
BottomNavigationBarItem(
label: "HomeScreen",
icon: Icon(
Icons.home,
size: 30,
),
),
BottomNavigationBarItem(
label: "Course",
icon: Icon(
Icons.book,
size: 30,
),
),
BottomNavigationBarItem(
label: "Profile",
icon: Icon(
Icons.account_box,
size: 30,
),
),
],
),
);
}
}
CodePudding user response:
Mention the type of the list List<Widget>
List screens = [CoursesT, HomeScreenTeacher(), HomeScreen()];
to
List<Widget> screens = [CoursesT, HomeScreenTeacher(), HomeScreen()];
CodePudding user response:
The issue is here on CoursesT
which is need to be CoursesT()
inside screens
.
List<Widget> screens = [CoursesT(), HomeScreenTeacher(), HomeScreen()];