Show temperature of today after starting app
This commit is contained in:
+9
-3
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:wetter/components/compact_weather_data.dart';
|
||||
import 'package:wetter/models/daily_weather_model.dart';
|
||||
import 'package:wetter/services/brightsky_api_service.dart';
|
||||
|
||||
@@ -17,7 +18,7 @@ class _MyAppState extends State<MyApp> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
futureAlbum = BrightSkyAPI.fetchForecast();
|
||||
futureAlbum = BrightSkyAPI.fetchForecast(DateTime.now());
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -26,17 +27,22 @@ class _MyAppState extends State<MyApp> {
|
||||
title: 'Fetch Data Example',
|
||||
theme: ThemeData(
|
||||
primarySwatch: Colors.blue,
|
||||
textTheme: const TextTheme(
|
||||
headline1: TextStyle(fontSize: 72.0, fontWeight: FontWeight.bold),
|
||||
headline6: TextStyle(fontSize: 36.0, fontStyle: FontStyle.italic),
|
||||
bodyText2: TextStyle(fontSize: 14.0, fontFamily: 'Hind'),
|
||||
),
|
||||
),
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Fetch Data Example'),
|
||||
title: const Text('Wetter heute in Harburg'),
|
||||
),
|
||||
body: Center(
|
||||
child: FutureBuilder<DailyWeatherModel>(
|
||||
future: futureAlbum,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
return Text(snapshot.data!.dailyAverageTemp());
|
||||
return CompactWeatherData(snapshot.data!);
|
||||
} else if (snapshot.hasError) {
|
||||
return Text('${snapshot.error}');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user