configurePlatform method
Configures the platform-specific implementation of Amplify using the
registered config
.
Implementation
@override
Future<void> configurePlatform(String config) async {
try {
await _channel.invokeMethod<void>(
'configure',
<String, Object>{
'version': version,
'configuration': config,
},
);
await Future.wait(
Analytics.plugins.map((plugin) => plugin.onConfigure()),
);
} on PlatformException catch (e) {
if (e.code == 'AnalyticsException') {
throw AnalyticsException.fromMap(Map<String, String>.from(e.details));
} else if (e.code == 'AmplifyException') {
throw AmplifyException.fromMap(Map<String, String>.from(e.details));
} else if (e.code == 'AmplifyAlreadyConfiguredException') {
return;
} else {
// This shouldn't happen. All exceptions coming from platform for
// amplify_flutter should have a known code. Throw an unknown error.
throw AmplifyException(AmplifyExceptionMessages.missingExceptionMessage,
recoverySuggestion:
AmplifyExceptionMessages.missingRecoverySuggestion,
underlyingException: e.toString());
}
}
}