在 Flex 下 使用
    Flex 的 direction 属性 是必选项 ,控制排列的方向(水平或竖直)
    水平

    1. direction: Axis.horizontal

    竖直

    1. direction: Axis.vertical

    Flex 下的 Expanded 部件 可以设置 flex的值
    如果 Flex 下还有别的 部件(例如:Container),则 Flex 会把剩余的空间按照 flex 的值 进行分配

    1. import 'package:flutter/cupertino.dart';
    2. import 'package:flutter/material.dart';
    3. // import 'package:english_words/english_words.dart';
    4. void main() => runApp(new MyApp());
    5. class MyApp extends StatelessWidget {
    6. @override
    7. Widget build(BuildContext context) {
    8. return new MaterialApp(
    9. title: 'Welcome to Flutter',
    10. home: new Scaffold(
    11. appBar: new AppBar(
    12. title: new Text('Welcome to Flutter12'),
    13. ),
    14. body: Flex(
    15. direction: Axis.horizontal,
    16. children: [
    17. Container(
    18. width: 50,
    19. height: 200,
    20. color: Colors.black45,
    21. ),
    22. Expanded(
    23. flex: 1,
    24. child: Container(
    25. color: Colors.redAccent,
    26. height: 200,
    27. )
    28. ),
    29. Expanded(
    30. flex: 1,
    31. child: Container(
    32. color: Colors.blue,
    33. height: 200,
    34. )
    35. ),
    36. Expanded(
    37. flex: 1,
    38. child: Container(
    39. color: Colors.cyanAccent,
    40. height: 200,
    41. )
    42. )
    43. ],
    44. ),
    45. ),
    46. );
    47. }
    48. }