哈尔滨网站建设推广网站icp备案查询官网

张小明 2026/1/10 2:23:55
哈尔滨网站建设推广,网站icp备案查询官网,佛山债优化公司,php网站建设情景效果图说明#xff1a;版本1的中心水果图片只是简单的排列#xff0c;这个版本是让图片进行两两交叠实现步骤1.构建网格子项Widget _buildInAudioItem({required String name,required ListString images, //用列表接收图片required VoidCallback onTap,double image…效果图说明版本1的中心水果图片只是简单的排列这个版本是让图片进行两两交叠实现步骤1.构建网格子项Widget _buildInAudioItem({ required String name, required ListString images, //用列表接收图片 required VoidCallback onTap, double imageSize 40, }) { return Column( mainAxisSize: MainAxisSize.min, children: [ GestureDetector( onTap: onTap, child: Container( height: 150, width: 155, decoration: BoxDecoration( color: Color(0xFF1B1D2E), borderRadius: BorderRadius.circular(10), ), child: Center( child: _buildImageLayout(images, imageSize: imageSize), //传递图片和图片尺寸 ), ), ), SizedBox(height: 8), Container( height: 30, child: Text( name, style: TextStyle(color: Colors.white, fontSize: 12), textAlign: TextAlign.center, maxLines: 2, overflow: TextOverflow.ellipsis, ), ), ], ); }2.构建图片布局 ******Widget _buildImageLayout(ListString images, {double imageSize 40}) { int count images.length; //图片个数 if (count 1) { // 单个图片居中显示 return Container( height: imageSize, width: imageSize, decoration: BoxDecoration( color: Color(0xFF55596D), borderRadius: BorderRadius.circular(imageSize / 2), ), child: Center( child: Image.asset( images[0], width: imageSize * 0.5, height: imageSize * 0.5, ), ), ); } else if (count 2) { // 两个图片交叠显示 double overlap imageSize * 0.2; // 交叠宽度 double totalWidth imageSize * 2 - overlap; return Container( width: totalWidth, child: Stack( children: [ // 第一个图片在左边 Positioned( top: 55, left: 0, child: Container( height: imageSize, width: imageSize, decoration: BoxDecoration( color: Color(0xFF55596D).withOpacity(0.8), borderRadius: BorderRadius.circular(imageSize / 2), ), child: Center( child: Image.asset( images[0], width: imageSize * 0.5, height: imageSize * 0.5, ), ), ), ), // 第二个图片在右边交叠一部分 Positioned( top: 55, left: imageSize - overlap, child: Container( height: imageSize, width: imageSize, decoration: BoxDecoration( color: Color(0xFF55596D).withOpacity(0.8), borderRadius: BorderRadius.circular(imageSize / 2), ), child: Center( child: Image.asset( images[1], width: imageSize * 0.5, height: imageSize * 0.5, ), ), ), ), ], ), ); } else if (count 3) { // 三个图片交叠显示 double overlap imageSize * 0.2; // 交叠宽度 double totalWidth imageSize (imageSize - overlap) * 2; return Container( width: totalWidth, child: Stack( children: [ // 第一个图片在最左边 Positioned( top:55, left: 0, child: Container( height: imageSize, width: imageSize, decoration: BoxDecoration( color: Color(0xFF55596D).withOpacity(0.8), borderRadius: BorderRadius.circular(imageSize / 2), ), child: Center( child: Image.asset( images[0], width: imageSize * 0.5, height: imageSize * 0.5, ), ), ), ), // 第二个图片在中间 Positioned( top:55, left: imageSize - overlap, child: Container( height: imageSize, width: imageSize, decoration: BoxDecoration( color: Color(0xFF55596D).withOpacity(0.8), borderRadius: BorderRadius.circular(imageSize / 2), ), child: Center( child: Image.asset( images[1], width: imageSize * 0.5, height: imageSize * 0.5, ), ), ), ), // 第三个图片在最右边 Positioned( top:55, left: (imageSize - overlap) * 2, child: Container( height: imageSize, width: imageSize, decoration: BoxDecoration( color: Color(0xFF55596D).withOpacity(0.8), borderRadius: BorderRadius.circular(imageSize / 2), ), child: Center( child: Image.asset( images[2], width: imageSize * 0.5, height: imageSize * 0.5, ), ), ), ), ], ), ); } return SizedBox.shrink(); } }3.使用子项构建表格Widget buildInAudioList() { return Padding( padding: EdgeInsets.symmetric(horizontal: 10, vertical: 40), child: GridView.count( crossAxisCount: 2, crossAxisSpacing: 15, mainAxisSpacing: 5, childAspectRatio: 155 / 180, shrinkWrap: true, children: [ _buildInAudioItem( name: 苹果, images: [assets/images/apple.png], onTap: () print(点击苹果), ), _buildInAudioItem( name: 苹果香蕉, images: [assets/images/apple.png, assets/images/banana.png], onTap: () print(点击苹果香蕉), ), _buildInAudioItem( name: 苹果、香蕉、樱桃, images: [assets/images/apple.png, assets/images/banana.png, assets/images/cherry.png], onTap: () print(点击苹果、香蕉、樱桃), ), _buildInAudioItem( name: 苹果, images: [assets/images/apple.png], onTap: () print(苹果), ), ], ), ); }代码实例import package:flutter/cupertino.dart; import package:flutter/material.dart; class DemoPage extends StatefulWidget { const DemoPage({super.key}); override StateDemoPage createState() _DemoPageState(); } class _DemoPageState extends StateDemoPage { override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.transparent, body: Container( width: double.infinity, height: double.infinity, decoration: const BoxDecoration( gradient: LinearGradient( begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [ Color(0xFF060618), Color(0xFF070A23), ], ), ), child: buildInAudioList(), ), ); } Widget buildInAudioList() { return Padding( padding: EdgeInsets.symmetric(horizontal: 10, vertical: 40), child: GridView.count( crossAxisCount: 2, crossAxisSpacing: 15, mainAxisSpacing: 5, childAspectRatio: 155 / 180, shrinkWrap: true, children: [ _buildInAudioItem( name: 苹果, images: [assets/images/apple.png], onTap: () print(点击苹果), ), _buildInAudioItem( name: 苹果香蕉, images: [assets/images/apple.png, assets/images/banana.png], onTap: () print(点击苹果香蕉), ), _buildInAudioItem( name: 苹果、香蕉、樱桃, images: [assets/images/apple.png, assets/images/banana.png, assets/images/cherry.png], onTap: () print(点击苹果、香蕉、樱桃), ), _buildInAudioItem( name: 苹果, images: [assets/images/apple.png], onTap: () print(苹果), ), ], ), ); } // 网格子项 Widget _buildInAudioItem({ required String name, required ListString images, //用列表接收图片 required VoidCallback onTap, double imageSize 40, }) { return Column( mainAxisSize: MainAxisSize.min, children: [ GestureDetector( onTap: onTap, child: Container( height: 150, width: 155, decoration: BoxDecoration( color: Color(0xFF1B1D2E), borderRadius: BorderRadius.circular(10), ), child: Center( child: _buildImageLayout(images, imageSize: imageSize), //传递图片和图片尺寸 ), ), ), SizedBox(height: 8), Container( height: 30, child: Text( name, style: TextStyle(color: Colors.white, fontSize: 12), textAlign: TextAlign.center, maxLines: 2, overflow: TextOverflow.ellipsis, ), ), ], ); } // 构建图片布局 Widget _buildImageLayout(ListString images, {double imageSize 40}) { int count images.length; //图片个数 if (count 1) { // 单个图片居中显示 return Container( height: imageSize, width: imageSize, decoration: BoxDecoration( color: Color(0xFF55596D), borderRadius: BorderRadius.circular(imageSize / 2), ), child: Center( child: Image.asset( images[0], width: imageSize * 0.5, height: imageSize * 0.5, ), ), ); } else if (count 2) { // 两个图片交叠显示 double overlap imageSize * 0.2; // 交叠宽度 double totalWidth imageSize * 2 - overlap; return Container( width: totalWidth, child: Stack( children: [ // 第一个图片在左边 Positioned( top: 55, left: 0, child: Container( height: imageSize, width: imageSize, decoration: BoxDecoration( color: Color(0xFF55596D).withOpacity(0.8), borderRadius: BorderRadius.circular(imageSize / 2), ), child: Center( child: Image.asset( images[0], width: imageSize * 0.5, height: imageSize * 0.5, ), ), ), ), // 第二个图片在右边交叠一部分 Positioned( top: 55, left: imageSize - overlap, child: Container( height: imageSize, width: imageSize, decoration: BoxDecoration( color: Color(0xFF55596D).withOpacity(0.8), borderRadius: BorderRadius.circular(imageSize / 2), ), child: Center( child: Image.asset( images[1], width: imageSize * 0.5, height: imageSize * 0.5, ), ), ), ), ], ), ); } else if (count 3) { // 三个图片交叠显示 double overlap imageSize * 0.2; // 交叠宽度 double totalWidth imageSize (imageSize - overlap) * 2; return Container( width: totalWidth, child: Stack( children: [ // 第一个图片在最左边 Positioned( top:55, left: 0, child: Container( height: imageSize, width: imageSize, decoration: BoxDecoration( color: Color(0xFF55596D).withOpacity(0.8), borderRadius: BorderRadius.circular(imageSize / 2), ), child: Center( child: Image.asset( images[0], width: imageSize * 0.5, height: imageSize * 0.5, ), ), ), ), // 第二个图片在中间 Positioned( top:55, left: imageSize - overlap, child: Container( height: imageSize, width: imageSize, decoration: BoxDecoration( color: Color(0xFF55596D).withOpacity(0.8), borderRadius: BorderRadius.circular(imageSize / 2), ), child: Center( child: Image.asset( images[1], width: imageSize * 0.5, height: imageSize * 0.5, ), ), ), ), // 第三个图片在最右边 Positioned( top:55, left: (imageSize - overlap) * 2, child: Container( height: imageSize, width: imageSize, decoration: BoxDecoration( color: Color(0xFF55596D).withOpacity(0.8), borderRadius: BorderRadius.circular(imageSize / 2), ), child: Center( child: Image.asset( images[2], width: imageSize * 0.5, height: imageSize * 0.5, ), ), ), ), ], ), ); } return SizedBox.shrink(); } }
版权声明:本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!

