12Flutter页面布局 AspectRatio和Cart卡片组件

import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
} class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
// TODO: implement build
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text(' AspectRatio、Cart卡片组件'),
),
body: HomeContent(),
),
);
}
} class HomeContent extends StatelessWidget {
@override
Widget build(BuildContext context) {
//Stack结合align实现布局:
return AspectRatio(
aspectRatio: 2.0/1.0,
child: Container(
color: Colors.red,
),
);
}
}
Cart卡片组件:
demo1:
main.dart
import 'package:flutter/material.dart'; void main() {
runApp(MyApp());
} class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
// TODO: implement build
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text(' AspectRatio、Cart卡片组件'),
),
body: HomeContent(),
),
);
}
} class HomeContent extends StatelessWidget {
@override
Widget build(BuildContext context) {
//Stack结合align实现布局:
return ListView(
children: <Widget>[
Card(
child: Column(
children: <Widget>[
ListTile(title: Text('中国'), subtitle: Text('山东')),
ListTile(
title: Text('青岛'),
),
ListTile(
title: Text('烟台'),
)
],
),
),
Card(
child: Column(
children: <Widget>[
ListTile(title: Text('中国'), subtitle: Text('山东')),
ListTile(
title: Text('青岛'),
),
ListTile(
title: Text('烟台'),
)
],
),
)
],
);
}
}
demo2:
main.dat
demo3:
main.dart
import 'package:flutter/material.dart';
import 'res/listData.dart'; void main() {
runApp(MyApp());
} class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
// TODO: implement build
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text(' AspectRatio、Cart卡片组件'),
),
body: HomeContent(),
),
);
}
} class HomeContent extends StatelessWidget {
@override
Widget build(BuildContext context) {
//Stack结合align实现布局:
return ListView(
children: listData.map((value) {
return Card(
margin: EdgeInsets.all(),
child: Column(
children: <Widget>[
AspectRatio(
aspectRatio: / ,
child: Image.network(
"${value['imageUrl']}",
fit: BoxFit.cover),
),
ListTile(
leading: CircleAvatar(
backgroundImage: NetworkImage(
"${value['imageUrl']}"),
),
title: Text("${value['title']}"),
subtitle: Text("${value['descripts']}",maxLines:,overflow: TextOverflow.ellipsis,))
],
),
);
}).toList(),
);
}
}
listData.dart
List listData=[
{
"title":"Candy Shop",
"author":"Mohamed Chahin",
"imageUrl":"https://www.itying.com/images/flutter/1.png",
"descripts":"MohamedChahinMohamedChahinMohamedChahinMohamedChahinMohamedChahinMohamedChahinMohamedChahinMohamedChahinMohamedChahinMohamedChahin"
},
{
"title":"Candy Shop",
"author":"Mohamed Chahin",
"imageUrl":"https://www.itying.com/images/flutter/2.png",
"descripts":"MohamedChahinMohamedChahinMohamedChahinMohamedChahinMohamedChahinMohamedChahinMohamedChahinMohamedChahinMohamedChahinMohamedChahin" },
{
"title":"Candy Shop",
"author":"Mohamed Chahin",
"imageUrl":"https://www.itying.com/images/flutter/3.png",
"descripts":"MohamedChahinMohamedChahinMohamedChahinMohamedChahinMohamedChahinMohamedChahinMohamedChahinMohamedChahinMohamedChahinMohamedChahin" },
{
"title":"Candy Shop",
"author":"Mohamed Chahin",
"imageUrl":"https://www.itying.com/images/flutter/4.png",
"descripts":"MohamedChahinMohamedChahinMohamedChahinMohamedChahinMohamedChahinMohamedChahinMohamedChahinMohamedChahinMohamedChahinMohamedChahin" },{
"title":"Candy Shop",
"author":"Mohamed Chahin",
"imageUrl":"https://www.itying.com/images/flutter/5.png",
"descripts":"MohamedChahinMohamedChahinMohamedChahinMohamedChahinMohamedChahinMohamedChahinMohamedChahinMohamedChahinMohamedChahinMohamedChahin" }
];
12Flutter页面布局 AspectRatio和Cart卡片组件的更多相关文章
- 10Flutter页面布局 Padding Row Column Expanded组件详解:
Padding组件: main.dart import 'package:flutter/material.dart'; import 'res/listData.dart'; /* flutter页 ...
- Flutter AspectRatio、Card 卡片组件
Flutter AspectRatio 组件 AspectRatio 的作用是根据设置调整子元素 child 的宽高比. AspectRatio 首先会在布局限制条件允许的范围内尽可能的扩展,widg ...
- flutter 页面布局 Paddiing Row Column Expanded 组件
Flutter Paddiing 组件 在 html 中常见的布局标签都有 padding 属性,但是 Flutter 中很多 Widget 是没有 padding 属 性.这个时候我们可以用 Pad ...
- 页面布局 Paddiing Row Column Expanded 组件详解
一.Paddiing 组件 padding EdgeInsetss 设置填充的值 child 组件 return Padding( padding: EdgeIn ...
- AspectRatio图片的宽高比、Card 卡片组件
一.AspectRatio 组件 AspectRatio 的作用是根据设置调整子元素 child 的宽高比. AspectRatio 首先会在布局限制条件允许的范围内尽可能的扩展,widget 的高度 ...
- 046——VUE中组件之使用动态组件灵活设置页面布局
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 13Flutter页面布局 Wrap组件
/* Flutter页面布局Wrap组件: Wrap可以实现流布局,单行的Wrap跟Row表现几乎一致,单列的Wrap则跟Row表现几乎一致. 但Row与Column都是单行单列的.Wrap则突破了这 ...
- 11Flutter页面布局 Stack层叠组件 Stack与Align Stack与Positioned实现定位布局
/* Flutter 页面布局 Stack层叠组件: Stack与Align Stack与Positioned实现定位布局: Flutter Stack组件: Stack表示堆得意思,我们可以用Sta ...
- 《React后台管理系统实战 :二》antd左导航:cmd批量创建子/目录、用antd进行页面布局、分离左导航为单独组件、子路由、动态写左导航、css样式相对陷阱
一.admin页面布局及路由创建 0)cmd批量创建目录及子目录 //创建各个目录,及charts和子目录bar md home category product role user charts\b ...
随机推荐
- jeffy-vim-v2.9
http://pan.baidu.com/s/1qW1DlP6
- .NET Framework 概述
文章标题:.NET Framework 概述 地址:https://docs.microsoft.com/zh-cn/dotnet/framework/get-started/overview NET ...
- Java&Selenium智能等待方法封装
Java&Selenium智能等待方法封装 ExpectedConditions方法还有很多,自然也可以继续扩展很多 package util; import org.openqa.selen ...
- 【Java基础-实验7】Banking_7 -添加银行透支扣款系统的 thorw异常机制
实验基本要求: 实验题目 7:(在6基础上修改) 将建立一个 OverdraftException 异常,它由 Account 类的withdraw()方法 抛出. 实验目的: 自定义异常 实验说明: ...
- 可能是最全面的 Python 字符串拼接总结
来源: 枫恋寒 链接: https://segmentfault.com/a/119000001.png"font-size: 12px;"> 在 Python 中字符串连接 ...
- 基于 es6 的 javascript 实用方法
一.求数字数组的平均数 - 使用 数组的 reduce() 方法将每个值添加到累加器,初始值为0,总和除以数组长度. const average = arr => arr.reduce((acc ...
- JS遍历表格获取每行数据及每个单元格数据
/** * 遍历表格获取每行数据及每个单元格数据 * @param tableID 表格ID */ function GetTable(tableID) { var milasUrl = {};//新 ...
- Java并发包--ConcurrentLinkedQueue
转载请注明出处:http://www.cnblogs.com/skywang12345/p/3498995.html ConcurrentLinkedQueue介绍 ConcurrentLinkedQ ...
- Java中的Listener 监听器
Listener的定义与作用 监听器Listener就是在application,session,request三个对象创建.销毁或者往其中添加修改删除属性时自动执行代码的功能组件. Listener ...
- Day1 读题解题提升
The 2014 ACM-ICPC Asia Mudanjiang Regional Contest 昨晚做了训练赛,然后读题又自闭了QAQ. Average Score ZOJ - 3819 题意: ...