Я пытаюсь создать приложение для теста в флаттере, используя файл JSON, поэтому сначала я хочу загрузить вопрос в этот виджет, а затем вызвать виджет страницы теста. ЭТОТ КОДЕКС РАБОТАЕТ БОЛЬШЕ ВРЕМЕНИ, ЛУЧШЕ, НО ИНОГДА ЭТО ОШИБКА НЕ ВСЕ ВРЕМЯ Пример кода:
@override
Widget build(BuildContext context) {
// TODO: implement build
// this function is called before the build so that
// the string assettoload is avialable to the DefaultAssetBuilder
setasset();
// and now we return the FutureBuilder to load and decode JSON
return FutureBuilder(
future: DefaultAssetBundle.of(context).loadString(assettoload, cache: true),
builder: (context , snapshot){
List mydata = json.decode( snapshot.data.toString());
if(mydata==null){
return Scaffold(
body: Center(
child: Text(
"Loading",
),
),
);
}
else{
return quizpage(mydata: mydata);//this line giving me the error
}
}
);