Update Flutter and Bloc Interactions Overview authored by Spencer Hooper's avatar Spencer Hooper
...@@ -13,7 +13,7 @@ When the Server has completed its task, it sends a [Response](Response and Reque ...@@ -13,7 +13,7 @@ When the Server has completed its task, it sends a [Response](Response and Reque
# Await # Await
In the Repository, the **await** keyword is used to force the caller to wait for the function to complete and ensures that our response will get the data that it has requested from the server. In the Repository, the **await** keyword is used to force the caller to wait for the function to complete and ensures that our response will get the data that it has requested from the server.
Below is code from the login repository that takes in a Login Request, encodes it as JSON and then sends a POST request to the server, awaiting a response from the server that confirms whether the password from the Login Request matches the password associated with that player in the Database. If it does, the response will be successful and the player will be logged in. Below is code from the login repository that takes in a Login Request, encodes it as JSON and then sends a POST request to the server, awaiting a response from the server that confirms whether the password from the Login Request matches the password associated with that player in the Database. If it does, the response will be successful and the player will be logged in, changing the display from the Login page to the main landing page.
```dart ```dart
Future<LoginWithCredentialsResponse> loginPlayer(LoginWithCredentialsRequest request) async Future<LoginWithCredentialsResponse> loginPlayer(LoginWithCredentialsRequest request) async
{ {
...@@ -32,7 +32,7 @@ Future<LoginWithCredentialsResponse> loginPlayer(LoginWithCredentialsRequest req ...@@ -32,7 +32,7 @@ Future<LoginWithCredentialsResponse> loginPlayer(LoginWithCredentialsRequest req
``` ```
# Example
As an example, the following code requests information about the majors and crews when creating a player: As an example, the following code requests information about the majors and crews when creating a player:
```dart ```dart
... ...
......