简体   繁体   English

颤振错误:断言失败:第 1785 行 pos 12:'hasSize'

[英]Flutter error:Failed assertion: line 1785 pos 12: 'hasSize'

I have a code of recording Audio in flutter.我有一个在颤振中录制音频的代码。 The code should work perfectly without errors, whenever I try to call it from an alert dialog I end up with an error代码应该可以完美运行而不会出错,每当我尝试从警报对话框中调用它时,我都会遇到错误

The following assertion was thrown during performLayout(): RenderShrinkWrappingViewport does not support returning intrinsic dimensions.在 performLayout() 期间抛出以下断言:RenderShrinkWrappingViewport 不支持返回内部尺寸。

Calculating the intrinsic dimensions would require instantiating every child of the viewport, which defeats the point of viewports being lazy.计算内在尺寸需要实例化视口的每个子项,这与视口懒惰的观点相悖。

If you are merely trying to shrink-wrap the viewport in the main axis direction, you should be able to achieve that effect by just giving the viewport loose constraints, without needing to measure its intrinsic dimensions.如果您只是试图在主轴方向收缩包裹视口,您应该能够通过给视口松散约束来实现该效果,而无需测量其内在尺寸。

Am trying to pass an option to record audio to an alert dialog.我正在尝试将录制音频的选项传递给警报对话框。 Users to record audio from a pop up instead of a main screen.用户从弹出窗口而不是主屏幕录制音频。 What am I doing wrong?我究竟做错了什么?

What i have so far到目前为止我所拥有的

 Widget setupAlertDialoadContainer() {
    return ListView(
      shrinkWrap: true, //just set this property
      padding: const EdgeInsets.all(8.0),
      //children: listItems.toList(),
      children: <Widget>[
        Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Container(
              margin: EdgeInsets.only(top: 24.0, bottom: 16.0),
              child: Text(
                this._recorderTxt,
                style: TextStyle(
                  fontSize: 48.0,
                  color: Colors.black,
                ),
              ),
            ),
            _isRecording
                ? LinearProgressIndicator(
                    value: 100.0 / 160.0 * (this._dbLevel ?? 1) / 100,
                    valueColor: AlwaysStoppedAnimation<Color>(Colors.green),
                    backgroundColor: Colors.red,
                  )
                : Container()
          ],
        ),
        Row(
          children: <Widget>[
            Container(
              width: 56.0,
              height: 56.0,
              margin: EdgeInsets.all(10.0),
              child: FloatingActionButton(
                heroTag: "Record",
                onPressed: () {
                  if (!this._isRecording) {
                    return this.startRecorder();
                  }
                  this.stopRecorder();
                },
                child: this._isRecording ? Icon(Icons.stop) : Icon(Icons.mic),
              ),
            ),
          ],
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
        ),
        Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Container(
              margin: EdgeInsets.only(top: 60.0, bottom: 16.0),
              child: Text(
                this._playerTxt,
                style: TextStyle(
                  fontSize: 48.0,
                  color: Colors.black,
                ),
              ),
            ),
          ],
        ),
        Row(
          children: <Widget>[
            Container(
              width: 56.0,
              height: 56.0,
              margin: EdgeInsets.all(8.0),
              child: FloatingActionButton(
                heroTag: "Start",
                onPressed: () {
                  startPlayer();
                },
                child: Icon(Icons.play_arrow),
              ),
            ),
            Container(
              width: 56.0,
              height: 56.0,
              margin: EdgeInsets.all(8.0),
              child: FloatingActionButton(
                heroTag: "Pause",
                onPressed: () {
                  pausePlayer();
                },
                child: Icon(Icons.pause),
              ),
            ),
            Container(
              width: 56.0,
              height: 56.0,
              margin: EdgeInsets.all(8.0),
              child: FloatingActionButton(
                heroTag: "Stop",
                onPressed: () {
                  stopPlayer();
                },
                child: Icon(Icons.stop),
              ),
            ),
          ],
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
        ),
        Container(
            height: 56.0,
            child: Slider(
                value: slider_current_position,
                min: 0.0,
                max: max_duration,
                onChanged: (double value) async {
                  await flutterSound.seekToPlayer(value.toInt());
                },
                divisions: max_duration.toInt()))
      ],
    );
  }

How am passing the data to the Alert dialog如何将数据传递到警报对话框

showDialog(
                        context: context,
                        builder: (BuildContext context) {
                          return AlertDialog(
                            title: Text('Record the data collection'),
                            content: setupAlertDialoadContainer(),
                          );
                        });

is the error is showing when alert box is opened??打开警告框时是否显示错误? if yes my suggestion is using如果是的话,我的建议是使用

showDialog(
                        context: context,
                        builder: (BuildContext context) {
                          return AlertDialog(
                            title: Text('Record the data collection'),
                            content: Container(
                                       child:setupAlertDialoadContainer(),
                                       height:200,
                                       width:200,
                                      ),
                          );
                        });

change the width and height of container according to your need根据需要更改容器的宽度和高度

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Flutter:断言失败:第 1927 行 pos 12:'hasSize' - Flutter: Failed assertion: line 1927 pos 12: 'hasSize' 断言失败:第 1979 行第 12 行:&#39;hasSize&#39; - Failed assertion: line 1979 pos 12: 'hasSize' 失败的断言:第 549 行 pos 12:“child.hasSize”:不正确 - Failed assertion: line 549 pos 12: 'child.hasSize': is not true 失败的断言:第 551 行 pos 12:“child.hasSize”:不正确 - Failed assertion: line 551 pos 12: 'child.hasSize': is not true 错误:RenderBox 未布局,断言失败:第 1940 行 pos 12:'hasSize' - Error: RenderBox was not laid out, Failed assertion: line 1940 pos 12: 'hasSize' 在“Row”中渲染 ListTile 时出现错误“断言失败:第 1687 行 pos 12:'hasSize'” - Get an error `Failed assertion: line 1687 pos 12: 'hasSize'` when render ListTile inside `Row` Flutter 中的错误:断言失败:第 588 行第 12 行:'size.isFinite': is not true.in GridTileBar - Error in Flutter: Failed assertion: line 588 pos 12: 'size.isFinite': is not true.in GridTileBar Flutter:我收到此错误 &gt; 断言失败:第 447 行 pos 12:'context:= null':不正确 - Flutter: I got this error > Failed assertion: line 447 pos 12: 'context != null': is not true 在 flutter 中创建 pdf 错误:断言失败:第 117 行 pos 12:':_paint':文档已保存 - creating pdf in flutter Error :Failed assertion: line 117 pos 12: '!_paint': The document has already been saved Flutter - _AssertionError('package:flutter/src/widgets/framework.dart':断言失败:第 4937 行 pos 12:'child == _child':不正确。) - Flutter - _AssertionError ('package:flutter/src/widgets/framework.dart': Failed assertion: line 4937 pos 12: 'child == _child': is not true.) Error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM