NoSuchMethodError: Метод '[]' был вызван при нулевом пробном вызове: [] ("a") - PullRequest
0 голосов
/ 04 мая 2020

Я пытаюсь создать приложение для теста в флаттере, используя файл 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
    }
  }
);   
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...