Skip to content

Commit

Permalink
Hourly cards were not updated when the city changed.
Browse files Browse the repository at this point in the history
  • Loading branch information
myavuzokumus committed Jan 8, 2024
1 parent 7a32f33 commit b3292b8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/pages/main_page_widgets/hourly_status_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class _HourlyStatusCardState extends State<HourlyStatusCard> {

late final ScrollController scrollController;

late final List<HourlyWeather> hourlyWeatherDetails;
late List<HourlyWeather> hourlyWeatherDetails;

@override
void initState() {
Expand Down Expand Up @@ -59,8 +59,13 @@ class _HourlyStatusCardState extends State<HourlyStatusCard> {
@override
void didUpdateWidget(covariant final HourlyStatusCard oldWidget) {

if (lastSelectedCity != "Select City" || widget.returnedJsonData.isNotEmpty) {
hourlyWeatherDetails = getHoursData();
}

//To make the animation work when the page is refreshed.
WidgetsBinding.instance.addPostFrameCallback((final _) {

if (scrollController.hasClients) {
scrollController.animateTo(hours.indexOf(widget.currentTime).toDouble() * 76,
duration: const Duration(seconds: 1), curve: Curves.easeOut);
Expand Down

0 comments on commit b3292b8

Please sign in to comment.