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++;
        });
      },
    ),
  • 相关阅读:
    webpack打包踩坑记录
    node笔记
    你真的会Xilinx FPGA的复位吗?
    Verilog 99题之001-009
    数字电路基础
    跨时钟域处理
    时序逻辑电路基础
    FPGA&ASIC基本开发流程
    关于FPGA的一些小见解
    基于FPGA的I2C读写EEPROM
  • 原文地址:https://www.cnblogs.com/Answer1215/p/11667982.html
Copyright © 2011-2022 走看看