效果图

    0E6D69D5F73CFD8B58639F8FFF2F27FA.jpg

    1. class ContentView extends StatelessWidget {
    2. @override
    3. Widget build(BuildContext context) {
    4. return Column(
    5. mainAxisAlignment: MainAxisAlignment.start,
    6. crossAxisAlignment: CrossAxisAlignment.center,
    7. children: [
    8. Container(
    9. padding: const EdgeInsets.all(10),
    10. child: Row(
    11. mainAxisAlignment: MainAxisAlignment.center,
    12. children: [
    13. Container(
    14. alignment: Alignment.center,
    15. width: 300,
    16. height: 100,
    17. color: Colors.black,
    18. )
    19. ],
    20. )
    21. ),
    22. Container(
    23. width: 300,
    24. height: 100,
    25. child: Row(
    26. children: [
    27. Expanded(
    28. child: Container(
    29. color: Colors.deepPurple
    30. ),
    31. flex: 2
    32. ),
    33. const SizedBox(
    34. width: 10
    35. ),
    36. Expanded(
    37. child: Column(
    38. children: [
    39. Container(
    40. height: 45,
    41. color: Colors.pink,
    42. ),
    43. const SizedBox(
    44. height: 10,
    45. ),
    46. Container(
    47. height: 45, // 注意加了SizeBox之后高度计算的时候要避免溢出
    48. color: Colors.orange
    49. )
    50. ],
    51. ),
    52. flex: 1
    53. )
    54. ],
    55. ),
    56. )
    57. ],
    58. );
    59. }
    60. }