From fb0dbef158e22e32738cca37db9af43d0fa6fbda Mon Sep 17 00:00:00 2001 From: Marco Date: Thu, 13 Jun 2024 21:49:04 +0200 Subject: [PATCH] Make the theme switcher icon change depending on the theme. --- android/app/src/main/AndroidManifest.xml | 2 +- lib/perdate_widget.dart | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index c6d3d0c..b0b6912 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,6 +1,6 @@ { appBar: AppBar( title: Text(formattedDate), actions: [ - IconButton( - icon: const Icon(Icons.lightbulb), - onPressed: () { - context.read().add(ThemeToggleEvent()); - }, - ), + BlocBuilder(builder: (context, state) { + var icon = const Icon(Icons.light_mode); + if (state.brightness == 'light') { + icon = const Icon(Icons.dark_mode); + } + return IconButton( + icon: icon, + onPressed: () { + context.read().add(ThemeToggleEvent()); + }, + ); + }), ], ), drawer: const AppDrawer(),