I'm writing a Flutter app for Android and iOS which will change its style/theme based on iOS' Dark Mode status.
Is there currently anything like a MediaQuery.isDarkModeEnabled in Flutter?
There is a GitHub issue open here but the Flutter team must be overwhelmed in issues so I can't see this being implemented too soon.
I can use 'traitCollection.userInterfaceStyle' from iOS-specific code channels, but adding platform-specific code for Flutter/Dart apps is not something I'm experienced in. Currently working on this solution!
For example, someone could have a CupertinoPicker
with adaptive colors:
CupertinoPicker(
backgroundColor: isDarkModeEnabled ? Colors.black : Colors.white,
children: items.map((thisItem) => Text(thisItem.name)).toList(),
itemExtent: 32,
onSelectedItemChanged: (newItem) {
setState(() => this.item = items[newItem]);
}
)