赞
踩
目录
主轴方向:mainAxisAlignment:MainAxisAlignment.center
交叉轴方向:crossAxisAlignment:CrossAxisAlignment
文字方向:textDirection:TextDirection
竖直方向排序:verticalDirection:VerticalDirection
基线对齐方式:textBaseline:TextBaseline
- enum Axis {
- horizontal,//水平
- vertical,//竖直
- }
- enum MainAxisAlignment {
- start,//顶头
- end,//接尾
- center,//居中
- spaceBetween,//顶头接尾,其他均分
- spaceAround,//中间的孩子均分,两头的孩子空一半
- spaceEvenly,//均匀平分
- }
- enum CrossAxisAlignment {
- start,//顶头
- end,//接尾
- center,//居中
- stretch,//伸展
- baseline,//基线
- }
- enum MainAxisSize {
- min,
- max,
- }
- enum TextDirection {
- ltr,//从左到右
- rtl,//从右到左
- }
- enum VerticalDirection{
- up,
- down,
- }
- enum TextBaseline {
- alphabetic,
- ideographic,
- }
- Column(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: [
- Flexible(
- flex: 1,
- child: Container(
- color: Colors.red,
- width: 100, // 宽度固定
- height: double.infinity, // 纵向填满
- ),
- ),
- Flexible(
- flex: 2,
- child: Container(
- color: Colors.blue,
- width: 100,
- height: double.infinity,
- ),
- ),
- ],
- )
- import 'dart:async';
-
- import 'package:flutter/material.dart';
- import 'package:flutter_diancan/pages/layout/login_page.dart';
- import 'package:flutter_diancan/pages/home/home_page.dart';
- import 'package:flutter_diancan/stores/user_store.dart';
- import 'package:provider/provider.dart';
-
- class Startpage extends StatelessWidget {
- const Startpage({super.key});
-
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- centerTitle: true,
- title: Text("首页"),
- ),
- body: Center(child: testFlex()));
- }
-
- testFlex() {
- var redBox = Container(
- color: Colors.red,
- height: 80,
- width: double.infinity,
- child: const Text("红"),
- );
-
- var blueBox = Container(
- color: Colors.blue,
- height: 80,
- width: double.infinity,
- child: const Text("蓝"),
- );
-
- var yellowBox = Container(
- color: Colors.yellow,
- height: 80,
- width: double.infinity,
- child: const Text("黄"),
- );
-
- var greenBox = Container(
- color: Colors.green,
- height: 80,
- width: double.infinity,
- child: const Text("绿"),
- );
-
- var show = Flex(
- direction: Axis.vertical,
- crossAxisAlignment: CrossAxisAlignment.start,
- textBaseline: TextBaseline.alphabetic,
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[redBox, blueBox, yellowBox, greenBox],
- mainAxisSize: MainAxisSize.max,
- );
- return show;
- }
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。