Composition vs. Inheritance - Building Flutter Widgets From Scratch

 

[Ko]

 - Floating Action Button 만들어진 code 보면 RawMaterialButton 기초로 만들어진 것을 확인할 있음.

 - RawMaterialButton 이용해서 우리만의 custom button 만들어서 사용해보자.(+ 버큰 제작)

 

[En]

 - If you look at the code created by Floating Action Button, you can see that it was created based on RawMaterialButton.
 -Let's make and use our own custom button using RawMaterialButton.

 

 - final code

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),

      onPressed: onPressed,

      elevation: 6.0,

      constraints: BoxConstraints.tightFor(

        width: 56.0,

        height: 56.0,

      ),

//      shape: CircleBorder(),

      shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10.0)),

      fillColor: Color(0xFF4C4F5E),

    );

  }

}

'플러터(Flutter) > 플러터 일반(Flutter General)' 카테고리의 다른 글

JSON Parsing and Dynamic Types  (0) 2020.03.19
Lifecycle method of Stateful widget  (0) 2020.03.19
Extract widget and Key  (0) 2020.03.19
Flutter Themes, Theme widget, ThemeData  (0) 2020.03.19
Colorzilla  (0) 2020.03.19

+ Recent posts