Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(flutter_weather): update tutorial (#2519)
- Loading branch information
1 parent
c29f40e
commit f9a4de9
Showing
97 changed files
with
2,151 additions
and
3,565 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 0 additions & 19 deletions
19
docs/_snippets/flutter_weather_tutorial/add_completer.dart.md
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
docs/_snippets/flutter_weather_tutorial/bloc_consumer_refactor.dart.md
This file was deleted.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
docs/_snippets/flutter_weather_tutorial/build_runner_builder.sh.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```sh | ||
flutter packages pub run build_runner build | ||
``` |
7 changes: 7 additions & 0 deletions
7
docs/_snippets/flutter_weather_tutorial/business_logic_layer/theme_cubit_tree.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
``` | ||
flutter_weather | ||
|-- lib/ | ||
|-- theme/ | ||
|-- cubit/ | ||
|-- theme_cubit.dart | ||
``` |
8 changes: 8 additions & 0 deletions
8
docs/_snippets/flutter_weather_tutorial/business_logic_layer/weather_cubit_tree.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
``` | ||
flutter_weather | ||
|-- lib/ | ||
|-- weather/ | ||
|-- cubit/ | ||
|-- weather_cubit.dart | ||
|-- weather_state.dart | ||
``` |
45 changes: 0 additions & 45 deletions
45
docs/_snippets/flutter_weather_tutorial/city_selection.dart.md
This file was deleted.
Oops, something went wrong.
51 changes: 0 additions & 51 deletions
51
docs/_snippets/flutter_weather_tutorial/combined_weather_temperature.dart.md
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
docs/_snippets/flutter_weather_tutorial/dart_async_import.dart.md
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
docs/_snippets/flutter_weather_tutorial/dart_convert_import.dart.md
This file was deleted.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
docs/_snippets/flutter_weather_tutorial/data_layer/export_top_level_models.dart.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
```dart | ||
library meta_weather_api; | ||
export 'src/models/models.dart'; | ||
``` |
3 changes: 3 additions & 0 deletions
3
docs/_snippets/flutter_weather_tutorial/data_layer/flutter_create_api_client.sh.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```sh | ||
flutter create --template=package meta_weather_api | ||
``` |
21 changes: 21 additions & 0 deletions
21
docs/_snippets/flutter_weather_tutorial/data_layer/get_weather_method.dart.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
```dart | ||
/// Fetches [Weather] for a given [locationId]. | ||
Future<Weather> getWeather(int locationId) async { | ||
final weatherRequest = Uri.https(_baseUrl, '/api/location/$locationId'); | ||
final weatherResponse = await _httpClient.get(weatherRequest); | ||
if (weatherResponse.statusCode != 200) { | ||
throw WeatherRequestFailure(); | ||
} | ||
final weatherJson = jsonDecode( | ||
weatherResponse.body, | ||
)['consolidated_weather'] as List; | ||
if (weatherJson.isEmpty) { | ||
throw WeatherRequestFailure(); | ||
} | ||
return Weather.fromJson(weatherJson.first as Map<String, dynamic>); | ||
} | ||
``` |
17 changes: 17 additions & 0 deletions
17
docs/_snippets/flutter_weather_tutorial/data_layer/http_pubspec.yaml.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
```yaml | ||
name: meta_weather_api | ||
description: A Dart API Client for the MetaWeather API. | ||
version: 1.0.0+1 | ||
|
||
environment: | ||
sdk: ">=2.12.0 <3.0.0" | ||
|
||
dependencies: | ||
http: ^0.13.0 | ||
json_annotation: ^4.0.0 | ||
|
||
dev_dependencies: | ||
coverage: ^0.14.1 | ||
build_runner: ^1.10.0 | ||
json_serializable: ^4.0.0 | ||
``` |
15 changes: 15 additions & 0 deletions
15
..._snippets/flutter_weather_tutorial/data_layer/json_serializable_pubspec.yaml.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
```yaml | ||
name: meta_weather_api | ||
description: A Dart API Client for the MetaWeather API. | ||
version: 1.0.0+1 | ||
|
||
environment: | ||
sdk: ">=2.12.0 <3.0.0" | ||
|
||
dependencies: | ||
json_annotation: ^4.0.0 | ||
|
||
dev_dependencies: | ||
build_runner: ^1.10.0 | ||
json_serializable: ^4.0.0 | ||
``` |
31 changes: 31 additions & 0 deletions
31
docs/_snippets/flutter_weather_tutorial/data_layer/location.dart.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
```dart | ||
enum LocationType { | ||
city, | ||
region, | ||
state, | ||
province, | ||
country, | ||
continent | ||
} | ||
class Location { | ||
const Location({ | ||
required this.title, | ||
required this.locationType, | ||
required this.latLng, | ||
required this.woeid, | ||
}); | ||
final String title; | ||
final LocationType locationType; | ||
final LatLng latLng; | ||
final int woeid; | ||
} | ||
class LatLng { | ||
const LatLng({required this.latitude, required this.longitude}); | ||
final double latitude; | ||
final double longitude; | ||
} | ||
``` |
8 changes: 8 additions & 0 deletions
8
docs/_snippets/flutter_weather_tutorial/data_layer/location.json.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
```json | ||
{ | ||
"title": "London", | ||
"location_type": "City", | ||
"woeid": 44418, | ||
"latt_long": "51.506321,-0.12714" | ||
} | ||
``` |
25 changes: 25 additions & 0 deletions
25
docs/_snippets/flutter_weather_tutorial/data_layer/location_search_method.dart.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
```dart | ||
/// Finds a [Location] `/api/location/search/?query=(query)`. | ||
Future<Location> locationSearch(String query) async { | ||
final locationRequest = Uri.https( | ||
_baseUrl, | ||
'/api/location/search', | ||
<String, String>{'query': query}, | ||
); | ||
final locationResponse = await _httpClient.get(locationRequest); | ||
if (locationResponse.statusCode != 200) { | ||
throw LocationIdRequestFailure(); | ||
} | ||
final locationJson = jsonDecode( | ||
locationResponse.body, | ||
) as List; | ||
if (locationJson.isEmpty) { | ||
throw LocationIdRequestFailure(); | ||
} | ||
return Location.fromJson(locationJson.first as Map<String, dynamic>); | ||
} | ||
``` |
18 changes: 18 additions & 0 deletions
18
docs/_snippets/flutter_weather_tutorial/data_layer/meta_weather_api_client_tree.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
``` | ||
flutter_weather | ||
|-- lib/ | ||
|-- test/ | ||
|-- packages/ | ||
|-- meta_weather_api/ | ||
|-- lib/ | ||
|-- src/ | ||
|-- models/ | ||
|-- location.dart | ||
|-- location.g.dart | ||
|-- weather.dart | ||
|-- weather.g.dart | ||
|-- models.dart | ||
|-- meta_weather_api_client.dart | ||
|-- meta_weather_api.dart | ||
|-- test/ | ||
``` |
Oops, something went wrong.