Skip to content

Commit 6e7a4f8

Browse files
authored
chore(main): readme update (#5786)
* updated readme to gen2 instructions * updated formatting * update formatting * further formatting * updated to ask users to use Gen 2
1 parent 0e2d03e commit 6e7a4f8

File tree

1 file changed

+49
-90
lines changed

1 file changed

+49
-90
lines changed

README.md

Lines changed: 49 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ We are iterating and looking for feedback and collaboration, so please [**let us
1212

1313
⚠️ **Amplify Flutter v1 is now in Maintenance Mode until April 30th, 2025. This means that we will continue to include updates to ensure compatibility with backend services and security. No new features will be introduced in v1.**
1414

15-
Please use the latest version (v2) of Amplify Flutter. If you are currently using v1, follow [these instructions](https://docs.amplify.aws/lib/project-setup/upgrade-guide/q/platform/flutter/) to upgrade to v2.
15+
Please use the latest version (Gen 2) of Amplify Flutter. If you are currently using v1, follow [these instructions](https://docs.amplify.aws/lib/project-setup/upgrade-guide/q/platform/flutter/) to upgrade to v2.
1616

1717
## Supported Amplify Libraries
1818

@@ -56,9 +56,8 @@ We follow [semantic versioning for updating our dependencies](https://semver.org
5656

5757
## Documentation
5858

59-
- [Getting Started with Amplify Flutter](https://docs.amplify.aws/start/q/integration/flutter)
59+
- [Getting Started with Amplify Flutter](https://docs.amplify.aws/flutter/start/quickstart/)
6060
- [Amplify Framework](https://docs.amplify.aws/)
61-
- [Install the Amplify CLI](https://docs.amplify.aws/lib/project-setup/prereq/q/platform/flutter#install-and-configure-the-amplify-cli)
6261
- [Contributing to Amplify Flutter](CONTRIBUTING.md)
6362

6463
## Flutter Development Guide
@@ -68,116 +67,76 @@ Amplify for Flutter is an open-source project and welcomes contributions from th
6867
#### Prerequisites
6968

7069
- [Flutter](https://flutter.dev/docs/get-started/install)
71-
- [Amplify CLI](https://docs.amplify.aws/lib/project-setup/prereq/q/platform/flutter#option-1-watch-the-video-guide)
70+
- Node.js v18.17 or later
71+
- npm v9 or later
7272

73-
#### Getting Started Amplify Flutter
73+
#### Getting Started With Amplify Flutter
7474

7575
1. Open your Flutter project. If you do not have an active Flutter project, you can create one after installing the [Flutter development tooling](https://flutter.dev/docs/get-started/install) and running `flutter create <project-name>` in your terminal.
7676

77-
2. Using the Amplify CLI, run `amplify init` from the root of your project:
77+
2. Run the following to create an amplify project:
7878

79-
If you have not configured the Amplify CLI, check out our documentation at [Amplify CLI Installation](https://docs.amplify.aws/lib/project-setup/prereq/q/platform/flutter#install-and-configure-the-amplify-cli).
79+
`npm create amplify@latest -y`
8080

81-
```bash
82-
==> amplify init
83-
Note: It is recommended to run this command from the root of your app directory
84-
? Enter a name for the project <project-name>
85-
The following configuration will be applied:
81+
4. To use the Authenticator, you need to add the following dependencies to your project:
8682

87-
Project information
88-
| Name: <project-name>
89-
| Environment: dev
90-
| Default editor: Visual Studio Code
91-
| App type: flutter
92-
| Configuration file location: ./lib/
83+
```yaml
84+
dependencies:
85+
amplify_auth_cognito: ^2.0.0
86+
amplify_authenticator: ^2.0.0
87+
amplify_flutter: ^2.0.0
88+
flutter:
89+
sdk: flutter
90+
```
9391
94-
? Initialize the project with the above configuration? Yes
95-
Using default provider awscloudformation
96-
? Select the authentication method you want to use: AWS profile
92+
5. run `flutter pub get`
9793

98-
For more information on AWS Profiles, see:
99-
https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html
100-
101-
? Please choose the profile you want to use default
102-
```
103-
104-
4. Add Amplify categories (choose defaults for this example):
105-
106-
```bash
107-
$ amplify add auth # Choose default configuration after entering this command in your terminal.
108-
```
109-
110-
5. Push changes to the cloud to provision the backend resources:
111-
112-
```bash
113-
$ amplify push
114-
```
115-
116-
6. In your pubspec.yaml file, add the following to `dependencies`:
117-
118-
> Note: Do not include dependencies in your `pubspec` file that you are not using in your app. This can cause a configuration error in the underlying SDK.
119-
120-
```yaml
121-
dependencies:
122-
amplify_auth_cognito: ^2.0.0
123-
amplify_authenticator: ^2.0.0
124-
amplify_flutter: ^2.0.0
125-
flutter:
126-
sdk: flutter
127-
```
128-
129-
7. From the terminal run
130-
131-
```bash
132-
flutter pub get
133-
```
134-
135-
8. In your main.dart file, add:
94+
6. Update your main.dart file to the following:
13695

13796
```dart
13897
import 'package:amplify_auth_cognito/amplify_auth_cognito.dart';
13998
import 'package:amplify_authenticator/amplify_authenticator.dart';
14099
import 'package:amplify_flutter/amplify_flutter.dart';
141100
import 'package:flutter/material.dart';
142101
143-
import 'amplifyconfiguration.dart';
144-
145-
void main() {
146-
runApp(const MyApp());
147-
}
148-
149-
class MyApp extends StatefulWidget {
150-
const MyApp({super.key});
151-
152-
@override
153-
State<MyApp> createState() => _MyAppState();
154-
}
102+
import 'amplify_outputs.dart';
155103
156-
class _MyAppState extends State<MyApp> {
157-
@override
158-
void initState() {
159-
super.initState();
160-
_configureAmplify();
104+
Future<void> main() async {
105+
try {
106+
WidgetsFlutterBinding.ensureInitialized();
107+
await _configureAmplify();
108+
runApp(const MyApp());
109+
} on AmplifyException catch (e) {
110+
runApp(Text("Error configuring Amplify: ${e.message}"));
161111
}
112+
}
162113
163-
Future<void> _configureAmplify() async {
164-
try {
165-
await Amplify.addPlugin(AmplifyAuthCognito());
166-
await Amplify.configure(amplifyconfig);
167-
safePrint('Successfully configured');
168-
} on Exception catch (e) {
169-
safePrint('Error configuring Amplify: $e');
170-
}
114+
Future<void> _configureAmplify() async {
115+
try {
116+
await Amplify.addPlugin(AmplifyAuthCognito());
117+
await Amplify.configure(amplifyConfig);
118+
safePrint('Successfully configured');
119+
} on Exception catch (e) {
120+
safePrint('Error configuring Amplify: $e');
171121
}
122+
}
172123
124+
class MyApp extends StatelessWidget {
125+
const MyApp({super.key});
173126
@override
174127
Widget build(BuildContext context) {
175128
return Authenticator(
176129
child: MaterialApp(
177130
builder: Authenticator.builder(),
178131
home: const Scaffold(
179132
body: Center(
180-
child: Text('You are logged in!'),
133+
child: Column(
134+
mainAxisAlignment: MainAxisAlignment.center,
135+
children: [
136+
SignOutButton(),
137+
Text('TODO Application'),
138+
],
139+
),
181140
),
182141
),
183142
),
@@ -186,17 +145,17 @@ class _MyAppState extends State<MyApp> {
186145
}
187146
```
188147

189-
9. Since Amplify Flutter supports 6 platforms with Flutter including iOS, Android, Web, and Desktop, some extra configuration may be required for each platform. Check out the [Platform Setup](https://docs.amplify.aws/lib/project-setup/platform-setup/q/platform/flutter/) guide to make sure you've completed the necessary steps.
148+
7. Deploy your backend use Amplify's per-developer cloud sandbox. This feature provides a separate backend environment for every developer on a team, ideal for local development and testing. To run your application with a sandbox environment, you can run the following command:
190149

191-
10. Run `flutter run` to launch your app on the connected device.
150+
`npx ampx sandbox --outputs-format dart --outputs-out-dir lib`
192151

193-
11. Once the app is loaded, tap on **Configure Amplify**, then on **Record Event** a few times.
152+
8. Since Amplify Flutter supports 6 platforms with Flutter including iOS, Android, Web, and Desktop, some extra configuration may be required for each platform. Check out the [Platform Setup](https://docs.amplify.aws/flutter/start/platform-setup/) guide to make sure you've completed the necessary steps.
194153

195-
12. To see the events you recoded, run `amplify console analytics`. This will open the Amazon Pinpoint console for your project in your default web browser. Within about a minute you should start seeing the events populating in the Events section of then Pinpoint console.
154+
9. Run `flutter run` to launch your app on the connected device.
196155

197156
Congratulations, you've built your first Amplify app! 🎉
198157

199-
For further documentation and Amplify Category usage, see the [documentation](https://docs.amplify.aws/lib/q/platform/flutter).
158+
For further documentation and Amplify Category usage, see the [documentation](https://docs.amplify.aws/flutter/).
200159

201160
---
202161

0 commit comments

Comments
 (0)