我有这个饼图是由Ffltter Pie_Chart插件创建的.

    return SizedBox(
            height: 150.0,
            child: Stack(
              children: [
                PieChart(
                  baseChartColor: AmbarColors.greyNoEvents,
                  totalValue: hoursSpent,
                  dataMap: dataMap,
                  // degreeOptions: const DegreeOptions(totalDegrees: 360, initialAngle: 0),
                  animationDuration: Duration(milliseconds: 2000),
                  chartLegendSpacing: 22,
                  chartRadius: MediaQuery.of(context).size.width / 3.2,
                  colorList: const [AmbarColors.backgroundGreen],
                  initialAngleInDegree: 0,
                  chartType: ChartType.ring,
                  ringStrokeWidth: 17,
                  centerText: '$percent%',
                  centerTextStyle: const TextStyle(
                      fontWeight: FontWeight.bold,
                      fontFamily: Fonts.satoshi,
                      fontSize: 30),
                  legendOptions: const LegendOptions(
                    showLegends: false,
                  ),

                  chartValuesOptions: const ChartValuesOptions(
                    showChartValueBackground: false,
                    showChartValues: false,
                    showChartValuesInPercentage: true,
                  ),
                  gradientList: gradientList,
                  // gradientList: ---To add gradient colors---
                  // emptyColorGradient: ---Empty Color gradient---
                )
              ],
            ));
      }

问题是当我将图表放入滚动区域时.这就是结果: Chart rotates every time I move the mouse and I don't understand why

video of this issue

还有谁有这个问题吗?

推荐答案

最后,我把SingleChildScrollView英镑放在了永远不能滚动的物理上.这一定是插件中的错误.

    return SizedBox(
              height: 180.0,
              child: Stack(
                children: [
                  SingleChildScrollView( //<!------in this point
                    physics: const NeverScrollableScrollPhysics(),
                    child: PieChart(
                      baseChartColor: Colors.greyNoEvents,
                      totalValue: hoursSpent,
                      dataMap: dataMap,
                      animationDuration: Duration(milliseconds: 2000),
                      chartLegendSpacing: 22,
                      chartRadius: MediaQuery.of(context).size.width / 3.2,
                      colorList: const [Colors.backgroundGreen],
                      initialAngleInDegree: 0,
                      chartType: ChartType.ring,
                      ringStrokeWidth: 17,
                      centerText: '$subsPercent%',
                      centerTextStyle: const TextStyle(
                          fontWeight: FontWeight.bold,
                          fontFamily: Fonts.satoshi,
                          fontSize: 30),
                      legendOptions: const LegendOptions(
                        showLegends: false,
                      ),

                      chartValuesOptions: const ChartValuesOptions(
                        showChartValueBackground: false,
                        showChartValues: false,
                        showChartValuesInPercentage: true,
                      ),
                      gradientList: gradientList,
                      // gradientList: ---To add gradient colors---
                      // emptyColorGradient: ---Empty Color gradient---
                    ),
                  )
                ],
              ),
        );
      }
            

Flutter相关问答推荐

Flutter -使用最小高度展开

本机调试符号包含无效的目录调试符号.目前仅支持Android ABI

在保持标高=1的情况下更改AppBar立面 colored颜色 /遮罩

在框中保存对象列表时,类型推断无法正常工作

设置Flutter 中的ListView.Builder()的最小高度

在Ffltter中,我已经使用了Ffltter_BLOC Cupit和Pusher,但当获得新数据时,UI没有更新

Flutter为什么不;没有ListView.iterable()构造函数?

Flutter-Riverpod:如何只从提供者读取一次值

我的第一个 flutter 项目出错,启动时为空值?

面对Flutter 中的行和列问题

使用 Riverpod 和 copyWith 方法更新数据类中列表中变量的值

如何使用 Rrect 或类似工具在 flutter 中绘制梯形线?

Flutter Websockets MacOS:相同的代码在调试模式下有效,但在发布模式下无效:(操作系统错误:提供了 node 名或服务名..)

如何从 showModalBottomSheet 中的 topRight 和 topLeft 移除平边

从物理设备 Flutter 中移除 USB 后启动画面不可见?

我一直在try 创建按钮以导航到第二页,但不知何故 RaisedButton 功能无法正常工作

是否可以在 Flutter 中使用 ToggleButtons 在页面 PageView 之间切换?

Flutter Bloc Todo 示例 - 收听存储库中的单个 todo

如何在Flutter 中将列表的模型类型转换为数组?

如何在 ElevatedButton 上设置背景 colored颜色 动画?