Skip to content

Instantly share code, notes, and snippets.

@code-brewer
Last active May 10, 2020 13:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save code-brewer/c729d017cafd08670d1459888260918c to your computer and use it in GitHub Desktop.
Save code-brewer/c729d017cafd08670d1459888260918c to your computer and use it in GitHub Desktop.
layout demo -- Row , Column, Expanded ...
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, // 1) 如果要将‘mainAxisSize’ 设置为 min,那么需要先禁用 spaceEvenly !
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.center, // 2) 修改这个属性看看效果
children: <Widget>[
Container(color: Colors.red, width: 60, height: 60),
Container(color: Colors.blue, width: 80, height: 80),
Container(color: Colors.green, width: 70, height: 70),
Container(color: Colors.orange, width: 100, height: 100),
],
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment