-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I encounter a Late Field initialization error when using Socket-IO #56
Comments
You may probably mis initiate the flutter feathers js client. I dont realy understand your code:
@override
void initState() {
isLoading = true;
fetchActivities();
super.initState();
}
More informations can help because from now, I cannot reproduce the given issue
|
The code above call this this code below which is from activities_provider.dart class ActivityProvider with ChangeNotifier{
//this is the method on init state in main.dart that is being called by fetchActivities
Future<APIResponse<List<ActivityI>>> getActivities() async {
List<ActivityI>? messages;
String? error;
try {
Map<String, dynamic> response = await socketIOClient.scketio.find(
serviceName: "activities",
query: {},
);
logger.i(response.toString());
messages = List<Map<String, dynamic>>.from(response["data"])
.map((map) => ActivityI.fromMap(map))
.toList();
} on FeatherJsError catch (e) {
logger.e("FeatherJsError error ::: Type => ${e.type} ::: Message => ${e.message}");
error = "Unexpected FeatherJsError occurred, please retry!";
} catch (e) {
logger.e("Unexpected error ::: ${e.toString()}");
error = "Unexpected error occurred, please retry!";
}
return APIResponse(errorMessage: error, data: messages);
}
}
//I am accessing getActivities() method using provider
fetchActivities() async {
context.read<ActivityProvider>().getActivities().then(
(response) {
isLoading = false;
if (response.errorMessage == null) {
setState(() {
activities = response.data!;
});
} else {
setState(() {
error = response.errorMessage;
});
}
},
);
} |
The logged error looks like this Future<APIResponse<List>> getActivities() async { This below is my socket-io initialization in main.dart FlutterFeathersjs socketIOClient = FlutterFeathersjs(); void main() { socket.Socket io = socket.io(API.baseUrl, <String, dynamic>{ |
Can you please, format correctly your code (snippets) in your previous comments. It's hard to look in up to your code. Just use |
|
This is the error I am encountering on calling find query on feathers Js server from flutter app both running on local machine
I/flutter ( 7821): │ ⛔ Unexpected error ::: LateInitializationError: Field 'scketio' has not been initialized.
The error comes from this code below;
This code from my provider;
Currently running debug app on memu emulator
The text was updated successfully, but these errors were encountered: