gpt4 book ai didi

flutter - 无法将 Row 下拉

转载 作者:IT王子 更新时间:2023-10-29 07:16:59 26 4
gpt4 key购买 nike

我正在尝试将行拉到横轴的末端(到屏幕底部)。

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,

),
),
],
));
}
}

enter image description here

但它不起作用。我做错了什么?

最佳答案

您没有设置高度,所以将行包装在一个可以设置高度的小部件中例如。

 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,

),
),
],
)
]
),

screenshot还有其他小部件可能会更好,但这取决于您的内容 https://api.flutter.dev/flutter/widgets/Align-class.html https://api.flutter.dev/flutter/widgets/Positioned-class.html

关于flutter - 无法将 Row 下拉,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57078634/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com