Flutter 如何创建主题大纲按钮?

Flutter 如何创建主题大纲按钮?,flutter,themes,Flutter,Themes,我尝试使用ButtonStyle,但出于某些原因,它要求MaterialStateProperty: outlinedButtonTheme: OutlinedButtonThemeData( style: ButtonStyle(backgroundColor: ... ) ), 从Flatter 1.20版开始,您可以按如下方式设置概述的按钮主题。请参阅下面的代码段 return MaterialApp( home: Home(), theme: ThemeD

我尝试使用ButtonStyle,但出于某些原因,它要求MaterialStateProperty:

outlinedButtonTheme: OutlinedButtonThemeData(
   style: ButtonStyle(backgroundColor: ... )
),

从Flatter 1.20版开始,您可以按如下方式设置概述的按钮主题。请参阅下面的代码段

return MaterialApp(
      home: Home(),
      theme: ThemeData.from(
        colorScheme: ColorScheme.light(),
      ).copyWith(
        outlinedButtonTheme: OutlinedButtonThemeData(
          style: OutlinedButton.styleFrom(
            primary: Colors.purple,
            backgroundColor: Colors.green,
          ),
        ),
      ),
    );