2.3.0
Introduce changes in #7 , which provides ability for app for Windows to react with system accent color changes.
It should be an awesome updates, but, a mistake was made there. As per #28 mentioned, while trying to stream the accent color, cause LateInitializationError
.
Beyond that, it actually break release build of other platform (At least Web
and Android
are breaking). For debug build, it works fine with console error, but all things works. However, in a release build,
this error can break the whole initialization phase and result a blank app without anything. It also makes web build hang up and finally being marked as no respond.
If I understand correctly:
|
static final SystemAccentColor accentColor = SystemAccentColor(fallbackColor) |
|
..load(); |
Here, try to initialize final variable
SystemTheme.accentColor
with
SystemAccentColor(fallbackColor)..load()
. During the
load()
,
|
/// Updates the fetched accent colors on Windows. |
|
Future<void> load() async { |
|
WidgetsFlutterBinding.ensureInitialized(); |
|
|
|
_subscription = SystemTheme.onChange.listen((color) { |
|
accent = color.accent; |
|
light = color.light; |
|
lighter = color.lighter; |
|
lightest = color.lightest; |
|
dark = color.dark; |
|
darker = color.darker; |
|
darkest = color.darkest; |
|
}); |
SystemTheme.onChange
getter was called, and it
return Stream.value(accentColor)
on platform other than Windows.
|
static Stream<SystemAccentColor> get onChange { |
|
if (kIsWeb || !Platform.isWindows) return Stream.value(accentColor); |
|
|
|
return _eventChannel.receiveBroadcastStream().map((event) { |
|
return SystemAccentColor._fromMap(event); |
|
}).distinct(); |
|
} |
The variable
accentColor
should be evaluate immediately, and it actually means
SystemTheme.accentColor
, which is still initializing. Then cause
LateInitializationError
.
Here's my current investigation report. I'm not sure why it will make web build no respond as it should be failed or crash at start time, there may be other deeper issue.