看效果
代码:
class _CListTile extends StatefulWidget {
_CListTile(
{Key key,
this.text,
this.textColor: Colors.black,
this.textHighLightColor: const Color(0xff25C78A),
this.leadingIconPath,
this.leadingHighLightIconPath,
@required this.onTab})
: super(key: key);
final Function onTab;
final String text;
final Color textColor;
final Color textHighLightColor;
final String leadingIconPath;
final String leadingHighLightIconPath;
_CListTileState createState() => _CListTileState();
}
class _CListTileState extends State<_CListTile> {
bool _highlight = false;
void _handleTapDown(TapDownDetails details) {
setState(() {
_highlight = true;
});
}
void _handleTapUp(TapUpDetails details) {
setState(() {
_highlight = false;
});
}
void _handleTapCancel() {
setState(() {
_highlight = false;
});
}
void _handleTap() {
widget.onTab();
}
Widget build(BuildContext context) {
return GestureDetector(
onTapDown: _handleTapDown,
onTapUp: _handleTapUp,
onTap: _handleTap,
onTapCancel: _handleTapCancel,
child: Container(
height: 52,
child: Material(
child: InkWell(
onTap: (){
if(widget.onTab != null) {
widget.onTab();
}
},
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Padding(padding: EdgeInsets.only(left: 16)),
_highlight
? Image.asset(widget.leadingHighLightIconPath, width: 25)
: Image.asset(widget.leadingIconPath, width: 25),
Padding(padding: EdgeInsets.only(left: 15)),
Text(widget.text,
style: TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.w600,
color: _highlight
? widget.textHighLightColor
: widget.textColor)),
],
),
),
)
),
);
}
}
使用的地方
_CListTile(
text: "test title",
leadingIconPath: "images/test.png",
leadingHighLightIconPath: "images/test1.png",
onTab: () {
print("test");
}),
热度: 16
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
WebKit技术内幕
朱永盛 / 电子工业出版社 / 2014-6 / 79.00元
《WebKit技术内幕》从炙手可热的HTML5 的基础知识入手,重点阐述目前应用最广的渲染引擎项目——WebKit。不仅着眼于系统描述WebKit 内部渲染HTML 网页的原理,并基于Chromium 的实现,阐明渲染引擎如何高效地利用硬件和最新技术,而且试图通过对原理的剖析,向读者传授实现高性能Web 前端开发所需的宝贵经验。 《WebKit技术内幕》首先从总体上描述WebKit 架构和组......一起来看看 《WebKit技术内幕》 这本书的介绍吧!