Flutter:如何修复并为轮廓按钮添加边框和颜色?

问题描述

谁能告诉我为什么我的代码没有将边框设为蓝色,并让它的宽度为 3.0?

这是它的样子(L:我的应用程序,R:教程应用程序):

enter image description here

代码

class CreateRoomButton extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return OutlinedButton(
      onpressed: () => print('Create Room'),style: ButtonStyle(
        shape: MaterialStateProperty.all<RoundedRectangleBorder>(
          RoundedRectangleBorder(
            side: BorderSide(
              color: Colors.blueAccent[100],width: 3.0,),borderRadius: BorderRadius.circular(30.0),child: Row(
        children: [
          ShaderMask(
            shadercallback: (rect) =>
                Palette.createRoomGradient.createShader(rect),child: Icon(
              Icons.video_call,color: Colors.white,size: 35.0,const SizedBox(width: 4.0),Text(
            'Create\nRoom',style: TextStyle(color: Colors.blueAccent[100]),],);
  }
}

此外,我必须在某处添加它(但由于 textColor 在 Flutter 2.0 中已贬值,因此我不知道如何处理它...):

textColor: Palette.facebookblue,

谢谢!

解决方法

只需将您的 OutlinedButton 更改为:

OutlinedButton(
    onPressed: () => print('Create Room'),style: OutlinedButton.styleFrom(
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(30.0),),side: BorderSide(width: 3.0,color: Colors.blueAccent[100]),)
    child: yourChildWidget,)
,

像这样,在孩子中你可以编写你的小部件

轮廓按钮( 样式: OutlinedButton.styleFrom( 侧面:BorderSide(颜色:Colors.teal), ),onPressed: () {},孩子:空, ),

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...