Skip to content

Commit

Permalink
Fix bug that theme color isn't changed
Browse files Browse the repository at this point in the history
  • Loading branch information
woin2ee committed Feb 18, 2025
1 parent 900a36a commit aa0d1b1
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/farm_page/farm_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ class _FarmPageState extends State<FarmPage> {
return ChangeNotifierProvider.value(
value: _controller,
builder: (context, child) {
final controller = context.watch<FarmPageController>();

return Theme(
data: ThemeData(
useMaterial3: true,
colorScheme: ColorScheme.fromSeed(seedColor: _controller.selectedSeason.personalColor),
colorScheme: ColorScheme.fromSeed(seedColor: controller.selectedSeason.personalColor),
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
Expand Down Expand Up @@ -179,9 +181,9 @@ class _NewButton extends StatelessWidget {
}

class _SeasonSelectionBox extends StatelessWidget {
_SeasonSelectionBox();
const _SeasonSelectionBox();

final List<Season> _seasons = [
static const List<Season> _seasons = [
Season.spring,
Season.summer,
Season.autumn,
Expand All @@ -191,15 +193,15 @@ class _SeasonSelectionBox extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Consumer<FarmPageController>(
builder: (context, model, child) => ToggleButtons(
builder: (context, controller, child) => ToggleButtons(
borderRadius: BorderRadius.circular(10),
constraints: const BoxConstraints(
minWidth: 70,
minHeight: 40,
),
isSelected: _seasons.map((season) => season == model.selectedSeason).toList(),
isSelected: _seasons.map((season) => season == controller.selectedSeason).toList(),
onPressed: (index) {
model.selectedSeason = _seasons[index];
controller.selectedSeason = _seasons[index];
},
children: [
...Season.values.map((season) => Padding(
Expand Down

0 comments on commit aa0d1b1

Please sign in to comment.