i am trying to pass a custom object called "Lesson" to a screen called "ExamScreen"
here is the call:
goStepScreen(int statusId, Lesson lesson, BuildContext context) {
if (statusId == SessionStates.Revision.getStatus()) {
navigateTo(context, const ExamScreen(lesson: lesson,));
and the exam screen:
class ExamScreen extends StatefulWidget {
final Lesson? lesson;
const ExamScreen({super.key, this.lesson});
@override
State<ExamScreen> createState() => _ExamScreenState();
}
class _ExamScreenState extends State<ExamScreen> with WidgetsBindingObserver {
i get error Invalid constant value
how can i solve it
2
Answers
Remove the const keyword from the ExamScreen constructor like this:
Remove the const keyword from the
navigateTo
You receive this error because lesson isn’t a constant value, so you cannot create a constant instance.