在Flutter中,IconButton 是一个常用的组件,用于显示一个图标作为按钮。然而,IconButton 本身并没有直接设置背景颜色的属性,因为它的设计初衷是使用图标的颜色来表示可交互性。不过,我们可以通过一些技巧来实现类似设置背景颜色的效果。 1. 理解Flutter IconButton 组件的基本属性 IconButton 主要有以下属性: icon:显示的...
Drop Down Button 按钮 Icon Button 图标按钮 Inkwell Button 墨水按钮 PopupMenu Button 弹出菜单按钮 Outline Button 轮廓按钮 Flat Button 扁平按钮ーー这是一个文本标签按钮,没有太多装饰,显示没有任何标高。平面按钮有两个必需的属性: ー child 和 onPress ()。默认情况下,平面按钮没有颜色,其文本为黑色。但是...
(//通过container 控制按钮大小height:60,width:200,child:ElevatedButton.icon(style:ButtonStyle(backgroundColor:MaterialStateProperty.all(Colors.red),//背景颜色foregroundColor:MaterialStateProperty.all(Colors.white),//文本颜色),onPressed:(){print("ElevatedButton.icon");},icon:constIcon(Icons.thumb_up,...
在接下来的章节中,我们将学习其他基本组件,如FlatButton和IconButton组件。 1.7 已弃用:推荐使用 TextButton 替代。 根据文档,FlatButton、RaisedButton 和 OutlineButton 已经分别被 TextButton、ElevatedButton 和 OutlinedButton 取代。ButtonTheme 也已经被 TextButtonTheme、ElevatedButtonTheme 和 OutlinedButtonTheme 取...
backgroundColor: Colors.red, leading: IconButton( icon: Icon(Icons.menu), tooltip:"Search", onPressed: () { print('menu Pressed'); }), title: Text('FlutterDemo'), actions:<Widget>[ IconButton( icon: Icon(Icons.search), tooltip:"Search", ...
FloatingActionButton(悬浮按钮) 属性 FloatingActionButton({ Key key,//按钮上的组件,可以是Text、icon, etc.this.child,//长按提示this.tooltip,//child的颜色(尽在child没有设置颜色时生效)this.foregroundColor,//背景色,也就是悬浮按键的颜色this.backgroundColor,this.heroTag =const_DefaultHeroTag(),//...
Flutter AppBar组件中的常见属性: import'package:flutter/material.dart';classAppBardemoPageextendsStatelessWidget{@overrideWidgetbuild(BuildContextcontext){returnScaffold(appBar:AppBar(backgroundColor:Colors.red,leading:IconButton(icon:Icon(Icons.menu),tooltip:"Search",onPressed:(){print('menu Pressed');...
all(8), child: FloatingActionButton( child: Icon(Icons.add), backgroundColor: this._currentIndex == 1? Colors.red : Colors.yellow, onPressed: (){ // print('点击 1'); setState(() { this._currentIndex=1; } ); } ) ), floatingActionButtonLocation: FloatingActionButtonLocation.center...
new IconButton( icon: ImageIcon(AssetImage("image/search.png")), onPressed: (){Navigator.push(context,newMaterialPageRoute(builder:(context)=>newSearch()),);}) ], backgroundColor: Colors.black, ), 样式.jpg appBar 添加按钮的时候,使用action去做处理 ...
// actions:通常使用 IconButton 来表示,也可以包含其他的按钮组。 // bottom:一般用于放置 tabBar,即在标题下面显示一个 Tab 导航栏。 // backgroundColor:导航背景颜色。 // iconTheme:用于定义图标样式。 // textTheme:用于定义文字样式。 // centerTitle:定义标题是否居中显示。