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

海口网站建设优化公司杭州seo公司服务

海口网站建设优化公司,杭州seo公司服务,做网站哪里好,wordpress文章分页链接优化目录 前言 需求 实现 前言 最近闲着无聊学习了flutter的一下知识,发现flutter和安卓之间,页面开发的方式还是有较大的差异的,众所周知,android的页面开发都是写在xml文件中的,而flutter直接写在代码里(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});@overrideState<CustomTextButton> createState() => _CustomTextButtonState();
}class _CustomTextButtonState extends State<CustomTextButton> {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.ds6.com.cn/news/56308.html

相关文章:

  • 做外贸公司网站怎么做网络推广平台大全
  • 网站常用图标素材深圳百度百科
  • 太原seo计费管理厦门seo小谢
  • 网址查询网站名称第三方网络营销平台有哪些
  • 企业做网站很重要么手机优化管家
  • 网站建设标准流程及外包注意事项网络推广员是干嘛的
  • python微信网站开发网站建设报价
  • 企业网站建设哪家seo提升排名
  • 专业电商网站建设哪家好必应搜索引擎网址
  • 怎么做关不掉的网站一键优化大师
  • 衡阳网站建设icp备软件培训机构
  • 社科联网站建设方案策划书不知怎么入门
  • 校园网站建设平台百度指数怎么下载
  • wordpress文章接口北京seo公司华网白帽
  • 动态网站开发全程实例网络营销主要干什么
  • 网站栏目设置完整度建设河南网站建设哪里好
  • 做app网站的软件有哪些内容吗1688黄页大全进口
  • 如何做营销型网站360公司官网首页
  • 赣榆城乡建设局网站bt磁力天堂torrentkitty
  • 公众平台如何做网站进一步优化营商环境
  • 做代码的网站广告优化师怎么学
  • wordpress手动数据库优化seo技术交流论坛
  • 网站可以叫做系统吗推广普通话内容100字
  • 专门做销售招聘网站软文营销平台
  • wrodpress做学校网站百度指数的网址是什么
  • 大连网站制作推广搜索引擎简称seo
  • 网站配色技巧seo优化方式
  • phpcms v9 网站名称标签整站优化的公司
  • 产品经理如何做p2p网站改版seo要点
  • 网站seo诊断评分63爱链接外链购买