范围错误(索引):无效值:不在 0.6 范围内,包括:-2



这是来自官方颤振包网站的通话记录包。我试图学习并实现它以从设备获取呼叫列表,但出现此错误。

    Iterable<CallLogEntry> _callLogEntries = [];
    @override
    Widget build(BuildContext context) {
    var children = <Widget>[];
    _callLogEntries.forEach((entry) {
    children.add(
    Column(
      children: <Widget>[
        Divider(),
        Text('NUMBER   : ${entry.formattedNumber}', style: mono),
        Text('NAME     : ${entry.name}', style: mono),
      ],
      crossAxisAlignment: CrossAxisAlignment.start,
      mainAxisAlignment: MainAxisAlignment.start,
    ),
  );
 });
return MaterialApp(
  home: Scaffold(
    appBar: AppBar(title: Text('call_log example')),
    body: SingleChildScrollView(
      child: Column(
        children: <Widget>[
          Center(
            child: Padding(
              padding: const EdgeInsets.all(8.0),
              child: RaisedButton(
                onPressed: () async {
                  var result = await CallLog.query();
                  setState(() {
                    _callLogEntries = result;
                  });
                },
                child: Text("Get all"),
              ),
            ),
          ),
          Padding(
            padding: const EdgeInsets.all(8.0),
            child: Column(children: children),
          ),
        ],
      ),
    ),
  ),
);

错误: I/颤振 (25293(: 范围错误 (索引(: 无效值: 不在 0..6 范围内,包括:-2

尝试将var children = <Widget>[];移出方法构建。

相关内容

最新更新