Skip to content

Commit 9fb6dd9

Browse files
Merge pull request #5 from Feichtmeier/fix_coords_null_in_forecast
Fix coords null in forecast
2 parents b191760 + f8cd6e4 commit 9fb6dd9

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

example/lib/screens/prebuilt_functions_demo_screen.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class _PrebuiltFunctionScreenState extends State<PrebuiltFunctionScreen> {
108108
mainAxisAlignment: MainAxisAlignment.spaceAround,
109109
children: [
110110
LocationViewWidget(
111-
title: snapshot.data!.name,
111+
title: snapshot.data!.name ?? '',
112112
color: Colors.black,
113113
),
114114
WeatherSummary(

lib/models/weather_data.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ class WeatherData {
2020
@JsonKey(name: 'main')
2121
Temperature temperature;
2222
@JsonKey(name: 'coord')
23-
Coordinates coordinates;
24-
String name;
23+
Coordinates? coordinates;
24+
String? name;
2525
@JsonKey(name: 'dt')
2626
int date;
2727

lib/models/weather_data.g.dart

Lines changed: 6 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/widgets/modules/location_view_widget.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class LocationView extends StatelessWidget {
2020
Widget build(BuildContext context) {
2121
return Center(
2222
child: Column(children: [
23-
Text(weatherData.name.toUpperCase(),
23+
Text(weatherData.name?.toUpperCase() ?? '',
2424
style: TextStyle(
2525
fontSize: 40,
2626
fontWeight: FontWeight.w300,
@@ -31,7 +31,7 @@ class LocationView extends StatelessWidget {
3131
children: [
3232
Icon(Icons.location_on, color: color, size: 15),
3333
const SizedBox(width: 10),
34-
Text(weatherData.coordinates.lat.toString(),
34+
Text(weatherData.coordinates?.lat.toString() ?? '',
3535
style: TextStyle(
3636
fontSize: 16,
3737
color: color,
@@ -41,7 +41,7 @@ class LocationView extends StatelessWidget {
4141
fontSize: 16,
4242
color: color,
4343
)),
44-
Text(weatherData.coordinates.lon.toString(),
44+
Text(weatherData.coordinates?.lon.toString() ?? '',
4545
style: TextStyle(
4646
fontSize: 16,
4747
color: color,

0 commit comments

Comments
 (0)