|
1 |
| -export const description = |
2 |
| - 'Use the Nitric framework to easily build and deploy a backend for your Flutter application' |
3 |
| - |
4 |
| -export const title_meta = 'Building a Full Stack Flutter Application in Dart' |
| 1 | +--- |
| 2 | +description: Use the Nitric framework to easily build and deploy a backend for your Flutter application |
| 3 | +title_seo: Building a Full Stack Flutter Application in Dart |
| 4 | +tags: |
| 5 | + - Frontend |
| 6 | + - Key Value Store |
| 7 | + - API |
| 8 | +--- |
5 | 9 |
|
6 | 10 | # Building a Full Stack Flutter Application in Dart
|
7 | 11 |
|
@@ -125,21 +129,23 @@ import 'dart:convert';
|
125 | 129 | ...
|
126 | 130 |
|
127 | 131 | api.get("/favorites", (ctx) async {
|
128 |
| - // Get a list of all the keys in the store |
129 |
| - var keys = await favouritesKV.keys(); |
| 132 | +// Get a list of all the keys in the store |
| 133 | +var keys = await favouritesKV.keys(); |
130 | 134 |
|
131 |
| - var favourites = await keys.asyncMap((k) async { |
132 |
| - final favourite = await favouritesKV.get(k); |
| 135 | +var favourites = await keys.asyncMap((k) async { |
| 136 | +final favourite = await favouritesKV.get(k); |
133 | 137 |
|
134 | 138 | return favourite;
|
135 |
| - }).toList(); |
136 | 139 |
|
137 |
| - // Return the body as a list of favorites |
138 |
| - ctx.res.body = jsonEncode(favorites); |
139 |
| - ctx.res.headers["Content-Type"] = ["application/json"]; |
| 140 | +}).toList(); |
140 | 141 |
|
141 |
| - return ctx; |
| 142 | +// Return the body as a list of favorites |
| 143 | +ctx.res.body = jsonEncode(favorites); |
| 144 | +ctx.res.headers["Content-Type"] = ["application/json"]; |
| 145 | +
|
| 146 | +return ctx; |
142 | 147 | });
|
| 148 | +
|
143 | 149 | ```
|
144 | 150 |
|
145 | 151 | We can then define the route for adding favorites. This will toggle a favorite on or off depending on whether the key exists in the key value store. Make sure you import the `favorite` class from `package:word_generator/favorite.dart`
|
@@ -1006,9 +1012,9 @@ At this point, we can get started on deploying our application. The frontend app
|
1006 | 1012 |
|
1007 | 1013 | For the backend, start by setting up your credentials and any configuration for the cloud you prefer:
|
1008 | 1014 |
|
1009 |
| -- [AWS](/reference/providers/pulumi/aws) |
1010 |
| -- [Azure](/reference/providers/pulumi/azure) |
1011 |
| -- [Google Cloud](/reference/providers/pulumi/gcp) |
| 1015 | +- [AWS](/providers/pulumi/aws) |
| 1016 | +- [Azure](/providers/pulumi/azure) |
| 1017 | +- [Google Cloud](/providers/pulumi/gcp) |
1012 | 1018 |
|
1013 | 1019 | Next, we'll need to create a `stack`. Stacks represent deployed instances of an application, including the target provider and other details such as the deployment region. You'll usually define separate stacks for each environment such as development, testing and production. For now, let's start by creating a `dev` stack for AWS.
|
1014 | 1020 |
|
|
0 commit comments