From a8d656338ac09fe3afce912a4f008182613ddea2 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 22 Sep 2022 18:18:24 -0600 Subject: [PATCH] theme context initState fix --- lib/widgets/custom_buttons/favorite_toggle.dart | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/widgets/custom_buttons/favorite_toggle.dart b/lib/widgets/custom_buttons/favorite_toggle.dart index 2d25d0674..83834a3ee 100644 --- a/lib/widgets/custom_buttons/favorite_toggle.dart +++ b/lib/widgets/custom_buttons/favorite_toggle.dart @@ -1,9 +1,11 @@ import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; +import 'package:stackwallet/providers/ui/color_theme_provider.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; -class FavoriteToggle extends StatefulWidget { +class FavoriteToggle extends ConsumerStatefulWidget { const FavoriteToggle({ Key? key, this.backGround, @@ -22,10 +24,10 @@ class FavoriteToggle extends StatefulWidget { final void Function(bool)? onChanged; @override - State createState() => _FavoriteToggleState(); + ConsumerState createState() => _FavoriteToggleState(); } -class _FavoriteToggleState extends State { +class _FavoriteToggleState extends ConsumerState { late bool _isActive; late Color _color; late void Function(bool)? _onChanged; @@ -36,9 +38,9 @@ class _FavoriteToggleState extends State { @override void initState() { on = widget.on ?? - Theme.of(context).extension()!.favoriteStarActive; + ref.read(colorThemeProvider.state).state.favoriteStarActive; off = widget.off ?? - Theme.of(context).extension()!.favoriteStarInactive; + ref.read(colorThemeProvider.state).state.favoriteStarInactive; _isActive = widget.initialState; _color = _isActive ? on : off; _onChanged = widget.onChanged;