Open mobiletoly opened 2 months ago
Hi @mobiletoly, thanks for taking the time to submit this issue. We will investigate this isolate configuration behavior and update you as we can.
Hi @mobiletoly, I wanted to note that we do not officially support Amplify in multiple isolates, but I was able to reproduce the issue you mentioned. We should not be throwing the type 'Null' is not a subtype of type 'Map<dynamic, dynamic>' in type cast
exception. There is already logic in place to silently log AmplifyAlreadyConfiguredExceptions, but it is not being hit due to additional exception handling downstream returning an unexpected exception that we do not handle properly. I'm marking this as a bug and we will get back to you when we have a fix.
Description
This issue is related to amplify_datastore.dart file.
in method:
this code:
so this line
Map<String, String>.from(e.details as Map)
throws error (type 'Null' is not a subtype of type 'Map<dynamic, dynamic>' in type cast) because e.details can be null.in my case PlatformException contains this information
(as you can see
e.details
field isnull
there)I would suggest to ignore this "User-Agent was already configured successfully" error, because for example in my case I'm initializing Amplify from the main UI thread, but there is also a possibility that some separate isolate is launched and it tries to initialize Amplify as well (have to deal with background services). Since there is no way to detect from one isolate that Amplify was already configured in another isolate - I end up having this issue.
Categories
Steps to Reproduce
Screenshots
No response
Platforms
Flutter Version
3.24.0-0.2.pre
Amplify Flutter Version
3.2.0
Deployment Method
Amplify CLI
Schema
No response