zoukankan      html  css  js  c++  java
  • [Flutter] Create a Customer widget

    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(
             56.0,
            height: 56.0,
          ),
        );
      }
    }

    Usage:

    RoundIconButton(
      icon: FontAwesomeIcons.plus,
      onPressed: () {
        setState(() {
          age++;
        });
      },
    ),
  • 相关阅读:
    L1-046. 整除光棍
    判断素数
    L1-025. 正整数A+B
    L1-023. 输出GPLT
    L1-020. 帅到没朋友
    L1-016. 查验身份证
    L1-011. A-B
    UVa 400 Unix Is命令
    Uva 136 丑数
    The Preliminary Contest for ICPC Asia Xuzhou 2019 K. Center
  • 原文地址:https://www.cnblogs.com/Answer1215/p/11667982.html
Copyright © 2011-2022 走看看