Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 09f08d9

Browse files
review updates
Co-authored-by: David Moore <[email protected]>
1 parent 391f854 commit 09f08d9

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

src/pages/guides/dart/flutter.mdx

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,8 @@ touch lib/services/main.dart
6767

6868
You will also need to add Nitric to your `pubspec.yaml`.
6969

70-
```yaml {{ label: "pubspec.yaml" }}
71-
dependencies:
72-
flutter:
73-
sdk: flutter
74-
75-
nitric_sdk:
76-
git:
77-
url: https://github.com/nitrictech/dart-sdk.git
78-
ref: main
70+
```bash
71+
flutter pub add nitric_sdk
7972
```
8073

8174
### Building the API
@@ -96,7 +89,7 @@ void main() {
9689
}
9790
```
9891

99-
We will define a favourites class to convert our JSON requests to Favourite objects and then back into JSON. Conversion to a `Map<String, dynamic` will also allow us to store the Favourites objects in the key value store. We can do this by defining `fromJson` and `toJson` methods, allowing the builtin `jsonEncode` and `jsonDecode` methods to understand our model. By defining this as a class it unifies the way the frontend and backend handle Favourites objects, while leaving room for extension for additional metadata.
92+
We will define a favourites class to convert our JSON requests to Favourite objects and then back into JSON. Conversion to a `Map<String, dynamic>` will also allow us to store the Favourites objects in the key value store. We can do this by defining `fromJson` and `toJson` methods, allowing the builtin `jsonEncode` and `jsonDecode` methods to understand our model. By defining this as a class it unifies the way the frontend and backend handle Favourites objects, while leaving room for extension for additional metadata.
10093

10194
```dart {{ label: "lib/favourite.dart" }}
10295
class Favourite {
@@ -134,6 +127,7 @@ api.get("/favourites", (ctx) async {
134127
135128
// Return the body as a list of favourites
136129
ctx.res.body = jsonEncode(favourites);
130+
ctx.res.headers["Content-Type"] = ["application/json"];
137131
138132
return ctx;
139133
});
@@ -210,7 +204,7 @@ Future<HttpContext> addCors(HttpContext ctx) async {
210204
We can then add the options routes and add the CORS middleware to the API. When we add a middleware at the API level it will run on every request to any route on that API.
211205

212206
```dart {{ label: "lib/services/main.dart" }}
213-
import 'package:flutter_blog/cors.dart';
207+
import 'package:word_generator/cors.dart';
214208
215209
...
216210
@@ -241,9 +235,9 @@ You can test the routes using the dashboard or cURL commands in your terminal.
241235
[{"name": "testpair"}]
242236
```
243237

244-
## Frontend
238+
## Flutter Frontend
245239

246-
We can now start on the frontend. The application will contain two pages which can be navigated between by using the
240+
We can now start on the frontend. The application will contain two pages which can be navigated between by using the side navigation.
247241

248242
The first will show the current generated word along with a history of all previously generated words. It will have a button to like the word and a button to generate the next word.
249243

@@ -994,7 +988,9 @@ class _HomePageState extends State<HomePage> {
994988

995989
## Deployment
996990

997-
At this point, you can deploy the application to any supported cloud provider. Start by setting up your credentials and any configuration for the cloud you prefer:
991+
At this point, we can get started on deploying our application. The frontend application deployment depends on which platform you wish to deploy to. You can take a look at the Flutter documentation for this [here](https://docs.flutter.dev/deployment). The backend will be deployed to one of the cloud platforms, AWS, Google Cloud, or Azure. This guide will demonstrate deploying to AWS.
992+
993+
For the backend, start by setting up your credentials and any configuration for the cloud you prefer:
998994

999995
- [AWS](/reference/providers/aws)
1000996
- [Azure](/reference/providers/azure)

0 commit comments

Comments
 (0)