I am working on a similar project. The problem I faced was the the Field device@.... was not initiated , I used "late" for variable initialization and it does not get initiated .
there are 2 solutions
- use ? instead of late but chances are your variable will show null value
2 initialize the variable by assigning it some value of same type like this
late String name;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Text(name)
//runtime error:
//LateInitializationError: Field 'name' has not been initialized.
);
}
becomes:
late String name;
@override
void initState() {
name = "Flutter Campus";// the type of value you assign should be same like in this case string
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Text(name)
);
}