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

后端 未结 10 1655
野性不改
野性不改 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:42

    Docs last example https://api.flutter.dev/flutter/material/RaisedButton-class.html

    RaisedButton(
      onPressed: () {},
      textColor: Colors.white,
      padding: const EdgeInsets.all(0.0),
      child: Container(
        decoration: const BoxDecoration(
          gradient: LinearGradient(
            colors: [
              Color(0xFF0D47A1),
              Color(0xFF1976D2),
              Color(0xFF42A5F5),
            ],
          ),
        ),
        padding: const EdgeInsets.all(10.0),
        child: const Text(
          'Gradient Button',
          style: TextStyle(fontSize: 20)
        ),
      ),
    );
    

提交回复
热议问题