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

企业网站建设合同书盖章页5118网站如何使用免费版

企业网站建设合同书盖章页,5118网站如何使用免费版,镇江详情设计,网站开发工作介绍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.pierceye.com/news/484588/

相关文章:

  • 西安大网站建设公司排名沈阳网络维护公司
  • 个人建立一个网站要多少钱乔拓云h5制作
  • 蒙阴网站建设百度指数排名
  • 视频网站如何推广做模具做什么网站
  • 关于旅游的网站建设论文广州外贸网站建设公司价格
  • 怎么给自己制作一个网站wordpress 中文摘要
  • 如何看网站的ftp服装网站建设策划书3000字
  • 无锡网站建设 网站制作常见的网站首页布局有哪几种
  • 网站研发PHP MYSQL网站开发全程实
  • 简约型网站国外做电商平台的网站还有什么
  • 云南昆明网站建设公司jsp网站开发详解下载
  • 上海h5网站开发网站建设在开封找谁做
  • 滨海建设局官方网站营销网络平台
  • 中国小康建设网是骗子网站吗?建设宁波市分行的互联网网站
  • 制造网站建设自己做游戏资讯网站
  • 网站建设质量如何衡量都江堰网站开发
  • 企业网站设计步骤中山制作网站的公司
  • 通化网站制作企信网官网查询入口
  • 无锡装修网站百科网站推广
  • 先做网站后付款怎么做网站弹窗通知
  • php做网站的分站学校网站开发价格
  • 静态动漫网站模板个人网站空间大小
  • 个人网站 如何做推广拓者设计吧官方网站
  • 农产品电子商务网站建设要求开发一款app软件需要多少钱
  • 仿微博网站模板织梦网站地图怎么做xml
  • 什么网站能买建设摩托车产品推广计划方案
  • 建设局网站买卖合同大连 商城网站制作公司
  • 网站开发实训意义湖州网站设计
  • 网站后台设置企业为什么要网站建设
  • 外贸网站推广平台有哪些怎么在亚马逊上开店铺