当前位置:   article > 正文

第7章页面布局-Container容器布局_container.newborder

container.newborder

防采集标记:亢少军老师的课程和资料

  1. import 'package:flutter/material.dart';
  2. void main() => runApp(
  3. new MaterialApp(
  4. title: 'Container布局容器示例',
  5. home: new LayoutDemo(),
  6. ),
  7. );
  8. class LayoutDemo extends StatelessWidget {
  9. @override
  10. Widget build(BuildContext context) {
  11. //返回一个Container对象
  12. Widget container = new Container(
  13. //添加装饰效果
  14. decoration: new BoxDecoration(
  15. color: Colors.grey,
  16. ),
  17. //子元素指定为一个垂直水平嵌套布局的组件
  18. child: new Column(
  19. children: [
  20. new Row(
  21. children: [
  22. //使用Expanded防止内容溢出
  23. new Expanded(
  24. child: new Container(
  25. width: 150.0,
  26. height: 150.0,
  27. //添加边框样式
  28. decoration: new BoxDecoration(
  29. //上下左右边框设置为宽度10.0 颜色为蓝灰色
  30. border: new Border.all(width: 10.0, color: Colors.blueGrey),
  31. //上下左右边框弧度设置为8.0
  32. borderRadius:
  33. const BorderRadius.all(const Radius.circular(8.0)),
  34. ),
  35. //上下左右增加边距
  36. margin: const EdgeInsets.all(4.0),
  37. //添加图片
  38. child: new Image.asset('images/1.jpeg'),
  39. ),
  40. ),
  41. new Expanded(
  42. child: new Container(
  43. width: 150.0,
  44. height: 150.0,
  45. decoration: new BoxDecoration(
  46. border: new Border.all(width: 10.0, color: Colors.blueGrey),
  47. borderRadius:
  48. const BorderRadius.all(const Radius.circular(8.0)),
  49. ),
  50. margin: const EdgeInsets.all(4.0),
  51. child: new Image.asset('images/2.jpeg'),
  52. ),
  53. ),
  54. ],
  55. ),
  56. new Row(
  57. children: [
  58. new Expanded(
  59. child: new Container(
  60. width: 150.0,
  61. height: 150.0,
  62. decoration: new BoxDecoration(
  63. border: new Border.all(width: 10.0, color: Colors.blueGrey),
  64. borderRadius:
  65. const BorderRadius.all(const Radius.circular(8.0)),
  66. ),
  67. margin: const EdgeInsets.all(4.0),
  68. child: new Image.asset('images/3.jpeg'),
  69. ),
  70. ),
  71. new Expanded(
  72. child: new Container(
  73. width: 150.0,
  74. height: 150.0,
  75. decoration: new BoxDecoration(
  76. border: new Border.all(width: 10.0, color: Colors.blueGrey),
  77. borderRadius:
  78. const BorderRadius.all(const Radius.circular(8.0)),
  79. ),
  80. margin: const EdgeInsets.all(4.0),
  81. child: new Image.asset('images/2.jpeg'),
  82. ),
  83. ),
  84. ],
  85. ),
  86. ],
  87. ),
  88. );
  89. return new Scaffold(
  90. appBar: new AppBar(
  91. title: new Text('Container布局容器示例'),
  92. ),
  93. body: container,
  94. );
  95. }
  96. }

@作者: 亢少军

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/231648
推荐阅读
相关标签
  

闽ICP备14008679号