网站开发维护报价单小程序开发视频教程

简单三步搞定Mac菜单栏:Dozer终极整理方案 【免费下载链接】Dozer Hide menu bar icons on macOS 项目地址: https://gitcode.com/gh_mirrors/do/Dozer 还在为Mac菜单栏上堆积如山的图标感到烦恼吗?想要一个清爽干净的工作界面?Dozer就…

张小明 2026/1/7 21:54:07 网站建设

手机网站html源码下载用文本文档做网站

前言If you have any questions, feel free to communicate at any timeRecord each screen with code【V】【Guste8868】在工业控制等宽温(-10~60℃工作)场景下,21.5 英寸 FHD 高亮度显示模组需兼具温度适应性与视觉清晰度。友达 G215HAN01.…

张小明 2026/1/7 21:54:10 网站建设

手机上怎么制作网站吗医疗营销型网站建设

AdNauseam终极指南:如何用点击混淆技术保护隐私安全 【免费下载链接】AdNauseam AdNauseam: Fight back against advertising surveillance 项目地址: https://gitcode.com/gh_mirrors/ad/AdNauseam 在当今数字广告无处不在的时代,我们的每一次点…

张小明 2026/1/9 9:01:34 网站建设

网站专题页面制作织梦手机网站模板删除

解密开源KVM软件Barrier:跨设备控制的完整实现方案 【免费下载链接】barrier Open-source KVM software 项目地址: https://gitcode.com/gh_mirrors/ba/barrier 你是否曾经在多台电脑间频繁切换键盘鼠标,工作效率大打折扣?Barrier作为…

张小明 2026/1/7 21:54:12 网站建设

网站改版开发公司湖北民族建设集团网站首页

C开发者的依赖管理革命:vcpkg实战全解析 【免费下载链接】vcpkg vcpkg - 一个用于管理 C 和 C 库的工具,支持在 Windows、Linux 和 macOS 上安装和集成各种库。 项目地址: https://gitcode.com/GitHub_Trending/vc/vcpkg 在C开发的漫长历史中&…

张小明 2026/1/7 21:54:10 网站建设

厦门专业网站建设建站西安seo霸屏

第一章:多指手势冲突频发?Open-AutoGLM协同调度模型一招解决在现代触控交互系统中,多指手势的广泛应用显著提升了操作效率,但也带来了频繁的手势识别冲突问题。不同手势动作(如缩放、旋转、滑动)常因轨迹重…

张小明 2026/1/7 21:54:12 网站建设