无法将Row下拉

时间:2019-07-17 14:47:26

标签: flutter

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

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

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

1 个答案:

答案 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,

        ),
        ),
      ],
    )
      ]
    ),

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