configureDataStore method
Future<void>
configureDataStore({
- ModelProviderInterface? modelProvider,
- dynamic errorHandler(
- AmplifyException
- DataStoreConflictHandler? conflictHandler,
- List<
DataStoreSyncExpression> ? syncExpressions, - int? syncInterval,
- int? syncMaxRecords,
- int? syncPageSize,
- AuthModeStrategy authModeStrategy = AuthModeStrategy.defaultStrategy,
override
This method instantiates the native DataStore plugins with plugin configurations. This needs to happen before Amplify.configure() can be called.
Implementation
@override
Future<void> configureDataStore({
ModelProviderInterface? modelProvider,
Function(AmplifyException)? errorHandler,
DataStoreConflictHandler? conflictHandler,
List<DataStoreSyncExpression>? syncExpressions,
int? syncInterval,
int? syncMaxRecords,
int? syncPageSize,
AuthModeStrategy authModeStrategy = AuthModeStrategy.defaultStrategy,
}) async {
_channel.setMethodCallHandler(_methodCallHandler);
try {
this.modelProvider = modelProvider;
this.errorHandler = errorHandler;
this.conflictHandler = conflictHandler;
_syncExpressions = syncExpressions;
return await _channel
.invokeMethod('configureDataStore', <String, dynamic>{
'modelSchemas': modelProvider?.modelSchemas
.map((schema) => schema.toMap())
.toList(),
'customTypeSchemas': modelProvider?.customTypeSchemas
.map((schema) => schema.toMap())
.toList(),
'hasErrorHandler': errorHandler != null,
'hasConflictHandler': conflictHandler != null,
'modelProviderVersion': modelProvider?.version,
'syncExpressions': syncExpressions!
.map((syncExpression) => syncExpression.toMap())
.toList(),
'syncInterval': syncInterval,
'syncMaxRecords': syncMaxRecords,
'syncPageSize': syncPageSize,
'authModeStrategy': authModeStrategy.rawValue,
});
} on PlatformException catch (e) {
if (e.code == "AmplifyAlreadyConfiguredException") {
throw AmplifyAlreadyConfiguredException(
AmplifyExceptionMessages.alreadyConfiguredDefaultMessage,
recoverySuggestion:
AmplifyExceptionMessages.alreadyConfiguredDefaultSuggestion);
} else {
throw _deserializeException(e);
}
}
}