Flutter使用Redux Store更新圆图保留标签

时间:2019-07-09 09:01:42

标签: flutter

我是扑朔迷离的新手,想问一个关于redux和circular chart的问题。我有以下代码。我尝试了不同的方法,但没有一个起作用。我在下面的代码中标记了无法使用的地方。

class CurrentTabPageState extends State<CurrentTabPage> {

int _angle = 0;
final GlobalKey<AnimatedCircularChartState> _chartKey = new GlobalKey<AnimatedCircularChartState>();

List<CircularStackEntry> data = <CircularStackEntry>[
  new CircularStackEntry(
    <CircularSegmentEntry>[
      new CircularSegmentEntry(50.0, Colors.red[200], rankKey: 'Q1'),
      new CircularSegmentEntry(1000.0, Colors.green[200], rankKey: 'Q2')
    ],
    rankKey: 'Quarterly Profits',
  ),
];

@override
Widget build(BuildContext context) {
  return new StoreConnector<ReduxState, double>(
    converter: (store) { setState(() {
      _angle = store.state.angle.toInt();
      print(_angle);     <------- Can print correct value here
    });
      return store.state.angle;
    },
    builder: (context, angle) {
      print(_angle);     <------- Can print correct value here
      return new AnimatedCircularChart(
          key: _chartKey,
          size: const Size(300.0, 300.0),
          initialChartData: data,
          chartType: CircularChartType.Radial,
          holeLabel: '$_angle',   <----- does not updated
          //holeLabel: 'angle',   <----- does not updated
          labelStyle: new TextStyle(
            color: Colors.blueGrey[600],
            fontWeight: FontWeight.bold,
            fontSize: _angle*10.roundToDouble(),   <---- does not updated
          )
      );
    });
}}

任何人都可以提出建议吗?非常感谢。

0 个答案:

没有答案