flutter - How to make a raised button that has a gradient background?

后端 未结 10 1667
野性不改
野性不改 2021-01-31 14:52

Is there a way to change the raised button background color to a gradient? if not, how can I achieve something like this?

10条回答
  •  孤独总比滥情好
    2021-01-31 15:59

    Refer Below -

    RaisedButton(
         onPressed: () {},
         textColor: Colors.white,
         padding: const EdgeInsets.all(0.0),
         shape:RoundedRectangleBorder(borderRadius: BorderRadius.circular(80.0)),
         child: Container(
           decoration: const BoxDecoration(
             gradient: LinearGradient(
               colors: [
                 Color(0xFF0D47A1),
                 Color(0xFF1976D2),
                 Color(0xFF42A5F5),
               ],
             ),
             borderRadius: BorderRadius.all(Radius.circular(80.0))
           ),
           padding: const EdgeInsets.fromLTRB(20, 10, 20, 10),
           child: const Text(
               'Gradient Button',
               style: TextStyle(fontSize: 20)
           ),
         ),
       )
    

提交回复
热议问题