如何为 OutlinedButton 设计主题?

4

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

outlinedButtonTheme: OutlinedButtonThemeData(
   style: ButtonStyle(backgroundColor: ... )
),
1个回答

1

自Flutter 1.20版本以来,您可以按照以下方式设置轮廓按钮主题。请参考下面的代码片段。

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

为什么是-1?这个答案有效并解决了问题所问的内容。 - RobertoAllende

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接