22
loading...
This website collects cookies to deliver better user experience
npm install -g @aws-amplify/cli
amplify configure
amplify configure
would require you to sign into the AWS Console if you have an existing account or create a new one.Enter the access key of the newly created user:
? accessKeyId: # YOUR_ACCESS_KEY_ID
? secretAccessKey: # YOUR_SECRET_ACCESS_KEY
This would update/create the AWS Profile in your local machine
? Profile Name: # (default)
amplify_flutter: ^0.2.0
amplify_auth_cognito: ^0.2.0
amplify_analytics_pinpoint: ^0.2.0
flutter pub get
amplify init
? Enter a name for the environment
`dev`
? Choose your default editor:
`IntelliJ IDEA`
? Choose the type of app that you're building:
'flutter'
? Where do you want to store your configuration file?
./lib/
? Do you want to use an AWS profile?
`Yes`
? Please choose the profile you want to use
`default`
// Amplify Flutter Packages
import 'package:amplify_flutter/amplify.dart';
import 'package:amplify_analytics_pinpoint/amplify_analytics_pinpoint.dart';
import 'package:amplify_auth_cognito/amplify_auth_cognito.dart';
// Generated in previous step
import 'amplifyconfiguration.dart';
class _MyHomePageState extends State<MyHomePage> {
@override
initState() {
super.initState();
_configureAmplify();
}
void _configureAmplify() async {
// Add Pinpoint and Cognito Plugins, or any other plugins you want to use
AmplifyAnalyticsPinpoint analyticsPlugin = AmplifyAnalyticsPinpoint();
AmplifyAuthCognito authPlugin = AmplifyAuthCognito();
await Amplify.addPlugins([authPlugin, analyticsPlugin]);
// Once Plugins are added, configure Amplify
// Note: Amplify can only be configured once.
try {
await Amplify.configure(amplifyconfig);
} on AmplifyAlreadyConfiguredException {
print("Tried to reconfigure Amplify; this can occur when your app restarts on Android.");
}
}
// customize the rest of your Widget below as you wish...
Addplugin
method was called before the Amplify.configuration()