Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: change outputs to amplifyConfig in flutter gen 2 docs #7764

Merged
merged 7 commits into from
Jun 28, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ However, it can take upwards of 30 minutes for the event to display in the Filte

## Flush events

Events have default configuration to flush out to the network every 30 seconds. If you would like to change this, update `amplifyconfiguration.dart` with the value in milliseconds you would like for `autoFlushEventsInterval`. This configuration will flush events every 10 seconds:
Events have default configuration to flush out to the network every 30 seconds. If you would like to change this, update `amplify_outputs.dart` with the value in milliseconds you would like for `autoFlushEventsInterval`. This configuration will flush events every 10 seconds:

```json
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ import 'package:amplify_auth_cognito/amplify_auth_cognito.dart';
import 'package:amplify_flutter/amplify_flutter.dart';
import 'package:flutter/material.dart';

import 'amplifyconfiguration.dart';
import 'amplify_outputs.dart';

Future<void> _configureAmplify() async {
// Add Pinpoint and Cognito Plugins, and any other plugins you want to use
Expand All @@ -316,15 +316,15 @@ When running your app on macOS you will need to enable keychain sharing in Xcode

</Callout>

Make sure that the amplifyconfiguration.dart file generated in the project setup is included and sent to Amplify.configure:
Make sure that the amplify_outputs.dart file generated in the project setup is included and sent to Amplify.configure:

```dart
import 'package:amplify_analytics_pinpoint/amplify_analytics_pinpoint.dart';
import 'package:amplify_auth_cognito/amplify_auth_cognito.dart';
import 'package:amplify_flutter/amplify_flutter.dart';
import 'package:flutter/material.dart';

import 'amplifyconfiguration.dart';
import 'amplify_outputs.dart';

Future<void> _configureAmplify() async {
// ...
Expand All @@ -333,7 +333,7 @@ Future<void> _configureAmplify() async {
// Once Plugins are added, configure Amplify
// Note: Amplify can only be configured once.
try {
await Amplify.configure(outputs);
await Amplify.configure(amplifyConfig);
} on AmplifyAlreadyConfiguredException {
safePrint(
'Tried to reconfigure Amplify; this can occur when your app restarts on Android.',
Expand All @@ -350,7 +350,7 @@ import 'package:amplify_analytics_pinpoint/amplify_analytics_pinpoint.dart';
import 'package:amplify_auth_cognito/amplify_auth_cognito.dart';
import 'package:flutter/material.dart';

import 'amplifyconfiguration.dart';
import 'amplify_outputs.dart';

Future<void> _configureAmplify() async {
// Add any Amplify plugins you want to use
Expand All @@ -361,7 +361,7 @@ Future<void> _configureAmplify() async {
// Once Plugins are added, configure Amplify
// Note: Amplify can only be configured once.
try {
await Amplify.configure(outputs);
await Amplify.configure(amplifyConfig);
} on AmplifyAlreadyConfiguredException {
safePrint(
'Tried to reconfigure Amplify; this can occur when your app restarts on Android.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,9 @@ npx ampx sandbox
<InlineFilter filters={['flutter']}>

```bash title="Terminal" showLineNumbers={false}
npx ampx sandbox --outputs-format dart --outputs-out-dir lib --outputs-version 0
npx ampx sandbox --outputs-format dart --outputs-out-dir lib
```

<Callout info>

**Note:** when using Amplify Gen 2 with Flutter, you must downgrade the generated client configuration file (`amplify_outputs.dart`) with [`--outputs-version 0`](/[platform]/reference/cli-commands/#npx-ampx-generate-outputs)

</Callout>

</InlineFilter>
<InlineFilter filters={['android']}>

Expand Down Expand Up @@ -394,7 +388,7 @@ import 'package:amplify_authenticator/amplify_authenticator.dart';
import 'package:amplify_flutter/amplify_flutter.dart';
import 'package:flutter/material.dart';

import 'amplifyconfiguration.dart';
import 'amplify_outputs.dart';

Future<void> main() async {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ import 'package:amplify_flutter/amplify_flutter.dart';
import 'package:flutter/material.dart';

// highlight-start
import 'amplifyconfiguration.dart';
import 'amplify_outputs.dart';
import 'models/ModelProvider.dart';
// highlight-end

Expand All @@ -345,7 +345,7 @@ Future<void> main() async {
)
);
await Amplify.addPlugins([api]);
await Amplify.configure(outputs);
await Amplify.configure(amplifyConfig);

safePrint('Successfully configured Amplify');
} on Exception catch (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ import 'package:amplify_flutter/amplify_flutter.dart';
import 'package:amplify_storage_s3/amplify_storage_s3.dart';
import 'package:flutter/material.dart';

import 'amplifyconfiguration.dart';
import 'amplify_outputs.dart';

Future<void> _configureAmplify() async {
try {
Expand All @@ -455,7 +455,7 @@ Future<void> _configureAmplify() async {
await Amplify.addPlugins([auth, storage]);

// call Amplify.configure to use the initialized categories in your app
await Amplify.configure(outputs);
await Amplify.configure(amplifyConfig);
} on Exception catch (e) {
safePrint('An error occurred configuring Amplify: $e');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ To ensure the local **amplify_outputs.json** file is up-to-date, you can run [th

<InlineFilter filters={["flutter"]}>

## Step 3 - Import latest amplifyconfiguration.dart file
## Step 3 - Import latest amplify_outputs.dart file

To ensure the local **amplifyconfiguration.dart** file is up-to-date, you can run [the npx ampx generate outputs command](/[platform]/reference/cli-commands/#npx-ampx-generate-outputs).
To ensure the local **amplify_outputs.dart** file is up-to-date, you can run [the npx ampx generate outputs command](/[platform]/reference/cli-commands/#npx-ampx-generate-outputs).

</InlineFilter>

Expand Down
2 changes: 1 addition & 1 deletion src/pages/[platform]/reference/cli-commands/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ npx ampx sandbox

```bash title="Terminal" showLineNumbers={false}
# for Flutter
npx ampx sandbox --outputs-format dart --outputs-out-dir lib --outputs-version 0
npx ampx sandbox --outputs-format dart --outputs-out-dir lib
```

## npx ampx sandbox delete
Expand Down
9 changes: 2 additions & 7 deletions src/pages/[platform]/start/quickstart/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1313,14 +1313,9 @@ npx ampx sandbox
</InlineFilter>
<InlineFilter filters={["flutter"]}>
```bash title="Terminal" showLineNumbers={false}
npx ampx sandbox --outputs-format dart --outputs-out-dir lib --outputs-version 0
npx ampx sandbox --outputs-format dart --outputs-out-dir lib
```

<Callout info>

**Note:** when using Amplify Gen 2 with Flutter, you must downgrade the generated client configuration file (`amplify_outputs.dart`) with [`--outputs-version 0`](/[platform]/reference/cli-commands/#npx-ampx-generate-outputs)

</Callout>
</InlineFilter>

## Adding Authentication
Expand Down Expand Up @@ -1358,7 +1353,7 @@ import 'package:amplify_authenticator/amplify_authenticator.dart';
import 'package:amplify_flutter/amplify_flutter.dart';
import 'package:flutter/material.dart';

import 'amplifyconfiguration.dart';
import 'amplify_outputs.dart';

Future<void> main() async {
try {
Expand Down