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

创建空白网站北京有限公司公章图片

创建空白网站,北京有限公司公章图片,曲阜网站建设价格,ghost hexo WordPress前言: 之前一直看到 有手机充电的时候 有气泡从Type-C 的位置冒泡上来 慢慢上移, 然后和上面的圆圈 会和,感觉还是挺好看的。今天试了下用 Flutter 实现了一版本。大致效果如下,而且气泡 和 气泡直接还可以粘黏 实现原理&#xff…

前言:

之前一直看到 有手机充电的时候 有气泡从Type-C 的位置冒泡上来 慢慢上移, 然后和上面的圆圈 会和,感觉还是挺好看的。今天试了下用 Flutter 实现了一版本。大致效果如下,而且气泡 和 气泡直接还可以粘黏

 实现原理:

大致的布局就是这样的: Stack 包裹住所有的元素,需要位置移动的是 AnimatedBuilder,这里是把他们独立出来,方便随机的时候打散处理。

代码实现:

  • PageBubble.dart 整个页面 气泡的粘连效果 有点吃性能
    import 'dart:math';
    import 'dart:ui';import 'package:flutter/material.dart';
    import 'package:untitled1a/pages/example1/bubble_dot.dart';class PageBubble extends StatefulWidget {const PageBubble({Key? key}) : super(key: key);@overrideState<PageBubble> createState() => _PageBubbleState();
    }class _PageBubbleState extends State<PageBubble>with SingleTickerProviderStateMixin {late AnimationController _animationController;final Random random = Random();@overridevoid initState() {_animationController = AnimationController(vsync: this,duration: const Duration(milliseconds: 2500),);_animationController.repeat();super.initState();}@overridevoid dispose() {_animationController.dispose();// TODO: implement disposesuper.dispose();}@overrideWidget build(BuildContext context) {return Scaffold(appBar: AppBar(backgroundColor: Theme.of(context).colorScheme.inversePrimary,title: Text('充电气泡'),),body: Align(alignment: Alignment(0.0, 1),child: Container(height: MediaQuery.of(context).size.height / 3 * 2,width: 250,// color: Colors.blue,child: Stack(alignment: Alignment.topCenter,children: [...buildAnimatedPositioned(),Padding(padding: const EdgeInsets.only(top: 40,left: 0,),child: RotationTransition(alignment: Alignment.center,turns: _animationController,child: Container(width: 200,height: 200,decoration: const BoxDecoration(color: Colors.deepPurple,borderRadius: BorderRadius.only(topRight: Radius.circular(70),topLeft: Radius.circular(90),bottomRight: Radius.circular(60),bottomLeft: Radius.circular(80),),),),),),//这个效果很有意思 就是有费性能  不需要可以移除掉BackdropFilter(filter: ImageFilter.dilate(radiusX: 3.0, radiusY: 3.0),child: Container(),),Positioned(left: 35,top: 45,child: Container(width: 180,height: 180,decoration: BoxDecoration(color: Colors.black,borderRadius: BorderRadius.circular(90),),child: const Center(child: Text('89%',style: TextStyle(fontSize: 40,color: Colors.white,),),),),),],),),),);}int getRandomNumber(int min, int max) {var random = Random();return min + random.nextInt(max - min + 1);}List<Widget> buildAnimatedPositioned() {List<Widget> _list = [];List.generate(9,(index) => {_list.add(BubbleDot(time: getRandomNumber(2000, 3500))),});return _list;}
    }
    

  • BubbleDot.dart    气泡效果    之所以把气泡单独出来是为了后面的随机打散操作
    import 'dart:math';
    import 'package:flutter/material.dart';class BubbleDot extends StatefulWidget {final int time;const BubbleDot({super.key, required this.time});@overrideState<BubbleDot> createState() => _BubbleDotState();
    }class _BubbleDotState extends State<BubbleDot>with SingleTickerProviderStateMixin {late AnimationController _animationController;late Animation<double> _animation;final Random random = Random();late double _leftPos = 0;late double _dotWidth = 0;@overridevoid initState() {_animationController = AnimationController(vsync: this,duration: Duration(milliseconds: widget.time),);_animation = _animationController.drive(Tween<double>(begin: getRandomNumber(660, 800).toDouble(), end: 100));//_leftPos = random.nextDouble() * 200;_leftPos = getRandomNumber(35, 180).toDouble();_dotWidth = getRandomNumber(30, 66).toDouble();_animationController.addStatusListener((AnimationStatus status) => {print('status  $status')});_animationController.repeat();// TODO: implement initStatesuper.initState();}@overridevoid dispose() {// TODO: implement dispose_animationController.dispose();super.dispose();}@overrideWidget build(BuildContext context) {return AnimatedBuilder(animation: _animation,builder: (BuildContext context, Widget? child) {return Positioned(top: _animation.value,//top: 240,left: _leftPos,child: ClipOval(child: Container(width: _dotWidth,height: _dotWidth,decoration: BoxDecoration(color: Colors.deepPurple,boxShadow: [BoxShadow(color: Colors.deepPurple.withOpacity(0.5),spreadRadius: 6,blurRadius: 8,offset: Offset(4, 4), // changes position of shadow),],),),),);},);}int getRandomNumber(int min, int max) {return min + random.nextInt(max - min + 1);}
    }
    

http://www.yayakq.cn/news/39645/

相关文章:

  • 网站500兆空间多少钱沈阳做网站优化
  • html5 js全屏滑动网站源码wordpress阅读权限
  • 公司网站宣传设计贵州微信网站建设
  • 我想注册网站我怎么做网站建设中如何使用字体
  • 法学院网站建设建议建设网站提供资料的函
  • 个人适合做什么网站网页设计实训报告总结万能模板
  • 国外网站赚钱网站建设微信开发
  • 乐清网站推广中国企业网官方网站下载
  • 网站2级域名 还是子目录seo关键词优化公司哪家好
  • 做网站设计需求宁夏省建筑信息平台
  • 百度云搜索引擎入口官网企业网站的优化方案
  • 免费的黄金网站有哪些网站主机英文
  • 做服务网站建设微信商城网站
  • zhihe网站建设 淘宝目前最火的推广平台
  • 如何查看网站seo网站改版要改哪些页面
  • 电子拜年贺卡在线制作网站互联网学校
  • 网站关键词优化方式网站建设+用ftp上传文件
  • 建设银行网站怎么下设计公司平面设计
  • 免费建网站哪个好搜索引擎优化的例子
  • 北京企业网站建设方网页建设与网站设计心德体会
  • 网站上广告动图是怎么做的电子商务网站的设计要求包括
  • 云南营销型网站建设墨客网站建设xcyxqc
  • 合肥建设网站查询免费微网站与公众号平台对接
  • 给别人做网站的销售叫什么软件泉州seo管理
  • 企业网站建设内存无法进入网站后台
  • 网站建设意见征求简述网站建设的基本特征
  • 安徽建设银行招聘网站中国十大公关公司排名
  • 网站开发人员需要什么要求农产品网站开发方案
  • 猪八戒做网站要多少钱网站建设公司怎样布局
  • 调查网站做调查不容易过住总集团公司宣传册设计样本