我试图将行拉到横轴的末端(到屏幕底部)。
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import 'package:provider/provider.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
// TODO: implement build
return MaterialApp(home: HomePage());
}
}
class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Row(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Container(
child: FlutterLogo(
size: 60,
),
),
Container(
child: FlutterLogo(
size: 60,
colors: Colors.red,
),
),
Container(
child: FlutterLogo(
size: 60,
colors: Colors.cyan,
),
),
],
));
}
}
但是它不起作用。我在做什么错了?
答案 0 :(得分:1)
您没有设置高度,因此将行包装在一个 例如。
body: new Column(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.end,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Container(
child: FlutterLogo(
size: 60,
),
),
Container(
child: FlutterLogo(
size: 60,
colors: Colors.red,
),
),
Container(
child: FlutterLogo(
size: 60,
colors: Colors.cyan,
),
),
],
)
]
),
还有其他小部件可能会更好,但这取决于您的内容 https://api.flutter.dev/flutter/widgets/Align-class.html https://api.flutter.dev/flutter/widgets/Positioned-class.html