flutter---进度条(3)

效果图

垂直音量进度条

1.定义变量

Dart 复制代码
double _sliderValue9 = 0.65;

2.构造垂直音量条

Dart 复制代码
Widget _buildVerticalSliderCard({
    required String title, //卡片标题
    required double value, //当前值
    required ValueChanged<double> onChanged, //值变化回调
  }) {
    return Container(
      padding: const EdgeInsets.all(16),
      decoration: BoxDecoration(
        color: const Color(0xFF1E293B),
        borderRadius: BorderRadius.circular(12),
        border: Border.all(color: Colors.white.withOpacity(0.1)),
      ),
      child: Column(
        children: [

          //标题
          Text(
            title,
            style: const TextStyle(
              color: Colors.white,
              fontSize: 14,
              fontWeight: FontWeight.w500,
            ),
          ),
          const SizedBox(height: 16),
          Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [

              //垂直滑块区域
              SizedBox(
                height: 200, //固定宽高
                width: 60,
                child: RotatedBox( //旋转盒子(关键)
                  quarterTurns: 3, //旋转270度
                  //进度条核心
                  child: SliderTheme(
                    data: SliderThemeData(
                      trackHeight: 12, //轨道高度
                      thumbShape: const RoundSliderThumbShape(
                        enabledThumbRadius: 10, //滑块半径
                      ),
                      activeTrackColor: const Color(0xFF1E40AF), //激活颜色
                      inactiveTrackColor: Colors.white.withOpacity(0.1),//未激活颜色
                      thumbColor: Colors.white,
                    ),
                    child: Slider(
                      value: value,
                      onChanged: onChanged,
                    ),
                  ),
                ),
              ),
              const SizedBox(width: 20),
              //可视化进度容器
              Column(
                children: [
                  Container(
                    width: 80,
                    height: 180,
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(8),
                      border: Border.all(color: Colors.white.withOpacity(0.2)),
                    ),
                    child: Stack(
                      children: [
                        // 背景
                        Container(
                          decoration: BoxDecoration(
                            borderRadius: BorderRadius.circular(8),
                            color: Colors.white.withOpacity(0.05),
                          ),
                        ),
                        // 填充
                        Positioned(
                          bottom: 0,
                          child: AnimatedContainer(
                            duration: const Duration(milliseconds: 300),
                            width: 80,
                            height: 180 * value, //动态高度:总高度x进度值
                            decoration: BoxDecoration(
                              borderRadius: const BorderRadius.only(
                                bottomLeft: Radius.circular(8),
                                bottomRight: Radius.circular(8),
                              ),
                              gradient: LinearGradient(
                                begin: Alignment.bottomCenter,
                                end: Alignment.topCenter,
                                colors: [
                                  const Color(0xFF1E40AF),
                                  const Color(0xFF3B82F6),
                                ],
                              ),
                            ),
                          ),
                        ),
                      ],
                    ),
                  ),
                  const SizedBox(height: 8),
                  Text(
                    '${(value * 100).toInt()}%',
                    style: const TextStyle(
                      color: Colors.white,
                      fontSize: 16,
                      fontWeight: FontWeight.bold,
                    ),
                  ),
                ],
              ),
            ],
          ),
        ],
      ),
    );
  }

3.使用垂直音量条

Dart 复制代码
         _buildVerticalSliderCard(
            title: '垂直音量条',
            value: _sliderValue9,
            onChanged: (value) => setState(() => _sliderValue9 = value),
          ),
相关推荐
用户95421573334853 小时前
只是选个照片,怎么留下了这么多访问记录?Flutter 图片选择器排查与优化实录
flutter
FungLeo8 小时前
成为全栈·Flutter App 篇·第四批复盘:复用了什么,移动端又新增了什么
flutter·移动开发·跨端开发·成为全栈·api契约·全栈复盘
jason.zeng@150220710 小时前
使用vscode+flutter开发android程序(入门)
android·vscode·flutter
jason.zeng@150220710 小时前
Flutter 项目标准分层目录(repository/dto/page,对齐后端思想)
flutter
程序员老刘2 天前
跨平台开发地图 | 2026年10月
flutter·ai编程·客户端
林瞅瞅2 天前
Flutter 开发环境从零搭建与调试记录
flutter
FungLeo2 天前
成为全栈·Flutter App 篇·Markdown 编辑器:编辑、预览与离开保护
flutter·移动开发·markdown编辑器·表单设计·成为全栈·草稿保存
FungLeo2 天前
成为全栈·Flutter App 篇·会员中心:资料、密码、通知与私有数据缓存
flutter·dart·身份认证·数据隔离·成为全栈·会员中心
穆梓兰煊3 天前
Flutter端云协同推理架构解析
flutter·github