How to handle this kind of error message? Why is it coming? Is that issue? I called below method every 10 seconds.
checkQuick(String url, String token) async {
result =
(await HelperDatabase1().displayGetUserPreference()).elementAt(0)?.data;
final response = await http.get(
'$url/nativeapi/v1.0/User/GetUserPreference',
headers: {'Authorization': 'Bearer $token'},
);
final jsonResponse = json.decode(response.body);
GetUserPreference model = GetUserPreference.fromJson(jsonResponse);
var data = GetUserPreference(data: model.data);
//result = data.data;
if (result != data.data) {
// await HelperDatabase1().updateGetUserPreference(1, data.data);
print('inside');
await HelperDatabase1().deleteGetUserPreference();
await HelperDatabase1().storeGetUserPreference(url, token);
}
}
below error message coming some times.
E/flutter ( 7148): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: FormatException: Unexpected end of input (at character 1)
E/flutter ( 7148):
E/flutter ( 7148): ^
E/flutter ( 7148):
E/flutter ( 7148): #0 _ChunkedJsonParser.fail (dart:convert-patch/convert_patch.dart:1392:5) E/flutter ( 7148): #1
_ChunkedJsonParser.close (dart:convert-patch/convert_patch.dart:510:7) E/flutter ( 7148): #2 _parseJson (dart:convert-patch/convert_patch.dart:30:10) E/flutter ( 7148): #3
JsonDecoder.convert (dart:convert/json.dart:493:36) E/flutter ( 7148):4 JsonCodec.decode (dart:convert/json.dart:151:41) E/flutter ( 7148): #5 _ListPageState.checkQuick
(package:reborn_next_job02/ui/AssetRegisters.dart:153:31) E/flutter ( 7148): E/flutter ( 7148): #6
_ListPageState.initState. (package:reborn_next_job02/ui/AssetRegisters.dart:47:7) E/flutter ( 7148): #7 _rootRunUnary (dart:async/zone.dart:1132:38) E/flutter ( 7148): #8 _CustomZone.runUnary (dart:async/zone.dart:1029:19) E/flutter ( 7148): #9 _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7) E/flutter ( 7148): #10
_CustomZone.bindUnaryCallbackGuarded. (dart:async/zone.dart:968:26) E/flutter ( 7148): #11 _rootRunUnary (dart:async/zone.dart:1136:13) E/flutter ( 7148): #12
_CustomZone.runUnary (dart:async/zone.dart:1029:19) E/flutter ( 7148): #13 _CustomZone.bindUnaryCallback. (dart:async/zone.dart:952:26) E/flutter ( 7148): #14
_Timer._runTimers (dart:isolate-patch/timer_impl.dart:382:19) E/flutter ( 7148): #15 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:416:5) E/flutter ( 7148): #16
_RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:171:12)