Outlined transparent button with gradient border in flutter

后端 未结 3 1653
情歌与酒
情歌与酒 2021-02-02 00:11

Is it possible to create an outlined(transparent) button with gradient border in flutter? I tried to use LinearGradient in BorderSide style but it\'s not allowed.

3条回答
  •  深忆病人
    2021-02-02 00:58

    To change the size, you can insert a Container:

    OutlineGradientButton(
      child: Container(
        constraints: BoxConstraints(maxWidth: 300, maxHeight: 50),
        height: 50,
        alignment: Alignment.center,
        child: Text(
          'Text',
          textAlign: TextAlign.center,
          style: TextStyle(
              color: Colors.white, fontSize: 20, fontWeight: FontWeight.w500),
        ),
      ),
      gradient: LinearGradient(
        colors: [Color(0xfff3628b), Color(0xffec3470)],
        begin: Alignment.topCenter,
        end: Alignment.bottomCenter,
      ),
      strokeWidth: 3,
      radius: Radius.circular(25),
    ),
    

提交回复
热议问题