我正在尝试使用此代码在颤振应用程序中构建滚动滑块来构建约束:
var cardAspectRatio = 12.0 / 16.0;
var widgetAspectRatio = cardAspectRatio * 1.2;
AspectRatio (
aspectRatio: widgetAspectRatio,
child: LayoutBuilder(builder: (context, constraints) {
var width = constraints.maxWidth;
var height = constraints.maxHeight;
})
Run Code Online (Sandbox Code Playgroud)
为了给它它的宽度和高度约束,但由此产生的错误表明框约束是无界的:
I/flutter ( 6957): RenderAspectRatio has unbounded constraints.
I/flutter ( 6957): This RenderAspectRatio was given an aspect ratio of
0.8999999999999999 but was given both unbounded
I/flutter ( 6957): constraints: BoxConstraints(unconstrained)
I/flutter ( 6957): size: MISSING
I/flutter ( 6957): aspectRatio: 0.9
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
这个断言现在跟着我因为某种原因使用不同的代码,搜索它,发现flutter团队现在还没有解决它,我们有什么可以做的吗?
v`I/flutter ( 5598): Another exception was thrown:
'package:flutter/src/animation/animations.dart': Failed assertion: line
376 pos 15: 'parent != null': is not true.
I/chatty ( 5598): uid=10085(com.example.gam3ity_aa) 1.ui identical 21
lines
I/flutter ( 5598): Another exception was thrown:
'package:flutter/src/animation/animations.dart': Failed assertion: line
376 pos 15: 'parent != null': is not true.
I/flutter ( 5598): Another exception was thrown:
'package:flutter/src/animation/animations.dart': Failed assertion: line
376 pos 15: 'parent != null': is not true.
I/chatty ( 5598): uid=10085(com.example.gam3ity_aa) 1.ui identical 10
lines
I/flutter ( 5598): …Run Code Online (Sandbox Code Playgroud)