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

温岭市溪建设局网站芯片设计公司

温岭市溪建设局网站,芯片设计公司,网页游戏平台代理,网站建设用net后缀如何目录 前言 需求 实现 前言 最近闲着无聊学习了flutter的一下知识#xff0c;发现flutter和安卓之间#xff0c;页面开发的方式还是有较大的差异的#xff0c;众所周知#xff0c;android的页面开发都是写在xml文件中的#xff0c;而flutter直接写在代码里#xff08;da…目录 前言 需求 实现 前言 最近闲着无聊学习了flutter的一下知识发现flutter和安卓之间页面开发的方式还是有较大的差异的众所周知android的页面开发都是写在xml文件中的而flutter直接写在代码里dart文件中从目前我的认识来看两者在UI上的“套娃”方式flutter更能套简直就是“套中套”啊哈哈。比如今天的手写一个最简单的自定义按钮吧效果如下图所示 需求 带文本的普通按钮可修改字体大小和字体颜色提供修改背景色按下后的背景色支持支持圆角和边框提供点击事件的回调 这几个需求还是毕竟常用的目前没考虑渐变色和图标具体需求具体改吧 实现 本次demo的代码本身属于练手相当于flutter的hello world(毕竟我才刚了解flutter没几天。 以下是具体的代码实现 import package:flutter/material.dart;class CustomTextButton extends StatefulWidget {//按钮的宽度final double? width;//按钮的长度final double? height;final String text;final double? textSize;final Color textColor;final Color backgroundColor;final Color pressedBackgroundColor;final VoidCallback onClick;final double borderRadius;final Color borderColor;const CustomTextButton({super.key,required this.onClick,required this.text,this.textSize 16,this.width double.infinity,required this.height,this.backgroundColor Colors.white,this.pressedBackgroundColor Colors.white,this.borderRadius 0.0,this.borderColor Colors.white,this.textColor Colors.black});overrideStateCustomTextButton createState() _CustomTextButtonState(); }class _CustomTextButtonState extends StateCustomTextButton {bool _isPressed false;overrideWidget build(BuildContext context) {return ConstrainedBox(constraints:BoxConstraints.expand(width: widget.width, height: widget.height),child: GestureDetector(onTap: () {widget.onClick();},onTapDown: (details) {setState(() {_isPressed true;});},onTapUp: (details) {setState(() {_isPressed false;});},child: Container(alignment: Alignment.center,decoration: BoxDecoration(color: _isPressed? widget.pressedBackgroundColor: widget.backgroundColor,borderRadius: BorderRadius.circular(widget.borderRadius),border: Border.fromBorderSide(BorderSide(width: 1, color: widget.borderColor))),child: Text(widget.text,maxLines: 1,overflow: TextOverflow.ellipsis,style: TextStyle(color: widget.textColor,fontSize: widget.textSize,fontStyle: FontStyle.normal,),),),),);} }extension HexColor on Color {/// String is in the format aabbcc or ffaabbcc with an optional leading #.static Color fromHex(String hexString) {final buffer StringBuffer();if (hexString.length 6 || hexString.length 7) buffer.write(ff);buffer.write(hexString.replaceFirst(#, ));return Color(int.parse(buffer.toString(), radix: 16));}}代码演示如何使用这个还是非常简单易懂的有什么需要改进的地方也请大佬指示改进。 Container(margin: const EdgeInsets.only(left: 20, right: 20),child: CustomTextButton(text: 注册,textSize: 18,textColor: Colors.white,backgroundColor: HexColor.fromHex(F9AC00),pressedBackgroundColor: HexColor.fromHex(E0CE32),height: 44,borderRadius: 30,onClick: () {Fluttertoast.showToast(msg: 您按了注册,toastLength: Toast.LENGTH_SHORT,gravity: ToastGravity.BOTTOM,timeInSecForIosWeb: 1,backgroundColor: Colors.black12,textColor: Colors.black,fontSize: 14.0);},),),
http://www.w-s-a.com/news/418599/

相关文章:

  • vs 团队网站开发中铁建设门户网登录咋进不去了
  • 快速网站建设公司哪家好优秀的网站建设
  • 网站开发的自适应wordpress搜索词结果按文章标题
  • 微网站是用什么开发的wordpress中英文主题
  • 纯静态网站怎么做淄博seo开发
  • 江西新农村建设权威网站盐步网站制作
  • 网站ui设计例子怎么做打鱼网站
  • 在1688做公司网站wordpress category
  • 单页面 网站 模板网站代理公司
  • 手机网站底部电话代码网站后台点击添加图片没有反应
  • 龙岩建设局网站声明自学制作网站难不难
  • 济南网站优化小黑godaddy中文网站开发
  • 做微课常用的网站广州seo优化推广
  • 主机屋如何做网站电脑网页游戏大全
  • 工作网站建设中布线费用账务处理特色的重庆网站推广
  • dede 网站地图模板htm写作网站水平哪个最好
  • 服务器上的网站erp教学零基础入门
  • 网站建设58设计资料网站
  • 如何把动态图发网站做头像网页设计实训报告小结
  • 做简历用的网站wordpress版权说明
  • 网站关键词有哪些网站新闻前置审批
  • 怎么自己注册网站义乌做公司网站
  • 做哪种网站赚钱苏州住房城乡建设部网站
  • 镇江做网站学编程学哪一种比较好
  • 华美天一建筑公司网站赚钱做任务的网站有哪些
  • asp网站打开速度慢家乡网页设计教程
  • 网站 设计 深圳书店网站的建设
  • 北京网络营销推广培训哪家好南宁软件优化网站建设
  • flash网站引导页仓库管理系统源码
  • 济南网站制作公司排名营销型网站管理系统