You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter中syncfusion_flutter_charts在Android真机显示灰色屏幕问题

Android物理设备图表显示灰色屏幕,模拟器正常问题排查

我在Android模拟器中可正常绘制图表,但在Android物理设备上无法显示图表,仅呈现灰色屏幕。

截图:
模拟器正常显示图表
物理设备灰色屏幕

相关代码如下:

@override
Widget build(BuildContext context) {
  TextTheme _textTheme = Theme.of(context).textTheme;
  // TODO: implement build
  return SafeArea(
    child: Scaffold(
      backgroundColor: Colors.white,
      body: Column(
        children: [
          SizedBox(
            height: 20,
          ),
          Padding(
            padding: const EdgeInsets.fromLTRB(20, 10, 20, 10),
            child: Row(
              children: [
                GestureDetector(
                  onTap: () {
                    Navigator.pop(context);
                  },
                  child: Icon(
                    Icons.arrow_back_ios,
                    color: Colors.blueAccent,
                    size: 20,
                  ),
                ),
                SizedBox(
                  width: 10,
                ),
                Image.network(
                  widget.cryptoData.cryptoImage!,
                  height: 20,
                  width: 20,
                  // fit: BoxFit.fill,
                ),
                SizedBox(
                  width: 6,
                ),
                Text(widget.cryptoData.cryptoName!,
                    style: _textTheme.labelSmall),
                SizedBox(
                  width: 2,
                ),
                Text('(' + widget.cryptoData.cryptoSymbol! + ')',
                    style: _textTheme.titleMedium)
              ],
            ),
          ),
          SizedBox(
            height: 10,
          ),
          Padding(
            padding: const EdgeInsets.fromLTRB(20, 0, 20, 10),
            child: Row(
              children: [
                Text(
                    "\$" +
                        limitDecimalToTwo(
                            widget.cryptoData.cryptoValue.toString()),
                    style: _textTheme.labelLarge),
                SizedBox(
                  width: 20,
                ),
                Text(
                    limitDecimalToTwo(
                        widget.cryptoData.cryptoValueChange.toString()),
                    style: TextStyle(
                        color: widget.cryptoData.cryptoValueChange
                                    .toString()[0] ==
                                '-'
                            ? Colors.red
                            : Colors.green,
                        fontSize: 14)),
              ],
            ),
          ),
          Expanded(
              flex: 4,
              child: Container(
                child: SfCartesianChart(
                  primaryXAxis: CategoryAxis(),
                  // primaryYAxis: CategoryAxis(
                  //     isVisible: false,
                  //     majorGridLines: const MajorGridLines(width: 0)),
                  series: <ChartSeries<CryptoData, String>>[
                    LineSeries<CryptoData, String>(
                        dataSource: cryptoDataList,
                        xValueMapper: (CryptoData crypto, _) =>
                            getDateInProperFormat(crypto.date),
                        yValueMapper: (CryptoData crypto, _) => crypto.value),
                  ],
                ),
              )),
          SizedBox(
            height: 20,
          ),
          Padding(
            padding: const EdgeInsets.all(15),
            child: Expanded(
                flex: 2,
                child: CryptoRowWidget(
                    cryptoName: widget.cryptoData.cryptoName,
                    cryptoCode: widget.cryptoData.cryptoSymbol,
                    cryptoImage: widget.cryptoData.cryptoImage,
                    cryptoValue: widget.cryptoData.cryptoValue.toString(),
                    cryptoValueChange:
                        widget.cryptoData.cryptoValueChange.toString(),
                    cryptoQunatityAvailable: '')),
          ),
          Padding(
            padding: const EdgeInsets.all(15),
            child: Expanded(
              flex: 1,
              child: Row(
                crossAxisAlignment: CrossAxisAlignment.center,
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  ElevatedButton(
                      style: ElevatedButton.styleFrom(shape: StadiumBorder()),
                      onPressed: () {
                        showAlertDialog(context, _textTheme, 'Buy');
                      },
                      child: Padding(
                          padding: const EdgeInsets.fromLTRB(30, 10, 30, 10),
                          child: Text(
                            'Buy',
                            style: _textTheme.bodySmall,
                          ))),
                  SizedBox(
                    width: 40,
                  ),
                  ElevatedButton(
                      style: ElevatedButton.styleFrom(shape: StadiumBorder()),
                      onPressed: () {
                        showAlertDialog(context, _textTheme, 'Sell');
                      },
                      child: Padding(
                          padding: const EdgeInsets.fromLTRB(30, 10, 30, 10),
                          child: Text(
                            'Sell',
                            style: _textTheme.bodySmall,
                          ))),
                ],
              ),
            ),
          )
        ],
      ),
    ),
  );
}

我曾找到过类似问题的解决方案,但该方案针对的是存在ListView父组件的场景,我的代码中没有ListView,因此无法适用,特此求助。

内容的提问来源于stack exchange,提问作者Swapnil Gaikwad

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.02 06:20:27