image.png

    1. import 'package:flutter/material.dart';
    2. void main() => runApp(MyApp());
    3. class MyApp extends StatelessWidget {
    4. @override
    5. Widget build(BuildContext context) {
    6. Color color = Theme.of(context).primaryColor; //定义颜色
    7. // 创建一组 button
    8. Widget buttonSection = Container(
    9. child: Row(
    10. mainAxisAlignment: MainAxisAlignment.spaceEvenly,
    11. children: [
    12. _buildButtonColumn(color, Icons.call, 'CALL'),
    13. _buildButtonColumn(color, Icons.near_me, 'ROUTE'),
    14. _buildButtonColumn(color, Icons.share, 'SHARE')
    15. ],
    16. ));
    17. Widget textSection = Container(
    18. padding: const EdgeInsets.all(32),
    19. child: Text(
    20. 'Lake Oeschinen lies at the foot of the Blüemlisalp in the Bernese '
    21. 'Alps. Situated 1,578 meters above sea level, it is one of the '
    22. 'larger Alpine Lakes. A gondola ride from Kandersteg, followed by a '
    23. 'half-hour walk through pastures and pine forest, leads you to the '
    24. 'lake, which warms to 20 degrees Celsius in the summer. Activities '
    25. 'enjoyed here include rowing, and riding the summer toboggan run.',
    26. softWrap: true,
    27. ));
    28. return MaterialApp(
    29. title: 'Flutter layout demo',
    30. home: Scaffold(
    31. appBar: AppBar(
    32. title: Text('Flutter layout demo'),
    33. ),
    34. body: ListView(
    35. children: [
    36. Image.asset(
    37. 'images/lake.jpg',
    38. width: 600,
    39. height: 240,
    40. fit: BoxFit.cover,
    41. ),
    42. titleSection,
    43. buttonSection,
    44. textSection
    45. ],
    46. ),
    47. ),
    48. );
    49. }
    50. // 快速创建 button 的方法
    51. Column _buildButtonColumn(Color color, IconData icon, String label) {
    52. return Column(
    53. mainAxisSize: MainAxisSize.min,
    54. mainAxisAlignment: MainAxisAlignment.center,
    55. children: [
    56. Icon(icon, color: color),
    57. Container(
    58. margin: const EdgeInsets.only(top: 8),
    59. child: Text(label,
    60. style: TextStyle(
    61. fontSize: 12,
    62. fontWeight: FontWeight.w400,
    63. color: color,
    64. ))),
    65. ],
    66. );
    67. }
    68. }
    69. // 顶部 title Widget
    70. Widget titleSection = Container(
    71. padding: const EdgeInsets.all(32), // 容器 padding 32
    72. child: Row(
    73. // 定义一行 Row
    74. children: [
    75. Expanded(
    76. /*1 定义一列*/
    77. child: Column(
    78. crossAxisAlignment: CrossAxisAlignment.start,
    79. children: [
    80. /*2*/
    81. Container(
    82. padding: const EdgeInsets.only(bottom: 8),
    83. child: Text(
    84. 'Oeschinen Lake Campground',
    85. style: TextStyle(
    86. fontWeight: FontWeight.bold,
    87. ),
    88. ),
    89. ),
    90. Text(
    91. 'Kandersteg, Switzerland',
    92. style: TextStyle(
    93. color: Colors.grey[500],
    94. ),
    95. ),
    96. ],
    97. ),
    98. ),
    99. /*3*/
    100. Icon(
    101. Icons.star,
    102. color: Colors.red[500],
    103. ),
    104. Text('41'),
    105. ],
    106. ),
    107. );