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

公司做网站多少钱在线seo

公司做网站多少钱,在线seo,网站优化 月付费,软件制作过程flutter开发实战-实现marquee文本跑马灯效果 最近开发过程中需要marquee文本跑马灯效果,这里使用到了flutter的插件marquee 效果图如下 一、marquee 1.1 引入marquee 在pubspec.yaml中引入marquee # 跑马灯效果marquee: ^2.2.31.2 marquee使用 marquee使用也是…

flutter开发实战-实现marquee文本跑马灯效果

最近开发过程中需要marquee文本跑马灯效果,这里使用到了flutter的插件marquee

效果图如下
在这里插入图片描述

在这里插入图片描述

一、marquee

1.1 引入marquee

在pubspec.yaml中引入marquee

  # 跑马灯效果marquee: ^2.2.3

1.2 marquee使用

marquee使用也是非常方便的。比如直接指定文本text

Marquee(text: 'flutter开发实战-实现marquee文本跑马灯效果',
)

或者设置更多属性值

Marquee(// 文本text: '实现marquee文本跑马灯效果,这里是一传长文本',// 文本样式style: TextStyle(fontWeight: FontWeight.bold),// 滚动轴:水平或者竖直scrollAxis: Axis.horizontal,// 轴对齐方式startcrossAxisAlignment: CrossAxisAlignment.start,// 空白间距blankSpace: 20.0,// 速度velocity: 100.0,// 暂停时长pauseAfterRound: Duration(seconds: 1),// startPaddingstartPadding: 10.0,// 加速时长accelerationDuration: Duration(seconds: 1),// 加速CurveaccelerationCurve: Curves.linear,// 减速时长decelerationDuration: Duration(milliseconds: 500),// 减速CurvedecelerationCurve: Curves.easeOut,
)

二、根据文本宽度是否需要跑马灯效果

根据Text文本的大小判断是否需要进行显示跑马灯效果,获取文本的大小,需要TextPainter来获取Size
TextPainter查看:https://blog.csdn.net/gloryFlow/article/details/132198113

2.1 根据获取的文本宽度确定是否显示跑马灯效果

判断计算的文本宽度是否超出指定的ContainerWidth,来确定是否显示Marquee

代码如下

import 'package:flutter/material.dart';
import 'package:marquee/marquee.dart';typedef MarqueeBuilder = Marquee Function(BuildContext context, String text, TextStyle textStyle);
typedef TextBuilder = Text Function(BuildContext context, String text, TextStyle textStyle);class MarqueeText extends StatelessWidget {final String text;final TextStyle textStyle;final double containerWidth;final TextBuilder textBuilder;final MarqueeBuilder marqueeBuilder;const MarqueeText({Key? key,required this.marqueeBuilder,required this.textBuilder,required this.text,required this.textStyle,required this.containerWidth}): super(key: key);Size calculateTextSize(String text, TextStyle style) {final TextPainter textPainter = TextPainter(text: TextSpan(text: text, style: style),maxLines: 1,textDirection: TextDirection.ltr)..layout(minWidth: 0, maxWidth: double.infinity);return textPainter.size;}Widget build(BuildContext context) {final textWidth = this.calculateTextSize(this.text, this.textStyle).width;return textWidth < this.containerWidth? this.textBuilder(context, text, textStyle): this.marqueeBuilder(context, text, textStyle);}
}

2.2 使用该自定义的Widget

下面我这里使用这个跑马灯的Widget
代码如下

Container(width: size.width,height: size.height,alignment: Alignment.center,color: Colors.greenAccent,// child: LoadingWidget(bgColor: Colors.blueGrey,),child: MarqueeText(containerWidth: 300,text: "如果你不相信努力和时光,那么时光第一个就会辜负你。不是因为有希望才去努力,而是努力了,才能看到希望。",textStyle: TextStyle(fontSize: 25,fontWeight: FontWeight.w400,fontStyle: FontStyle.normal,color: Colors.redAccent,decoration: TextDecoration.none,),marqueeBuilder: (context, text, textStyle) => Marquee(text: text,style: textStyle,scrollAxis: Axis.horizontal,crossAxisAlignment: CrossAxisAlignment.start,blankSpace: 20.0,velocity: 100.0,pauseAfterRound: Duration(milliseconds: 500),showFadingOnlyWhenScrolling: true,fadingEdgeStartFraction: 0.1,fadingEdgeEndFraction: 0.1,startPadding: 10.0,accelerationDuration: Duration(milliseconds: 100),accelerationCurve: Curves.linear,decelerationDuration: Duration(milliseconds: 100),decelerationCurve: Curves.easeOut,textDirection: TextDirection.ltr,),textBuilder: (context, text, textStyle) => Text(text,style: textStyle,),),),

三、小结

flutter开发实战-实现marquee根据文本长度显示文本跑马灯效果。通过TextPainter计算文本内容的宽度与ContainerWidth进行对比确定是否需要显示marquee。
学习记录,每天不停进步。

http://www.hkea.cn/news/184886/

相关文章:

  • 乐从网站建设公司北京seo优化推广
  • 如何在网上接做网站的小项目市场监督管理局电话
  • 淘宝购物站优化
  • 石家庄最新疫情轨迹河南网站优化公司哪家好
  • 网站色彩搭配服务器ip域名解析
  • 哪个网站专业做安防如何注册域名网站
  • 穆棱市住房和城乡建设局网站关键词词库
  • 成都网站建设市场什么是网络营销的核心
  • 深圳找人做网站廊坊优化外包
  • 衡阳市城市建设投资有限公司网站湖南企业seo优化报价
  • css做网站常用百度权重优化软件
  • 合合肥网站建设制作网站用什么软件
  • 杭州网站设计公司推荐网络推广与优化
  • 移动惠生活app下载网址荆门网站seo
  • 做网站很赚钱吗关键词自助优化
  • wordpress小工具里的用户中心南京谷歌优化
  • 网站开发中茶叶网络营销策划方案
  • 临海市住房与城乡建设规划局 网站目前最新的营销模式有哪些
  • 高校建设网站的特色如何建立一个网站
  • 公司做网站域名归谁搜索引擎营销策划方案
  • 怎么做外贸个人网站seo综合查询工具可以查看哪些数据
  • 黑客网站盗qq百度seo公司整站优化
  • 网页设计代码不能运行seo的中文名是什么
  • 灵溪网站建设外贸网站谷歌seo
  • 网站开发系统设计产品推销
  • 不用代码做网站 知乎百度引流推广怎么收费
  • 怎么看网站后台什么语言做的产品全网营销推广
  • 可以做宣传图的网站网络销售管理条例
  • 做书籍封皮的网站制作网站平台
  • 1网站建设公司长沙网站到首页排名