Wrong theme applied on first app launch until backgrounded
Đánh giá
- Độ khó
- 1/5
- Thời gian dự kiến
- Dưới một giờ
- Mức phù hợp với người mới
- 86/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Lĩnh vực
- mobile-dev
Hướng nghiên cứu
Bắt đầu trong lib/service/styles.dart tại Styles._getSelectedTheme() và theo dõi luồng khởi chạy lần đầu khi Storage().selectedTheme là null. Đảm bảo theme hệ thống mặc định có sẵn cho lựa chọn cục bộ trước khi phân giải, sau đó xác minh rằng một bản cài đặt mới sẽ chọn theme sáng hoặc tối của thiết bị mà không đưa ứng dụng xuống nền.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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;
}
- Ngôn ngữ chính
- Dart
- Star
- 3
- Fork
- 4
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của rokwire/app-flutter-plugin
-
[TASK] Investigate crash after login on iOSCó thể đã có người làm @roberlander2 đã nhận 148 ngày trước. Đang mở
rokwire/app-flutter-plugin#696 · 1 người được giao ·
-
[TASK] Improve service initialization efficiencyCó thể đã có người làm @roberlander2 đã nhận 212 ngày trước. Đang mở
rokwire/app-flutter-plugin#692 · 1 người được giao ·
-
[WEB] [BUG] Improve WEB accessibilityCó thể làm lại được @dobromirdobrev đã nhận 285 ngày trước và không có pull request nào đang mở. Đang mởWEB
rokwire/app-flutter-plugin#663 · 1 người được giao ·
-
[FEATURE] Load User info synchronouslyCó thể làm lại được @akshadpai đã nhận 336 ngày trước và không có pull request nào đang mở. Đang mở
rokwire/app-flutter-plugin#656 · 1 người được giao ·
-
[FEATURE] Quiz ArchiveCó thể làm lại được @bsdworkin đã nhận 478 ngày trước và không có pull request nào đang mở. Đang mở
rokwire/app-flutter-plugin#624 · 1 người được giao ·
Tất cả issue của rokwire/app-flutter-plugin
Issue tương tự
-
bug to check
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
MunichWays/munich-ways-app#275 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
jhomlala/betterplayer#1599 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
fluttercommunity/plus_plugins#4004 ·
Maintainer thường phản hồi trong vòng 1 ngày