码迷,mamicode.com
首页 > 其他好文 > 详细

[Flutter] Create a Customer widget

时间:2019-10-13 20:51:44      阅读:101      评论:0      收藏:0      [点我收藏+]

标签:ESS   learn   style   require   tac   creat   ++   int   ica   

For example, we want to have to button, looks similar to FloatingActionButton:

技术图片

But in the doc, it says to it is recommend to have only one floatingActionButton pre Application. 

So it is good idea to implement a similar one and learn how to build custom widget.

 

First thing first, since Flutter source code are very easy to read, we can check how FloatActionButton are implemented. 

Actually we can see it is implement as ‘RawMateriaButton‘.

 

class RoundIconButton extends StatelessWidget {
  RoundIconButton({@required this.icon, @required this.onPressed});

  final IconData icon;
  final Function onPressed;

  @override
  Widget build(BuildContext context) {
    return RawMaterialButton(
      child: Icon(icon),
      elevation: 6.0,
      onPressed: onPressed,
      shape: CircleBorder(),
      fillColor: Color(0XFF4C4F5E),
      constraints: BoxConstraints.tightFor(
        width: 56.0,
        height: 56.0,
      ),
    );
  }
}

 

Usage:

RoundIconButton(
  icon: FontAwesomeIcons.plus,
  onPressed: () {
    setState(() {
      age++;
    });
  },
),

 

[Flutter] Create a Customer widget

标签:ESS   learn   style   require   tac   creat   ++   int   ica   

原文地址:https://www.cnblogs.com/Answer1215/p/11667982.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!