I need to send data to another screen using dart I try to make constructor on the other screen(editdata.dart) to get the data from the main screen (readdata.dart) it is stateful widget the problem in:
createState() => EditFire()
EditFire class need to pass parameters but I don’t have the data yet.
editdata.dart:
class EditData extends StatefulWidget {
@override
//Here the Error Occurs//
State<StatefulWidget> createState() => EditFire();
}
class EditFire extends State<EditData> {
EditFire(String ID, String date, String time, String dest, String src){
currentID = ID;
olddate = date;
oldtime = time;
_destinationcontroller.text = dest;
_sourcecontroller.text = src;
}
late String currentID;
final _destinationcontroller = TextEditingController();
final _sourcecontroller = TextEditingController();
late String olddate;
late String oldtime;
}
in readdata.dart:
EditFire("2","17/6/2022","2:25","NewYork","Japan");
2
Answers
First page
Second page in which you want to receive data
To access the data of EditData to EditFire, you don’t required to pass it in constructor. As you can see that EditFire is a state of EditData.
So If you want to get anything in EditFire which is used in EditData, You can used it like widget.abc
And to pass the values to EditData, you need to pass it to the constructor. like,
Hope, this will resolve your issue, still not resolved please comment with the issue.