Skip to content

Commit

Permalink
Merge pull request #134 from sommye-ctr/dark-mode-error
Browse files Browse the repository at this point in the history
Fixed icon updation for dark mode #133
  • Loading branch information
Akshit517 authored Jan 15, 2025
2 parents 3407c72 + fbb991e commit 336e847
Showing 1 changed file with 12 additions and 23 deletions.
35 changes: 12 additions & 23 deletions lib/widgets/theme_mode_switch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,22 @@ import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:taskly/providers/theme_provider.dart';

class ThemeModeSwitch extends StatefulWidget {
class ThemeModeSwitch extends StatelessWidget {
const ThemeModeSwitch({super.key});

@override
State<ThemeModeSwitch> createState() => _ThemeModeSwitchState();
}

class _ThemeModeSwitchState extends State<ThemeModeSwitch> {
late ThemeProvider themeProvider;

@override
void initState() {
super.initState();
themeProvider = Provider.of<ThemeProvider>(context, listen: false);
}

@override
Widget build(BuildContext context) {
return Card(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)),
margin: const EdgeInsets.all(0),
child: IconButton(
onPressed: () => themeProvider.darkTheme = !themeProvider.darkTheme,
icon: Icon(
themeProvider.darkTheme
? Icons.dark_mode_rounded
: Icons.light_mode_rounded,
return Consumer<ThemeProvider>(
builder: (context, value, child) => Card(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)),
margin: const EdgeInsets.all(0),
child: IconButton(
onPressed: () => value.darkTheme = !value.darkTheme,
icon: Icon(
value.darkTheme
? Icons.dark_mode_rounded
: Icons.light_mode_rounded,
),
),
),
);
Expand Down

0 comments on commit 336e847

Please sign in to comment.