我得到了一个错误:
'package:flutter/src/material/theme_data.dart': Failed assertion: line 412 pos 12: 'colorScheme?.brightness == null || brightness == null || colorScheme!.brightness == brightness': is not true.我使用了这个亮度: Brightness.dark参数作为我的暗模式,在最近的更新之前没有任何问题。我一次更新了几个东西,所以我不知道是什么引起了这个变化。我现在需要改变我的黑暗模式吗?
当前的黑暗主题:
darkTheme: ThemeData(
toggleableActiveColor: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
textTheme: _textTheme(),
colorScheme: ColorScheme.fromSwatch(primarySwatch: Colors.blue).copyWith(secondary: Colors.blueAccent),
brightness: Brightness.dark,
),发布于 2022-02-10 18:34:24
这是在颤振更新中收紧ThemeData构造器wrt、亮度参数和颜色方案亮度参数的结果。在你的例子中,ColorScheme的亮度是光的(默认的),但是ThemeData的亮度是暗的。
要使您的darkTheme正常工作,需要删除亮度参数并将其放入colorScheme中,如下所示:
darkTheme: ThemeData(
toggleableActiveColor: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
colorScheme: ColorScheme.fromSwatch(primarySwatch: Colors.blue)
.copyWith(
secondary: Colors.blueAccent, brightness: Brightness.dark),
),https://stackoverflow.com/questions/71069904
复制相似问题