我正在尝试从实时Firebase中获取一些数据。当我执行代码时,出现以下错误:ERROR:flutter / lib / ui / ui_dart_state.cc(157)

时间:2020-06-23 07:17:15

标签: firebase flutter

我正在尝试从实时Firebase中获取一些数据。当我执行代码时,出现以下错误:ERROR:flutter / lib / ui / ui_dart_state.cc(157) 未处理的异常:无效的参数

以下是代码:

      Future<void> fetchAndsetRooms () async{
        print("token is :"+token);
    final url='https://xx-xx-xx.firebaseio.com/rooms.json';
    try{
      final response=await http.get(url,headers: null);
      final extaractedData= json.decode(response.body) as Map<String, dynamic>;
      final List <Room> loadedRooms=[];
      extaractedData.forEach((id,value){

        loadedRooms.add(Room(

          id:id,
          name:value['roomname'],
          isOn:value['roomison'],
          houseid:value['houseid'],
          imageUrl:value['roomimage'],
          

         

        ));
      });
      _items=loadedRooms;
      notifyListeners();

    }catch(error){
      throw (error);

    }

    
    
  }

0 个答案:

没有答案