I need to create a new account everytime to contribute to stack overflow!
This is STUPID!!! PLS!!! Fix your rating system!!! I have 5 and 1/2 years EXP.
Seriously... And I am not allowed to ask or post questions or solutions...
Flutter was returning these errors and nobody has offered the below solution.
Error 1 :
Another exception was thrown: Invalid argument(s)
Error 2 :
Another exception was thrown: Incorrect use of ParentDataWidget
I kept running into this problem because the data for ParentDataWidget was not yet loaded and I was accessing it.
My Solution :
Create a variable
bool isLoaded = false;
IF : isLoaded = false
Do not render the screen.
IF : isLoaded = true
Render the screen
// 1: Set your state
class MyStatefulWidget extends StatefulWidget {
@override
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
}
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
@override
Widget build(BuildContext context) {
return Container(
);
}
}
// 2: Get all your variables (WHEN YOU HAVE YOUR DATA FROM YOUR LAST CALL)
// This will be my final call in my methods for this page
Future getWhateverDataMethod() async {
//Magic happens over here and you get all your data.
// When you have your data you need. Then set the isLoaded var
isLoaded = true;
}
// 3 : Load your page
NOW, when you load your screen your data is ready to be rendered and your error will disappear