0

我是一名新的颤振开发人员,我正在使用 fl_chart 制作一些仪表板。我的图表在全屏(屏幕 2)的 Web 窗口中很好地显示,一旦我尝试调整窗口大小,在某个时间,饼图变得比父容器大(屏幕 1)知道我应该如何解决问题 ? 调整屏幕大小后的仪表板 全屏显示仪表板

    Expanded(
      child: Scaffold(
        appBar: AppBar(
          automaticallyImplyLeading:
          MediaQuery.of(context).size.width < 600,
          leading:  IconButton(
              color: Color(0xff2A3F54),
              icon: Icon(FontAwesomeIcons.chartLine),
              onPressed: () {
                //
              }),
          title: Text('Dashboard 2022', style: TextStyle(
              color: Color(0xff2A3F54)
          )),
        ),
       body: Container(
        padding: EdgeInsets.all(12.0),
         child: GridView.builder(
          itemCount: 4,
          gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
          crossAxisCount: 3,
          crossAxisSpacing: 4.0,
          mainAxisSpacing: 4.0,
          childAspectRatio: 2,
           ),
          itemBuilder: (BuildContext context, int index){
            return Padding(
              padding: const EdgeInsets.all(12.0),
              child: _pages[index],
            );
          },
        ),
        ),
      ),
      ),

piechart.dart 构建方法:

     Widget build(BuildContext context) {
return FutureBuilder(
    future: _getData(),
    builder: (BuildContext context, AsyncSnapshot snapshot) {
      if (snapshot.connectionState == ConnectionState.done) {
        return  Card(
            color: Colors.white,
            child: Column(
              children: <Widget>[
                SizedBox(
                  width: double.infinity,
                  child: Container(
                    padding:
                        EdgeInsets.only(left: 20.0, top: 8.0, bottom: 8.0),
                    child: //(this.title!= null) ?
                        Text(
                      getTitle(),
                      style:
                          TextStyle(color: Color(0xff2A3F54), fontSize: 16),
                      textAlign: TextAlign.left,
                    ),
                  ),
                ),
                const Divider(
                  height: 4,
                  thickness: 1,
                  indent: 20,
                  endIndent: 20,
                  color: Color(0xffB0BEC5),
                ),
                Expanded(
                  child: Row(children: <Widget>[
                    Expanded(
                      child: PieChart(
                        PieChartData(
                            startDegreeOffset: 180,
                            borderData: FlBorderData(
                              show: false,
                            ),
                            sectionsSpace: 1,
                            centerSpaceRadius: 0,
                            sections: showingSections(snapshot.data)),
                      ),
                    ),
                    const SizedBox(
                      width: 40,
                    ),
                    showingPieChartIndicator(snapshot.data),
                  ]),
                )
              ],
            ),
          //),
        );
      } else
        return Center(child: CircularProgressIndicator());
    });

}

4

0 回答 0