Wrong theme applied on first app launch until backgrounded
Valutazione
- Difficoltà
- 1/5
- Tempo stimato
- Meno di un'ora
- Idoneità per principianti
- 86/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Tranquilla
- Ambito
- mobile-dev
Direzione di ricerca
Inizia in lib/service/styles.dart, in Styles._getSelectedTheme(), e segui il percorso del primo avvio quando Storage().selectedTheme è null. Assicurati che il tema di sistema predefinito sia disponibile per la selezione locale prima della risoluzione, quindi verifica che una nuova installazione selezioni il tema chiaro o scuro del dispositivo senza mandare l’app in background.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
When an app is launched for the very first time after a fresh install (no persisted theme preference), the wrong theme is applied (e.g. the light theme while the device is in dark mode). Sending the app to the background and reopening it corrects the theme.
Root Cause
Styles._getSelectedTheme() in lib/service/styles.dart:
String? selectedTheme = Storage().selectedTheme;
if (selectedTheme == null) {
Storage().selectedTheme = AppThemes.system; // persists default, but local var stays null
}
if (selectedTheme == AppThemes.system) { // still null on first launch -> skipped
...resolve to light/dark...
}
return selectedTheme; // returns null on first launch
On first launch Storage().selectedTheme is null. The default AppThemes.system is written to storage but the local selectedTheme variable is not updated, so the system->light/dark resolution is skipped and the method returns null. _applySelectedTheme() then falls back to the un-themed 'default' theme instead of the device-appropriate one.
On a later resume, updateFromNet() -> build() -> _getSelectedTheme() runs again; by then Storage().selectedTheme is persisted as 'system', resolution succeeds, and notifyChanged rebuilds with the correct theme — which is why backgrounding 'fixes' it.
Fix
Update the local variable when defaulting:
if (selectedTheme == null) {
selectedTheme = Storage().selectedTheme = AppThemes.system;
}
- Lingua principale
- Dart
- Stelle
- 3
- Fork
- 4
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di rokwire/app-flutter-plugin
-
[TASK] Investigate crash after login on iOSForse già presa @roberlander2 l’ha presa 148 giorni fa. Aperta
rokwire/app-flutter-plugin#696 · 1 assegnatario ·
-
[TASK] Improve service initialization efficiencyForse già presa @roberlander2 l’ha presa 212 giorni fa. Aperta
rokwire/app-flutter-plugin#692 · 1 assegnatario ·
-
[WEB] [BUG] Improve WEB accessibilityForse di nuovo libera @dobromirdobrev l’ha presa 285 giorni fa e non c’è nessuna pull request aperta. ApertaWEB
rokwire/app-flutter-plugin#663 · 1 assegnatario ·
-
[FEATURE] Load User info synchronouslyForse di nuovo libera @akshadpai l’ha presa 336 giorni fa e non c’è nessuna pull request aperta. Aperta
rokwire/app-flutter-plugin#656 · 1 assegnatario ·
-
[FEATURE] Quiz ArchiveForse di nuovo libera @bsdworkin l’ha presa 478 giorni fa e non c’è nessuna pull request aperta. Aperta
rokwire/app-flutter-plugin#624 · 1 assegnatario ·
Tutte le issue di rokwire/app-flutter-plugin
Issue simili
-
bug to check
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
MunichWays/munich-ways-app#275 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
jhomlala/betterplayer#1599 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
fluttercommunity/plus_plugins#4004 ·
I maintainer di solito rispondono entro 1 giorno