You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 20, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: src/pages/guides/dart/flutter.mdx
+10-14Lines changed: 10 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -67,15 +67,8 @@ touch lib/services/main.dart
67
67
68
68
You will also need to add Nitric to your `pubspec.yaml`.
69
69
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
79
72
```
80
73
81
74
### Building the API
@@ -96,7 +89,7 @@ void main() {
96
89
}
97
90
```
98
91
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.
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.
211
205
212
206
```dart {{ label: "lib/services/main.dart" }}
213
-
import 'package:flutter_blog/cors.dart';
207
+
import 'package:word_generator/cors.dart';
214
208
215
209
...
216
210
@@ -241,9 +235,9 @@ You can test the routes using the dashboard or cURL commands in your terminal.
241
235
[{"name": "testpair"}]
242
236
```
243
237
244
-
## Frontend
238
+
## Flutter Frontend
245
239
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.
247
241
248
242
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.
249
243
@@ -994,7 +988,9 @@ class _HomePageState extends State<HomePage> {
994
988
995
989
## Deployment
996
990
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:
0 commit comments