窗口小部件连续起火?

时间:2019-06-08 05:53:21

标签: flutter dart

我是扑扑开发的新手。我在构建中调用小部件,第一次(登录屏幕)工作正常。我要转到另一个屏幕,然后返回到着陆屏幕,该小部件会连续触发并显示空白屏幕。

body: Container(
          child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Container(
                  margin: EdgeInsets.only(bottom: 20.0),
                  child: Text('Total Orders - ' + _orders['orders'].toString(),
                      style: TextStyle(
                          color: Colors.black,
                          fontWeight: FontWeight.bold,
                          fontSize: 18.0,
                          ),
                    ),
                ),
                _buildOrdersChart(context, model, _orders),
              ],
          ),
      ),
Widget _buildOrdersChart(BuildContext context, MainModel model, _orders) {
    var data = [
      Sales('DineIn', _orders['DineIn'].toInt(), Colors.teal[800]),
      Sales('Delivery', _orders['Delivery'].toInt(), Colors.pink[800]),
      Sales('TakeAway', _orders['Takeaway'].toInt(), Colors.lime[900]),
    ];

    var series = [
      charts.Series(
          domainFn: (Sales sales, _) => sales.day,
          measureFn: (Sales sales, _) => sales.sold,
          colorFn: (Sales sales, _) => sales.color,
          id: 'Sales',
          data: data,
          labelAccessorFn: (Sales sales, _) => '${sales.sold.toString()}')
    ];

    var chart = charts.PieChart(
      series,
      animationDuration: Duration(seconds: 1),
      defaultRenderer:
          charts.ArcRendererConfig(arcWidth: 100, arcRendererDecorators: [
        charts.ArcLabelDecorator(labelPosition: charts.ArcLabelPosition.inside)
      ]),
    );}

0 个答案:

没有答案