When running the Amplify Flutter tutorial project after configuring the authentication plugin, I constantly receive the following error:
Error: MissingPluginException(No implementation found for method configure on channel com.amazonaws.amplify/amplify)
at Object.throw_ [as throw] (http://localhost:56261/dart_sdk.js:5331:11)
at MethodChannel._invokeMethod (http://localhost:56261/packages/flutter/src/services/system_channels.dart.lib.js:954:21)
at _invokeMethod.next (<anonymous>)
at http://localhost:56261/dart_sdk.js:39029:33
at _RootZone.runUnary (http://localhost:56261/dart_sdk.js:38886:58)
at _FutureListener.thenAwait.handleValue (http://localhost:56261/dart_sdk.js:33872:29)
at handleValueCallback (http://localhost:56261/dart_sdk.js:34432:49)
at Function._propagateToListeners (http://localhost:56261/dart_sdk.js:34470:17)
at _Future.new.[_completeWithValue] (http://localhost:56261/dart_sdk.js:34312:23)
at async._AsyncCallbackEntry.new.callback (http://localhost:56261/dart_sdk.js:34335:35)
at Object._microtaskLoop (http://localhost:56261/dart_sdk.js:39173:13)
at _startMicrotaskLoop (http://localhost:56261/dart_sdk.js:39179:13)
at http://localhost:56261/dart_sdk.js:34686:9
The code below in main.dart
is copied directly from the Amplify Flutter, but using only the Auth plugin:
class _MyHomePageState extends State<MyHomePage> {
@override
initState() {
super.initState();
_configureAmplify();
}
void _configureAmplify() async {
AmplifyAuthCognito authPlugin = AmplifyAuthCognito();
Amplify.addPlugin(authPlugin);
try {
await Amplify.configure(amplifyconfig); # <--- this is what throws the MissingPluginException
} on AmplifyAlreadyConfiguredException {
print(
"Tried to reconfigure Amplify; this can occur when your app restarts on Android.");
}
}
...
}
pubspec.yaml:
name: <myproject>
description: <description>
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
amplify_flutter: '<1.0.0'
amplify_auth_cognito: '<1.0.0'
cupertino_icons: ^1.0.2
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
Yeah, yeah, I've already searched stackoverflow and github. I've tried everything anyone's suggested including:
flutter clean
then flutter pub get
WidgetsFlutterBinding.ensureInitialized()
in main()
Amplify.configure()
before the Auth plugin is loadedAs of posting, Amplify-Flutter does not support the Web platform, and this error is expected behavior until then. See: https://github.com/aws-amplify/amplify-flutter/issues/234