Flutter web Http GET throws unwaited function - flutter

I'm running an HTTP get using flutter for the web and after connecting it stops running and directs me to the browser_client.dart file highlighting this function
unawaited(xhr.onLoad.first.then((_) {
var body = (xhr.response as ByteBuffer).asUint8List();
completer.complete(StreamedResponse(
ByteStream.fromBytes(body), xhr.status!,
contentLength: body.length,
request: request,
headers: xhr.responseHeaders,
reasonPhrase: xhr.statusText));
}));
then afterward shows this on the debug console
Error: error
at Object.throw_ [as throw] (http://localhost:53840/dart_sdk.js:5061:11)
at searchListing (http://localhost:53840/packages/maimo/app/data/services/api.dart.lib.js:33:19)
at searchListing.next (<anonymous>)
at http://localhost:53840/dart_sdk.js:38640:33
at _RootZone.runUnary (http://localhost:53840/dart_sdk.js:38511:59)
at _FutureListener.thenAwait.handleValue (http://localhost:53840/dart_sdk.js:33713:29)
at handleValueCallback (http://localhost:53840/dart_sdk.js:34265:49)

Related

flutter web throw Error Assertion failed: "call initWeb() before initSession"

I got this error on Google Console after I released my flutter web app, and some of my methods don't work as well as they do in the Android version.
errors.dart:251 Uncaught (in promise) Error: Assertion failed: "call initWeb() before initSession"
at Object.throw_ [as throw] (errors.dart:251:49)
at flutter_branch_sdk_web.FlutterBranchSdk.__.initSession (flutter_branch_sdk_web.dart:169:7)
at FlutterBranchSdk.initSession (flutter_branch_sdk_plugin.dart:49:22)
at order_screen._OrderScreenState.new.listenDynamicLinks (order_screen.dart:63:57)
at listenDynamicLinks.next (<anonymous>)
at runBody (async_patch.dart:84:54)
at Object._async [as async] (async_patch.dart:123:5)
at order_screen._OrderScreenState.new.listenDynamicLinks (order_screen.dart:62:34)
at order_screen._OrderScreenState.new.initState (order_screen.dart:40:7)
at [_firstBuild] (framework.dart:4728:57)
at framework.StatefulElement.new.mount (framework.dart:4561:5)
at framework.SingleChildRenderObjectElement.new.inflateWidget (framework.dart:3631:13)
at framework.SingleChildRenderObjectElement.new.updateChild (framework.dart:3383:18)
at framework.SingleChildRenderObjectElement.new.mount (framework.dart:6123:14)
at framework.StatelessElement.new.inflateWidget (framework.dart:3631:13)
at framework.StatelessElement.new.updateChild (framework.dart:3383:18)
at framework.StatelessElement.new.performRebuild (framework.dart:4613:16)
at framework.StatelessElement.new.rebuild (framework.dart:4311:5)
at [_firstBuild] (framework.dart:4566:5)
at framework.StatelessElement.new.mount (framework.dart:4561:5)

How fix Error: Unexpected null value flutter web?

how solve this .
in moblie phone it works prefectly but when i build in web i have this error
Some helps please !
An Observatory debugger and profiler on Chrome is available at: http://127.0.0.1:60879/cssBXX81wfI=
Flutter Web Bootstrap: Auto
Token: null
====> API Call: /api/v1/config
Header: {Content-Type: application/json; charset=UTF-8, zoneId: null, X-localization: fr, Authorization: Bearer null}
Error: Unexpected null value.
at Object.throw_ [as throw] (http://localhost:60787/dart_sdk.js:5405:11)
at Object.nullCheck (http://localhost:60787/dart_sdk.js:5732:30)
at [_configureOverlay] (http://localhost:60787/packages/get/get_navigation/src/snackbar/snackbar_controller.dart.lib.js:3027:53)
at [_show] (http://localhost:60787/packages/get/get_navigation/src/snackbar/snackbar_controller.dart.lib.js:3190:30)
at Object._checkAndCall (http://localhost:60787/dart_sdk.js:5609:16)
at Object.callMethod (http://localhost:60787/dart_sdk.js:5652:17)
at Object.dsend (http://localhost:60787/dart_sdk.js:5655:17)
at get_queue.GetQueue.new._check$ (http://localhost:60787/packages/get/get_utils/src/queue/get_queue.dart.lib.js:91:65)
at _check$.next (<anonymous>)
at runBody (http://localhost:60787/dart_sdk.js:43083:34)
at Object._async [as async] (http://localhost:60787/dart_sdk.js:43114:7)
at [_check] (http://localhost:60787/packages/get/get_utils/src/queue/get_queue.dart.lib.js:86:20)
at get_queue.GetQueue.new.add (http://localhost:60787/packages/get/get_utils/src/queue/get_queue.dart.lib.js:79:19)
at snackbar_controller._SnackBarQueue.new._addJob (http://localhost:60787/packages/get/get_navigation/src/snackbar/snackbar_controller.dart.lib.js:3325:40)
at _addJob.next (<anonymous>)
at runBody (http://localhost:60787/dart_sdk.js:43083:34)
at Object._async [as async] (http://localhost:60787/dart_sdk.js:43114:7)
at [_addJob] (http://localhost:60787/packages/get/get_navigation/src/snackbar/snackbar_controller.dart.lib.js:3323:20)
at snackbar_controller.SnackbarController.new.show (http://localhost:60787/packages/get/get_navigation/src/snackbar/snackbar_controller.dart.lib.js:2996:76)
at Object.ExtensionSnackbar$124showSnackbar [as ExtensionSnackbar|showSnackbar]
(http://localhost:60787/packages/get/get_navigation/src/snackbar/snackbar_controller.dart.lib.js:12329:16)
at Object.showCustomSnackBar (http://localhost:60787/packages/efood_multivendor/view/base/custom_snackbar.dart.lib.js:38:61)
at ApiChecker.checkApi (http://localhost:60787/packages/efood_multivendor/data/repository/auth_repo.dart.lib.js:38045:25)
at splash_controller.SplashController.new.getConfigData (http://localhost:60787/packages/efood_multivendor/data/repository/auth_repo.dart.lib.js:38091:34)
at getConfigData.next (<anonymous>)
at http://localhost:60787/dart_sdk.js:43063:33
at _RootZone.runUnary (http://localhost:60787/dart_sdk.js:42919:58)
at _FutureListener.thenAwait.handleValue (http://localhost:60787/dart_sdk.js:37493:29)
at handleValueCallback (http://localhost:60787/dart_sdk.js:38088:49)
at _Future._propagateToListeners (http://localhost:60787/dart_sdk.js:38126:17)
at [_completeError] (http://localhost:60787/dart_sdk.js:37963:23)
at http://localhost:60787/dart_sdk.js:38200:38
at _RootZone.runBinary (http://localhost:60787/dart_sdk.js:42924:58)
at _FutureListener.then.handleError (http://localhost:60787/dart_sdk.js:37506:33)
at handleError (http://localhost:60787/dart_sdk.js:38104:51)
at _Future._propagateToListeners (http://localhost:60787/dart_sdk.js:38130:17)
at [_completeError] (http://localhost:60787/dart_sdk.js:37963:23)
at async._AsyncCallbackEntry.new.callback (http://localhost:60787/dart_sdk.js:38015:31)
at Object._microtaskLoop (http://localhost:60787/dart_sdk.js:43223:13)
at _startMicrotaskLoop (http://localhost:60787/dart_sdk.js:43229:13)
at http://localhost:60787/dart_sdk.js:38359:9

Error during access Text Input (TextFormField) =>Bad state: Unsupported method call on the flutter/textinput channel: TextInput.setCaretRect

I'm using Chrome Browser as my Emulator to Run my Flutter Apps.
During accessing any TextInput (TextFormField) there's error like this:
Error: Bad state: Unsupported method call on the flutter/textinput channel: TextInput.setCaretRect
at Object.throw_ [as throw] (http://localhost:53880/dart_sdk.js:5033:11)
at _engine.TextEditingChannel.new.handleTextInput (http://localhost:53880/dart_sdk.js:170190:21)
at _engine.EnginePlatformDispatcher.__.[_sendPlatformMessage] (http://localhost:53880/dart_sdk.js:156913:39)
at _engine.EnginePlatformDispatcher.__.sendPlatformMessage (http://localhost:53880/dart_sdk.js:156780:33)
at _DefaultBinaryMessenger.[_sendPlatformMessage] (http://localhost:53880/packages/flutter/src/services/system_channels.dart.lib.js:2110:38)
at _DefaultBinaryMessenger.send (http://localhost:53880/packages/flutter/src/services/system_channels.dart.lib.js:2152:40)
at OptionalMethodChannel._invokeMethod (http://localhost:53880/packages/flutter/src/services/system_channels.dart.lib.js:938:50)
at _invokeMethod.next (<anonymous>)
at runBody (http://localhost:53880/dart_sdk.js:37376:34)
at Object._async [as async] (http://localhost:53880/dart_sdk.js:37407:7)
at OptionalMethodChannel.[_invokeMethod] (http://localhost:53880/packages/flutter/src/services/system_channels.dart.lib.js:936:20)
at OptionalMethodChannel.[_invokeMethod] (http://localhost:53880/packages/flutter/src/services/system_channels.dart.lib.js:1059:34)
at OptionalMethodChannel.invokeMethod (http://localhost:53880/packages/flutter/src/services/system_channels.dart.lib.js:1039:36)
at invokeMethod.next (<anonymous>)
at runBody (http://localhost:53880/dart_sdk.js:37376:34)
at Object._async [as async] (http://localhost:53880/dart_sdk.js:37407:7)
at OptionalMethodChannel.invokeMethod (http://localhost:53880/packages/flutter/src/services/system_channels.dart.lib.js:1038:20)
at text_input.TextInput.__.[_setCaretRect] (http://localhost:53880/packages/flutter/src/services/text_input.dart.lib.js:1324:22)
at text_input.TextInputConnection.__.setCaretRect (http://localhost:53880/packages/flutter/src/services/text_input.dart.lib.js:1089:52)
at editable_text.EditableTextState.new.[_updateCaretRectIfNeeded] (http://localhost:53880/packages/flutter/src/widgets/widget_span.dart.lib.js:43665:56)
at editable_text.EditableTextState.new.[_openInputConnection] (http://localhost:53880/packages/flutter/src/widgets/widget_span.dart.lib.js:43386:41)
at editable_text.EditableTextState.new.[_openOrCloseInputConnectionIfNeeded] (http://localhost:53880/packages/flutter/src/widgets/widget_span.dart.lib.js:43410:37)
at editable_text.EditableTextState.new.[_handleFocusChanged] (http://localhost:53880/packages/flutter/src/widgets/widget_span.dart.lib.js:43618:50)
at focus_manager.FocusNode.new.notifyListeners (http://localhost:53880/packages/flutter/src/foundation/change_notifier.dart.lib.js:106:41)
at focus_manager.FocusNode.new.[_notify] (http://localhost:53880/packages/flutter/src/widgets/widget_span.dart.lib.js:46499:12)
at focus_manager.FocusManager.new.[_applyFocusChange] (http://localhost:53880/packages/flutter/src/widgets/widget_span.dart.lib.js:47229:26)
at Object._microtaskLoop (http://localhost:53880/dart_sdk.js:37480:13)
at _startMicrotaskLoop (http://localhost:53880/dart_sdk.js:37486:13)
at http://localhost:53880/dart_sdk.js:33257:9
Any solution for this matter ?

Uncaught Exception with try catch in Dart

I'm building a flutter app that uses SignalR. For this purpose I'm using signalr_core library. So far things work well when the server is up and running and I provide a valid authentication token, but when I provided a wrong token and start the connection I get the following error:
Error: Expected a value of type 'Error', but got one of type 'WebSocketChannelException'
at Object.throw_ [as throw] (http://localhost:64659/dart_sdk.js:4348:11)
at Object.castError (http://localhost:64659/dart_sdk.js:4319:15)
at Object.cast [as as] (http://localhost:64659/dart_sdk.js:4635:17)
at dart.LegacyType.new.as (http://localhost:64659/dart_sdk.js:6212:60)
at http://localhost:64659/packages/signalr_core/src/json_hub_protocol.dart.lib.js:2129:44
at _RootZone.runUnaryGuarded (http://localhost:64659/dart_sdk.js:37736:11)
at sendError (http://localhost:64659/dart_sdk.js:31344:26)
at _ControllerSubscription.new.[_sendError] (http://localhost:64659/dart_sdk.js:31359:11)
at _ControllerSubscription.new.[_addError] (http://localhost:64659/dart_sdk.js:31282:27)
at _SyncStreamController.new.[_sendError] (http://localhost:64659/dart_sdk.js:34230:39)
at _SyncStreamController.new.[_addError] (http://localhost:64659/dart_sdk.js:34042:27)
at _SyncStreamController.new.addError (http://localhost:64659/dart_sdk.js:34012:24)
at _RootZone.runBinaryGuarded (http://localhost:64659/dart_sdk.js:37753:11)
at sendError (http://localhost:64659/dart_sdk.js:31342:26)
at _ControllerSubscription.new.[_sendError] (http://localhost:64659/dart_sdk.js:31359:11)
at _ControllerSubscription.new.[_addError] (http://localhost:64659/dart_sdk.js:31282:27)
at _SyncStreamController.new.[_sendError] (http://localhost:64659/dart_sdk.js:34230:39)
at _SyncStreamController.new.[_addError] (http://localhost:64659/dart_sdk.js:34042:27)
at _SyncStreamController.new.addError (http://localhost:64659/dart_sdk.js:34012:24)
at _StreamSinkWrapper.new.addError (http://localhost:64659/dart_sdk.js:34339:24)
at _GuaranteeSink.new.[_addError] (http://localhost:64659/packages/stream_channel/src/stream_channel_controller.dart.lib.js:1223:26)
at _GuaranteeSink.new.addError (http://localhost:64659/packages/stream_channel/src/stream_channel_controller.dart.lib.js:1218:24)
at http://localhost:64659/packages/web_socket_channel/html.dart.lib.js:199:36
at _RootZone.runUnary (http://localhost:64659/dart_sdk.js:37810:58)
at _FutureListener.then.handleValue (http://localhost:64659/dart_sdk.js:32771:29)
at handleValueCallback (http://localhost:64659/dart_sdk.js:33319:49)
at Function._propagateToListeners (http://localhost:64659/dart_sdk.js:33357:17)
at _Future.new.[_complete] (http://localhost:64659/dart_sdk.js:33190:25)
at Object._cancelAndValue (http://localhost:64659/dart_sdk.js:38220:24)
at http://localhost:64659/dart_sdk.js:18845:17
at Object._checkAndCall (http://localhost:64659/dart_sdk.js:4558:16)
at Object.dcall (http://localhost:64659/dart_sdk.js:4563:17)
at WebSocket.<anonymous> (http://localhost:64659/dart_sdk.js:104962:23)
Although I did catch the exception in my code.
Here is the connection initialization code:
_connection = HubConnectionBuilder()
.withAutomaticReconnect() //
.withUrl(
_URL,
HttpConnectionOptions(
logging: (level, message) => print(message),
skipNegotiation: true,
transport: HttpTransportType.webSockets,
accessTokenFactory: () {
return Future.value('wrongToken');
},
)) //
.build(); //
As for connection start code:
void start() async {
try {
_streamingStateController.add(StreamingInfo(StreamingState.Starting));
await _connection.start();
_listenToGPSChange();
_streamingStateController.add(StreamingInfo(StreamingState.Started));
} on Exception catch (exception) {
_handleError('Oops. Unable to connect to the server.');
} on Error catch (error) {
_handleError('Oops. Unable to connect to the server.');
}
}
Please not that I get the same error when the connection succeeds (in case of valid parameters) but afterwards a shut down my server and send a message.
So the question is, how do I catch this type of errors?

Error: Unsupported operation: Attempted to change a read-only message (EntityUiPb) in dart by using flutter

I am just making an object of Google protocol buffer which I named OrganisasationUiPb and organisationUipb contain another protocol buffer message EntityUipb
my code
OrganisationUiPb uipb = new OrganisationUiPb();
uipb.dbInfo.id = "add";
uipb.name.canonicalName = "add";
print(uipb);
OrganisationUiPb
message OrganisationUiPb {
EntityUiPb dbInfo = 1;
NameUiPb name = 2;
TimeUiPb time = 3;
string orgCode = 4;
}
EntityUipb
message EntityUiPb {
string id = 1;
int32 version = 2;
StatusEnum lifeTime = 3;
LocaleUiPb locale = 4;
}
when I make an object of OrganisationUipb and start assign values I got this error in cosole
Error: Unsupported operation: Attempted to change a read-only message (EntityUiPb)
at Object.throw_ [as throw] (http://localhost:49885/dart_sdk.js:4463:11)
at Object.defaultFrozenMessageModificationHandler (http://localhost:49885/packages/protobuf/src/protobuf/type_registry.dart.lib.js:5888:15)
at protobuf._FieldSet.new.[_ensureWritable] (http://localhost:49885/packages/protobuf/src/protobuf/type_registry.dart.lib.js:2551:50)
at protobuf._FieldSet.new.[_validateField] (http://localhost:49885/packages/protobuf/src/protobuf/type_registry.dart.lib.js:3007:28)
at protobuf._FieldSet.new.[_$check] (http://localhost:49885/packages/protobuf/src/protobuf/type_registry.dart.lib.js:2800:27)
at protobuf._FieldSet.new.[_$set] (http://localhost:49885/packages/protobuf/src/protobuf/type_registry.dart.lib.js:2783:35)
at entityUiPb$46pb.EntityUiPb.__.$_setString (http://localhost:49885/packages/protobuf/src/protobuf/type_registry.dart.lib.js:3956:36)
at entityUiPb$46pb.EntityUiPb.__.set id [as id] (http://localhost:49885/packages/StudenceWebOrMObileUI/Protobuff/entityUiPb.pb.dart.lib.js:100:12)
at Object.main$ [as main] (http://localhost:49885/packages/StudenceWebOrMObileUI/main.dart.lib.js:491:20)
at main$ (http://localhost:49885/web_entrypoint.dart.lib.js:14:12)
at main$.next (<anonymous>)
at http://localhost:49885/dart_sdk.js:37175:33
at _RootZone.runUnary (http://localhost:49885/dart_sdk.js:37029:58)
at _FutureListener.thenAwait.handleValue (http://localhost:49885/dart_sdk.js:32116:29)
at handleValueCallback (http://localhost:49885/dart_sdk.js:32663:49)
at Function._propagateToListeners (http://localhost:49885/dart_sdk.js:32701:17)
at async._AsyncCallbackEntry.new.callback (http://localhost:49885/dart_sdk.js:32427:27)
at Object._microtaskLoop (http://localhost:49885/dart_sdk.js:37290:13)
at _startMicrotaskLoop (http://localhost:49885/dart_sdk.js:37296:13)
at http://localhost:49885/dart_sdk.js:32918:9
and on UI I got
errors.dart:165 Uncaught (in promise) Error: Unsupported operation: Attempted to change a read-only message (EntityUiPb)
at Object.throw_ [as throw] (errors.dart:214)
at Object.defaultFrozenMessageModificationHandler (field_set.dart:15)
at protobuf._FieldSet.new.[_ensureWritable] (field_set.dart:157)
at protobuf._FieldSet.new.[_validateField] (field_set.dart:794)
at protobuf._FieldSet.new.[_$check] (field_set.dart:512)
at protobuf._FieldSet.new.[_$set] (field_set.dart:493)
at entityUiPb$46pb.EntityUiPb.__.$_setString (generated_message.dart:456)
at entityUiPb$46pb.EntityUiPb.__.set id [as id] (entityUiPb.pb.dart:44)
at Object.main$ [as main] (main.dart:21)
at main$ (web_entrypoint.dart:9)
at main$.next (<anonymous>)
at async_patch.dart:45
at _RootZone.runUnary (zone.dart:1450)
at _FutureListener.thenAwait.handleValue (future_impl.dart:143)
at handleValueCallback (future_impl.dart:696)
at Function._propagateToListeners (future_impl.dart:725)
at async._AsyncCallbackEntry.new.callback (future_impl.dart:393)
at Object._microtaskLoop (schedule_microtask.dart:41)
at _startMicrotaskLoop (schedule_microtask.dart:50)
at async_patch.dart:166
please help me and provide solution of this so I can counter this problem
The reason for this is that the Dart protobuf implementation creates an immutable default value for the child objects of OrganisationUiPb so uipb.dbInfo is read-only from creation.
The workaround is to create the child object first, something like this:
EntityUiPb dbInfoTemp= new EntityUiPb();
dbInfoTemp.id = "add";
OrganisationUiPb uipb = new OrganisationUiPb()..dbInfo = dbInfoTemp;
...
print(uipb);
Mode discussion on the issue here:
https://github.com/dart-lang/protobuf/issues/305