Flutter 06

Button And Icons
In Flutter we can add Button and Icon Widget as well.

Icons

  body: Center( //LOCATED IN THE MIDDLE    child: Icon(      Icons.add_circle_outline    ),    ),

In body, we insert a widget called Icon with the shapeadd_circle_outline.
(Different Icon Shape can be checked here.)


We can add different properties as well. (colors, size, etc.)

   child: Icon(      Icons.add_circle_outline,      color: Colors.red,      size: 50.0,

Buttons
Button are like icons with functionality.
body: Center( //LOCATED IN THE MIDDLEchild: RaisedButton(  onPressed: (){},  child: Text('click me'),    color: Colors.lightBlue,),),

It’s important to include onPressed: (){} even it doesn’t have any function, or else an error will occur.

We can insert some action in the parenthesis{} in onPressed: to add some functionality. In this example, we print a string ‘You clicked me!’ whenever the button was clicked.

body: Center( //LOCATED IN THE MIDDLEchild: RaisedButton(  onPressed: (){    print('you clicked me!');  },  child: Text('click me'),    color: Colors.lightBlue,),),


关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章