Здравствуйте, я пытаюсь получить информацию от JSON, код:
GamesList gamesList;
final String auth = 'Basic'+
base64Encode(utf8.encode('***:*******'));
void fetchGames() {
http.get('000',
headers: {'authorizationHeader': auth}
)
.then((response) {
if (response.statusCode == 200) {
final jsonResponse = json.decode(response.body);
gamesList = GamesList.fromJson(jsonResponse);
} else {
print("Error");
}
});
}
Я получаю это сообщение:
I/flutter (27006): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (27006): The following NoSuchMethodError was thrown building Home(dirty, state: _HomeState#76cf4):
I/flutter (27006): The getter 'games' was called on null.
I/flutter (27006): Receiver: null
I/flutter (27006): Tried calling: games
and this is the stack:
I/flutter (27006): When the exception was thrown, this was the stack:
I/flutter (27006): #0 Object.noSuchMethod (dart:core/runtime/libobject_patch.dart:48:5)
I/flutter (27006): #1 listItem (package:spl/Globals/globals.dart:45:21)
I/flutter (27006): #2 _HomeState.build (package:spl/Pages/home.page.dart:146:13)
I/flutter (27006): #3 StatefulElement.build (package:flutter/src/widgets/framework.dart:3742:27)
I/flutter (27006): #4 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3654:15)
I/flutter (27006): #5 Element.rebuild (package:flutter/src/widgets/framework.dart:3507:5)
I/flutter (27006): #6 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2255:33)
I/flutter (27006): #7 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:653:20)
I/flutter (27006): #8 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:208:5)
I/flutter (27006): #9 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
I/flutter (27006): #10 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930:9)
I/flutter (27006): #11 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:751:7)
I/flutter (27006): #13 _Timer._runTimers (dart:isolate/runtime/libtimer_impl.dart:382:19)
I/flutter (27006): #14 _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:416:5)
I/flutter (27006): #15 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)
I/flutter (27006): (elided one frame from package dart:async)
I/flutter (27006): ════════════════════════════════════════════════════════════════════════════════════════════════════
Reloaded 6 of 525 libraries in 788ms.