BirjuVachhani / adaptive_theme

Easiest way to add support for light and dark theme in your flutter app.
https://pub.dev/packages/adaptive_theme
Apache License 2.0
464 stars 37 forks source link

Fix Cupertino theme changes #24

Closed glofru closed 2 years ago

glofru commented 3 years ago

Requirements

None.

Description of the Change

I have noticed that, with CupertinoApp, whenever you switched light/dark theme, the application did not update the theme. Moreover, setting "initial" to "AdaptiveMode.system", the app always started in dark mode despite the light mode on the device. I have made three mayors updates:

  1. In the CupertinoAdaptiveTheme's build method it now checks whether the theme is light because intentionally set white or because was set system and the device is in light mode. Giving that, the app is fully capable to detect the correct theme to set.
  2. I have created an initState method in CupertinoAdaptiveTheme that set an onPlatformBrightnessChanged method in order to catch the variation of the light/dark mode and so update accordingly.
  3. I have updated the README since there was a mistake: CupertinoApp does not have a "darkMode" property to be set.
BirjuVachhani commented 3 years ago

@glofru Take a look at this: https://github.com/flutter/flutter/issues/86975#issuecomment-890751189

Are you absolutely sure that this is different from what you're facing?

glofru commented 3 years ago

@glofru Take a look at this: flutter/flutter#86975 (comment)

Are you absolutely sure that this is different from what you're facing?

As far as I tried, it did not work on VSC and on terminal.

BirjuVachhani commented 3 years ago

@glofru My point here is that If it is working on Android or web then it should also work on other platforms too. There is no platform specific code here neither it relies on any platform specific APIs. This is pure Flutter code which just manages the themes being passed to the CupertinoApp or MaterialApp.

If MaterialApp is working and CupertinoApp isn't then don't you think something could be wrong in Flutter SDK itself?

BirjuVachhani commented 3 years ago

Huh... I tried CupertinoApp on web and it didn't work. I am sure it was working before!

https://adaptivetheme.codemagic.app

glofru commented 3 years ago

@glofru My point here is that If it is working on Android or web then it should also work on other platforms too. There is no platform specific code here neither it relies on any platform specific APIs. This is pure Flutter code which just manages the themes being passed to the CupertinoApp or MaterialApp.

If MaterialApp is working and CupertinoApp isn't then don't you think something could be wrong in Flutter SDK itself?

It could be, but I think this package should fix this kind of things in case.

BirjuVachhani commented 3 years ago

Eventually Flutter is gonna fix this but it makes sense! Let's what we can do!

BirjuVachhani commented 2 years ago

@glofru This has been fixed in a more neat and effective way and is available in the release 2.3.0.