首先你需要在“MaterialApp”设置两套theme
MaterialApp( theme: myTheme, // light darkTheme: ThemeData.dark(), // dark );
在widget中你需要这样判断
final isDark = MediaQuery.of(context).platformBrightness == Brightness.dark;