当前位置: 首页 > news >正文

青岛专业网站开发公司wordpress设置固定链接伪静态

青岛专业网站开发公司,wordpress设置固定链接伪静态,十六局门户网登录,渭南网站建设服务flutter开发实战-实现自定义按钮类似UIButton效果 最近开发过程中需要实现一下UIButton效果的flutter按钮#xff0c;这里使用的是监听手势点击事件。 一、GestureDetector GestureDetector属性定义 GestureDetector({super.key,this.child,this.onTapDown,this.onTapUp,t…flutter开发实战-实现自定义按钮类似UIButton效果 最近开发过程中需要实现一下UIButton效果的flutter按钮这里使用的是监听手势点击事件。 一、GestureDetector GestureDetector属性定义 GestureDetector({super.key,this.child,this.onTapDown,this.onTapUp,this.onTap,this.onTapCancel,this.onSecondaryTap,this.onSecondaryTapDown,this.onSecondaryTapUp,this.onSecondaryTapCancel,this.onTertiaryTapDown,this.onTertiaryTapUp,this.onTertiaryTapCancel,this.onDoubleTapDown,this.onDoubleTap,this.onDoubleTapCancel,this.onLongPressDown,this.onLongPressCancel,this.onLongPress,this.onLongPressStart, ...由于属性太多我们实现onTapDown、onTapUp、onTapCancel、onTap。 二、实现flutter自定义按钮 实现自定义按钮类似我们实现onTapDown、onTapUp、onTapCancel、onTap这几个方法 return GestureDetector(onTapDown: handleTapDown,// 处理按下事件onTapUp: handleTapUp,// 处理抬起事件onTap: handleTap,onTapCancel: handleTapCancel, }void handleTapDown(TapDownDetails details) {if (widget.enabled ! null widget.enabled true) {setState(() {_highlighted true;});}}void handleTapUp(TapUpDetails details) {setState(() {_highlighted false;});}void handleTapCancel() {setState(() {_highlighted false;});}void handleTap() {if (widget.enabled ! null widget.enabled true) {setState(() {_highlighted true;});Future.delayed(Duration(milliseconds: 100), () {if (mounted) {setState(() {_highlighted false;});}});if (widget.enabled ! null widget.enabled true) {widget.onPressed();}}}完整代码如下 import package:flutter/material.dart; import package:flutter/cupertino.dart;//枚举类的声明 enum ButtonAlignment { Center, Left, Right }class ButtonWidget extends StatefulWidget {const ButtonWidget({Key? key,this.bgColor,this.bgHighlightedColor,this.color,this.highlightedColor,this.disableColor,this.bgDisableColor,this.width,this.height,this.borderRadius,this.buttonAlignment: ButtonAlignment.Center,this.text: ,this.textFontSize,this.icon,this.iconTextPadding,required this.onPressed,this.enabled true,required this.child,this.border,this.padding,}) : super(key: key);final Color? bgColor; // 背景颜色final Color? bgHighlightedColor; // 背景点击高亮颜色final Color? color;final Color? highlightedColor;final Color? disableColor;final Color? bgDisableColor;final double? width;final double? height;final VoidCallback onPressed;final double? borderRadius;final ButtonAlignment? buttonAlignment;final String? text;final double? textFontSize;final Icon? icon;final double? iconTextPadding;final bool? enabled;final Widget child;final Border? border;final EdgeInsetsGeometry? padding;override_ButtonWidgetState createState() _ButtonWidgetState(); }class _ButtonWidgetState extends StateButtonWidget {bool _highlighted false;overridevoid initState() {// TODO: implement initStatesuper.initState();_highlighted false;}void handleTapDown(TapDownDetails details) {if (widget.enabled ! null widget.enabled true) {setState(() {_highlighted true;});}}void handleTapUp(TapUpDetails details) {setState(() {_highlighted false;});}void handleTapCancel() {setState(() {_highlighted false;});}void handleTap() {if (widget.enabled ! null widget.enabled true) {setState(() {_highlighted true;});Future.delayed(Duration(milliseconds: 100), () {if (mounted) {setState(() {_highlighted false;});}});if (widget.enabled ! null widget.enabled true) {widget.onPressed();}}}AlignmentGeometry showAlignment(ButtonAlignment? buttonAlignment) {AlignmentGeometry alignment Alignment.center;if (buttonAlignment ! null) {if (buttonAlignment ButtonAlignment.Left) {alignment Alignment.centerLeft;} else if (buttonAlignment ButtonAlignment.Right) {alignment Alignment.centerRight;} else {alignment Alignment.center;}}return alignment;}overrideWidget build(BuildContext context) {return GestureDetector(onTapDown: handleTapDown,// 处理按下事件onTapUp: handleTapUp,// 处理抬起事件onTap: handleTap,onTapCancel: handleTapCancel,child: Container(padding: widget.padding,width: widget.width,height: widget.height,alignment: showAlignment(widget.buttonAlignment),decoration: BoxDecoration(color: boxDecorationBgColor(),borderRadius: BorderRadius.circular(widget.borderRadius ?? 0),border: widget.border),child: widget.child,),);}Color? boxDecorationBgColor() {if (widget.enabled ! null widget.enabled true) {return (_highlighted ? widget.bgHighlightedColor : widget.bgColor);}return widget.bgDisableColor ?? widget.bgColor;}Color? textColor() {if (widget.enabled ! null widget.enabled true) {return (_highlighted ? widget.highlightedColor : widget.color);}return widget.disableColor ?? widget.bgColor;} }三、小结 flutter开发实战-实现自定义按钮类似UIButton效果通过监听手势GestureDetector的onTapDown、onTapUp、onTapCancel、onTap来实现按下背景变换松开背景恢复默认等效果。 学习记录每天不停进步。
http://www.dnsts.com.cn/news/69715.html

相关文章:

  • 域名注册好了怎么样做网站云开发和普通开发区别
  • 涞水网站建设深圳华强北今晚
  • 青岛网站建设电话东莞大朗网站建设哪家口碑好
  • 网站开发图形化软件wordpress 小工具居中
  • 网站制作与免费网站建设中国建行官方网站
  • 金本网站建设设计网站链接推广怎么做
  • 网站seo分析案例博物馆网站建设策划书
  • 深圳 网站建设设计软件开发制作公司
  • php网站开发实例教程源码网页制作教程视频教学
  • 搭建什么网站好玩3d建模一般学多久
  • 微网站建设定制网站建设公司取名软件
  • 软件库网站大全做企业网站那家好
  • 环艺做网站沐风wordpress
  • 组织网站建设应该注意什么手机网站域名m打头
  • 帝国网站seowordpress怎样给目录增加
  • 策划与设计一个电子商务网站做公司网站需要哪些资料
  • 做电影下载网站需要什么软件巨省网站
  • 常州网站制作策划品牌手机网站开发
  • 机械网站建设案例分类信息免费发布大全
  • 全国设计网站公司app软件小程序网站建设
  • 淘宝单页面网站简单分析网站的外链 以及优化的策略.
  • 做一个企业网站需要多长时间wordpress 新浪图片
  • 专业做网站流程常州市做网站的公司
  • 网站排名软件推荐太原工程建设信息网站
  • 广安门内网站建设名片设计模板
  • 网站收录查询工具财务软件做账流程
  • 全屏网站怎么做的新浪网站怎么做推广
  • 网站优化标题不超过多少个字符网站建设神器
  • vps设置网站访问用户权限网页设计代码动漫
  • 河北住房与建设信息网站wordpress前端ajax登录 注册