Flutter中FloatingActionButton的渐变背景

时间:2020-06-15 15:35:44

标签: flutter

是否可以将FAB的backgroundColor设置为渐变色而不是纯色?

我的按钮:

floatingActionButton: FloatingActionButton(
    backgroundColor: const Color(0xFFFF006E),
    child: const Icon(Icons.add, size: 40.0),
    onPressed: () {
        print('Start');
    },
),

3 个答案:

答案 0 :(得分:6)

希望这样做,

floatingActionButton: FloatingActionButton(
          child: Container(
            width: 60,
            height: 60,
            child: Icon(
              Icons.add,
              size: 40,
            ),
            decoration: BoxDecoration(
                shape: BoxShape.circle,
                gradient: LinearGradient(colors: [Colors.red, Colors.blue])),
          ),
          onPressed: () {},
        )

答案 1 :(得分:2)

使用可以将var condition = [{firstname:"mark"},{gender:"male"}]; jobs.user.find(condition) 与所需的渐变一起使用

Container

答案 2 :(得分:0)

我希望这会....

 FloatingActionButton(
    onPressed: () {},
      child: Container(
        height: 60,
        width: 60,
        decoration: BoxDecoration(
          shape: BoxShape.circle, 
          gradient: LinearGradient(
            colors: [
              Colors.teal,
              Colors.tealAcent
            ],
          ),
        ),
        child: Icon(
          Icons.add,
          color: Colors.white,
        ),
      ),
    )
相关问题