In my flutter project, I'm using the AWS Amplify storage plugin to upload files.
For that, I have added below dependencies
dependencies:
flutter:
sdk: flutter
amplify_storage_s3: <1.0.0
amplify_flutter: <1.0.0
amplify_auth_cognito: <1.0.0
And in main.dart file added one function to configure Amplify
void configureAmplify() async {
// First add plugins (Amplify native requirements)
AmplifyStorageS3 storage = new AmplifyStorageS3();
AmplifyAuthCognito auth = new AmplifyAuthCognito();
Amplify.addPlugins([auth, storage]);
// Configure
await Amplify.configure(amplifyconfig('cashify-bazaar'));
}
I call this configure
method on button click and it works fine.
But the problem is that once I called the configure
method and put an application in the background by the back press, and then resume from recent apps on android device, It throws an error
W/GeneratedPluginsRegister(21233): Tried to automatically register plugins with FlutterEngine (io.flutter.embedding.engine.FlutterEngine@99d4e49) but could not find and invoke the GeneratedPluginRegistrant.
and does not call onAttachedToEngine of flutter plugin, and because of this no plugin channel is registered which cause an error
Unhandled Exception: MissingPluginException( No implementation found for method <method_name> on channel <channel_name>
why the onAttachedToEngine
method of FlutterPlugin is not called, once I have called Amplify.configure
?
This is the same issue as https://github.com/aws-amplify/amplify-flutter/issues/99 which is fixed by https://github.com/aws-amplify/amplify-flutter/pull/345