Skip to content

Commit

Permalink
fix: Double super.initState and Disposed Timer
Browse files Browse the repository at this point in the history
  • Loading branch information
Pinho13 committed Nov 12, 2024
1 parent 4460dfc commit df701d8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ class LastUpdateTimeStamp<T extends StateProviderNotifier<dynamic>>
class _LastUpdateTimeStampState<T extends StateProviderNotifier<dynamic>>
extends State<StatefulWidget> {
DateTime currentTime = DateTime.now();

Timer? timer;
@override
void initState() {
super.initState();
Timer.periodic(
timer = Timer.periodic(
const Duration(seconds: 60),
(timer) {
if (mounted) {
Expand All @@ -34,6 +34,12 @@ class _LastUpdateTimeStampState<T extends StateProviderNotifier<dynamic>>
);
}

@override
void dispose() {
timer?.cancel();
super.dispose();
}

@override
Widget build(BuildContext context) {
return Consumer<T>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class _RestaurantPageViewState extends GeneralPageViewState<RestaurantPageView>
void initState() {
super.initState();
final weekDay = DateTime.now().weekday;
super.initState();
tabController = TabController(vsync: this, length: DayOfWeek.values.length);
tabController.animateTo(tabController.index + (weekDay - 1));
scrollViewController = ScrollController();
Expand Down

0 comments on commit df701d8

Please sign in to comment.