我很清楚 MainAxisSize 的效果,但我不明白它的目的。请像我5岁一样解释一下。谢谢。
供进一步参考:
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
backgroundColor: Color(0xffEDE7F6),
body: SafeArea(
child: Column(mainAxisSize: MainAxisSize.min, children: <Widget>[
Container(
height: 100,
width: 100,
color: Color(0xff9575CD),
child: Text('Container 1'),
),
Container(
height: 100,
width: 100,
color: Colors.black45,
child: Text('Container 2'),
),
Container(
height: 100,
width: 100,
color: Colors.black12,
child: Text('Container 3'),
),
]),
),
),
);
}
}
Run Code Online (Sandbox Code Playgroud)
模拟器上的输出:
我一直在 Android Studio 上使用 Flutter。今天,我更新了它,一切都在走下坡路。
在尝试解决此问题的过程中,我一直遇到不同的错误。
第一个错误:无法初始化类 org.codehaus.groovy.runtime.invokerhelper
第二个错误:无法初始化类 org.codehaus.groovy.reflection.ReflectionCache
无论如何,我一直在研究并做了以下工作
但仍然没有任何效果,我无法运行我的项目。请帮忙?
void main() {
Car myCar = Car(drive: slowDrive);
myCar.drive();
}
class Car {
Car({this.drive});
Function? drive;
}
void slowDrive() {
print('Driving slowly');
}
void fastDrive() {
print('Driving fast');
}
Run Code Online (Sandbox Code Playgroud)
该错误表示,必须先对值可以为 null 的表达式进行 null 检查,然后才能取消引用。
我怎样才能对这个进行空检查?