add
This commit is contained in:
@@ -4,19 +4,10 @@ import 'package:flutter/services.dart';
|
|||||||
class HomePage extends StatelessWidget {
|
class HomePage extends StatelessWidget {
|
||||||
// 功能列表数据
|
// 功能列表数据
|
||||||
final List<Map<String, dynamic>> features = [
|
final List<Map<String, dynamic>> features = [
|
||||||
{'icon': Icons.home, 'title': '首页'},
|
{'icon': Icons.bar_chart, 'title': '数据分析'},
|
||||||
{'icon': Icons.search, 'title': '搜索'},
|
{'icon': Icons.balance, 'title': '交易'},
|
||||||
{'icon': Icons.notifications, 'title': '通知'},
|
{'icon': Icons.account_balance, 'title': '交易所'},
|
||||||
{'icon': Icons.message, 'title': '消息'},
|
{'icon': Icons.branding_watermark, 'title': '品种'},
|
||||||
{'icon': Icons.person, 'title': '个人中心'},
|
|
||||||
{'icon': Icons.settings, 'title': '设置'},
|
|
||||||
{'icon': Icons.help, 'title': '帮助中心'},
|
|
||||||
{'icon': Icons.share, 'title': '分享'},
|
|
||||||
// 可以添加更多项测试滚动
|
|
||||||
{'icon': Icons.accessibility, 'title': '无障碍'},
|
|
||||||
{'icon': Icons.add_alert, 'title': '提醒'},
|
|
||||||
{'icon': Icons.book, 'title': '书籍'},
|
|
||||||
{'icon': Icons.camera, 'title': '相机'},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
HomePage({super.key});
|
HomePage({super.key});
|
||||||
@@ -75,35 +66,41 @@ class HomePage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
// 使用SafeArea确保内容在安全区域内
|
// 使用SafeArea确保内容在安全区域内
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
// 使用Expanded确保ListView获得足够空间
|
// 移除不必要的Expanded,避免约束冲突
|
||||||
child: Expanded(
|
child: Container(
|
||||||
child: Container(
|
color: theme.colorScheme.surface,
|
||||||
color: theme.colorScheme.surface,
|
// 让容器占满整个可用空间
|
||||||
// 确保ListView占满可用空间
|
width: double.infinity,
|
||||||
child: ListView.separated(
|
height: double.infinity,
|
||||||
// 关键修复:添加内边距但不影响滚动范围
|
child: ListView.builder(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
// 修改为ListView.builder
|
||||||
// 确保列表有足够多的项可以滚动(已添加测试项)
|
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||||
itemCount: features.length,
|
itemCount: features.length,
|
||||||
// 增强的滚动物理效果
|
// 优化Web端滚动物理效果,同时支持触摸和鼠标滚动
|
||||||
physics: const BouncingScrollPhysics(
|
physics: const ScrollPhysics(parent: BouncingScrollPhysics()),
|
||||||
parent: AlwaysScrollableScrollPhysics(),
|
itemBuilder: (context, index) {
|
||||||
),
|
// 构建列表项
|
||||||
separatorBuilder: (context, index) => Divider(
|
Widget item = _buildFeatureItem(
|
||||||
height: 1,
|
context: context,
|
||||||
thickness: 1,
|
icon: features[index]['icon'],
|
||||||
indent: 72,
|
title: features[index]['title'],
|
||||||
endIndent: 16,
|
);
|
||||||
color: theme.dividerColor,
|
|
||||||
),
|
// 在每个列表项下方添加分割线,包括最后一个
|
||||||
itemBuilder: (context, index) {
|
return Column(
|
||||||
return _buildFeatureItem(
|
mainAxisSize: MainAxisSize.min,
|
||||||
context: context,
|
children: [
|
||||||
icon: features[index]['icon'],
|
item,
|
||||||
title: features[index]['title'],
|
Divider(
|
||||||
);
|
height: 1,
|
||||||
},
|
thickness: 1,
|
||||||
),
|
indent: 72,
|
||||||
|
endIndent: 16,
|
||||||
|
color: theme.dividerColor,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user