Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed icon updation for dark mode #133 #134

Merged
merged 3 commits into from
Jan 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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