The next step is to install Amplify as a dependency in our project so we can interface with the libraries.
Back in Visual Studio Code, open pubspec.yaml and add the following dependency:
... // dependencies: (line 23)
amplify_core: '<1.0.0'
amplify_flutter: '<1.0.0'
amplify_auth_cognito: '<1.0.0'
amplify_analytics_pinpoint: '<1.0.0'
... // flutter
We’ll start by importing the dependencies into main.dart
... // import 'gps_page.dart'; (line 6)
import 'package:amplify_flutter/amplify.dart';
import 'amplifyconfiguration.dart';
import 'package:amplify_auth_cognito/amplify_auth_cognito.dart';
... // void main() {
.. // } Widget build closing brace (line 92)
void _configureAmplify() async {
AmplifyAuthCognito authPlugin = AmplifyAuthCognito();
Amplify.addPlugins([authPlugin]);
try {
await Amplify.configure(amplifyconfig);
print(' Successfully configured Amplify 🎉');
} catch (e) {
print(e);
print(' Could not configure Amplify ☠️');
}
}
... // super.initState(); (line 25)
_configureAmplify();
... // _authService.showLogin();