mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-03-21 06:38:52 +00:00
theme context initState fix
This commit is contained in:
parent
996f17d738
commit
0f7f5f70a5
1 changed files with 7 additions and 5 deletions
|
@ -1,9 +1,11 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:flutter_svg/svg.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/assets.dart';
|
||||||
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
||||||
|
|
||||||
class FavoriteToggle extends StatefulWidget {
|
class FavoriteToggle extends ConsumerStatefulWidget {
|
||||||
const FavoriteToggle({
|
const FavoriteToggle({
|
||||||
Key? key,
|
Key? key,
|
||||||
this.backGround,
|
this.backGround,
|
||||||
|
@ -22,10 +24,10 @@ class FavoriteToggle extends StatefulWidget {
|
||||||
final void Function(bool)? onChanged;
|
final void Function(bool)? onChanged;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<FavoriteToggle> createState() => _FavoriteToggleState();
|
ConsumerState<FavoriteToggle> createState() => _FavoriteToggleState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _FavoriteToggleState extends State<FavoriteToggle> {
|
class _FavoriteToggleState extends ConsumerState<FavoriteToggle> {
|
||||||
late bool _isActive;
|
late bool _isActive;
|
||||||
late Color _color;
|
late Color _color;
|
||||||
late void Function(bool)? _onChanged;
|
late void Function(bool)? _onChanged;
|
||||||
|
@ -36,9 +38,9 @@ class _FavoriteToggleState extends State<FavoriteToggle> {
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
on = widget.on ??
|
on = widget.on ??
|
||||||
Theme.of(context).extension<StackColors>()!.favoriteStarActive;
|
ref.read(colorThemeProvider.state).state.favoriteStarActive;
|
||||||
off = widget.off ??
|
off = widget.off ??
|
||||||
Theme.of(context).extension<StackColors>()!.favoriteStarInactive;
|
ref.read(colorThemeProvider.state).state.favoriteStarInactive;
|
||||||
_isActive = widget.initialState;
|
_isActive = widget.initialState;
|
||||||
_color = _isActive ? on : off;
|
_color = _isActive ? on : off;
|
||||||
_onChanged = widget.onChanged;
|
_onChanged = widget.onChanged;
|
||||||
|
|
Loading…
Reference in a new issue