Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Wrong theme applied on first app launch until backgrounded

Đang mở Phù hợp với người mới
#699 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

@akshadpai đang làm issue này rồi.

Từ ngày 12/6/2026.

  • #700 của @akshadpai — đang mở

Đá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
Công nghệ
dart, flutter
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

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của rokwire/app-flutter-plugin

Tất cả issue của rokwire/app-flutter-plugin

Issue tương tự

Thêm issue về Dart

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.