// 卡片练习布局
import 'package:flutter/material.dart';void main() => runApp(new MyApp());class MyApp extends StatefulWidget {@override_MyAppState createState() => _MyAppState();
}// 两张卡片组件 练习布局
class _MyAppState extends State<MyApp> {@overrideWidget build(BuildContext context) {return MaterialApp(title: '卡片练习',home: Scaffold(appBar: AppBar(title: Text("卡片组件练习")),body: Container(padding: EdgeInsets.all(0),child: ListView(children: <Widget>[getCardView1(),getCardView2(),getCardView3(),getCardView4()],),),),);}Widget getCardView1() {return Card(// 根据设置裁剪内容clipBehavior: Clip.antiAlias,color: Colors.lightBlue,// 设置卡片的阴影elevation: 20.0,margin: EdgeInsets.all(20.0),semanticContainer: true,shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)),child: Column(// 默认值 是子组件 自适应父组件mainAxisSize: MainAxisSize.min,children: <Widget>[const ListTile(// 标题leading: Icon(Icons.account_balance_wallet,color: Colors.white,),title: Text("主题",style: TextStyle(color: Colors.white, fontSize: 40.0),),subtitle: Text("这里是副标题的内容这里是副标题的内容",style: TextStyle(color: Colors.white, fontSize: 16.0),),contentPadding: EdgeInsets.only(left: 20.0, top: 10.0, bottom: 10.0, right: 20.0),// 点击按钮的内容),ButtonBar(children: <Widget>[FlatButton(onPressed: () {print("点击了关于");},child: Text("关于",style: TextStyle(color: Colors.white, fontSize: 14.0),)),FlatButton(onPressed: () {print("点击了设置");},child: Text("设置",style: TextStyle(color: Colors.white, fontSize: 14.0),))],)],),);}Widget getCardView2() {return Container(width: 300,height: 100,margin: EdgeInsets.all(20),decoration: BoxDecoration(borderRadius: BorderRadius.circular(20.0), color: Colors.black38),child: ListTile(//  leading: Icon(Icons.account_balance_wallet,color: Colors.blueAccent,),leading: Container(child: Column(mainAxisAlignment: MainAxisAlignment.center,children: <Widget>[Image.network("https://gss3.bdstatic.com/-Po3dSag_xI4khGkpoWK1HF6hhy/baike/w%3D268%3Bg%3D0/sign=30238593be119313c743f8b65d036bea/c995d143ad4bd1131090fc6356afa40f4bfb0505.jpg",width: 50.0,height: 50.0,fit: BoxFit.cover,)],),),title: Text("我是中间标题",textAlign: TextAlign.left,style: TextStyle(color: Colors.white54,fontSize: 20.0,),),subtitle: Text("我是二级副标题我是二级副标题",maxLines: 1,overflow: TextOverflow.ellipsis,),trailing: Icon(Icons.account_box,color: Colors.lightBlueAccent,),onTap: () {print("点击了ListTile控件");},),);}Widget getCardView3() {return Container(width: 300.0,margin: EdgeInsets.all(20.0),decoration: BoxDecoration(color: Colors.deepOrangeAccent,borderRadius: BorderRadius.circular(20.0)),child: Column(children: <Widget>[Container(margin: EdgeInsets.fromLTRB(10, 5, 10, 5),child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween,children: <Widget>[new Align(child: Text("左边",style: TextStyle(fontSize: 25.0, color: Colors.deepPurple),),),new Align(child: Text("右边"),)],),),getCardView2(),],),);}Widget getCardView4() {return Container(width: 100.0,height: 200.0,margin: EdgeInsets.all(20.0),decoration: BoxDecoration(color: Colors.deepPurpleAccent,borderRadius: BorderRadius.circular(20.0),// border: Border(bottom:BorderSide(width: 1,color: Color(0xffe5e5e5)))),child: Column(// mainAxisAlignment: MainAxisAlignment.center,children: <Widget>[// 第一个ContainerContainer(height: 50,decoration: BoxDecoration(border: Border(bottom: BorderSide(width: 1, color: Color(0xffe5e5e5)))),margin: EdgeInsets.fromLTRB(10, 5, 10, 0),child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween,children: <Widget>[new Align(child: Text("左边",style: TextStyle(color: Colors.white, fontSize: 20.0),),),new Align(child: Text("右边",style: TextStyle(color: Colors.white, fontSize: 25.0),),)],),),// 第二个ContainerContainer(height: 100.0,margin: EdgeInsets.fromLTRB(10, 5, 10, 0),decoration: BoxDecoration(// 设置边框的角度border: Border(bottom: BorderSide(width: 1, color: Color(0xffe5e5e5)))),child: ListTile(leading: Container(child: Column(mainAxisAlignment: MainAxisAlignment.center,children: <Widget>[Card(elevation: 2.0,shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5.0)),child: Image.network("https://gss3.bdstatic.com/-Po3dSag_xI4khGkpoWK1HF6hhy/baike/w%3D268%3Bg%3D0/sign=30238593be119313c743f8b65d036bea/c995d143ad4bd1131090fc6356afa40f4bfb0505.jpg",width: 50,height: 40,//fit: BoxFit.fill,),)],),),title: Text("我是主标题我是主标题",style: TextStyle(color: Colors.white30, fontSize: 20.0),overflow: TextOverflow.ellipsis,maxLines: 1,),subtitle: Text("我是二级标我是二级标题我是二级标题我是二级标题我是二级标题我是二级标题题",style: TextStyle(color: Colors.white30, fontSize: 15.0),maxLines: 1,overflow: TextOverflow.ellipsis,),trailing: Icon(Icons.account_balance_wallet),),),Container(height: 40,margin: EdgeInsets.fromLTRB(10, 0, 10, 0),child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween,children: <Widget>[new Align(child: Text("关于",style: TextStyle(color: Colors.white30, fontSize: 15.0),),),new Align(child: Text("设置",style: TextStyle(color: Colors.white30, fontSize: 15.0),),),new Align(child: Text("关闭",style: TextStyle(color: Colors.white30, fontSize: 15.0),),)],),)],),);}
}

Flutter 卡片练习相关推荐

  1. Flutter进阶—质感设计之卡片

    Card控件是质感设计中的卡片控件,作为详细信息的入口.卡片有圆角和阴影,卡片是用于表示一些相关信息的面板,例如相册,地理位置,餐食,联系细节等. import 'package:flutter/ma ...

  2. Flutter中AspectRatio、Card 卡片组件

    1. AspectRatio 组件 AspectRatio 的作用是根据设置调整子元素 child 的宽高比. AspectRatio 首先会在布局限制条件允许的范围内尽可能的扩展,widget 的高 ...

  3. iOS播放器、Flutter高仿书旗小说、卡片动画、二维码扫码、菜单弹窗效果等源码

    iOS精选源码 全网最详细购物车强势来袭 一款优雅易用的微型菜单弹窗(类似QQ和微信右上角弹窗) swift, UITableView的动态拖动重排CCPCellDragger 高仿书旗小说 Flut ...

  4. iOS播放器、Flutter高仿书旗小说、卡片动画、二维码扫码、菜单弹窗效果等源码...

    2019独角兽企业重金招聘Python工程师标准>>> iOS精选源码 全网最详细购物车强势来袭 一款优雅易用的微型菜单弹窗(类似QQ和微信右上角弹窗) swift, UITable ...

  5. 【Flutter】【widget】【card】卡片组件的使用和练习代码

    文章目录 前言 一.card是什么? 二.使用步骤 1.基础的使用 2.提升 总结 前言 一.card是什么? 卡片组件,可以制作很多卡片类型的widget,比如商品,个人信息卡片等 二.使用步骤 1 ...

  6. Flutter组件--卡片效果(card组件)

    Card是卡片组件块,内容可以由大多数类型的Widget构成,Card具有圆角和阴影,这让它看起来有立体感. 属性 说明 margin 外边距 child 子组件 elevation 阴影值的深度 c ...

  7. Flutter——实现网易云音乐的渐进式卡片切换

    介绍 此功能为 仿网易云音乐App的一部分 : 仿网易云音乐App 预览图 我们可以看到页面下方切换的卡片效果 分析 首先动画以 x轴分为两部分 : 左侧文字 和 右侧图片 右侧图片以 z轴 分为 : ...

  8. Flutter页面布局:Flutter AspectRatio、Card卡片组件、卡片图文列表

    1.Flutter AspectRatio组件 AspectRatio 的作用是根据设置调整子元素 child 的宽高比. AspectRatio 首先会在布局限制条件允许的范围内尽可能的扩展,wid ...

  9. Flutter UI自动化测试技术方案选型与探索

    Flutter页面无法直接使用Native测试工具定位元素,给自动化测试带来很多不便.虽然Google官方推出了Flutter driver 和 Integration test,但是在实际使用中存在 ...

最新文章

  1. jQuery.fn和jQuery.prototype区别。
  2. PMcaff微分享 | 为什么大部分女生爱星座?大部分男生恨星座?
  3. Web Dynpro for ABAP 之 Web Dynpro Window Web Dynpro Application
  4. win8 Windows 8 设置 默认浏览器
  5. Sqoop(二)常用命令及常数解析
  6. 严重: A child container failed during start
  7. 前端学习(1484):json-server工具使用
  8. 线程池异步线程中再次获取线程池资源的问题
  9. “华为”和“荣耀”手机有什么区别?
  10. 第007讲 地图映射,线包字
  11. do while新用法--方便数据验证时跳出
  12. 【python】编程语言入门经典100例--21
  13. sync是同步还是非同步_高速AD项目学习笔记——实现sync同步的经验
  14. Log4j日志等级设置详解
  15. 绘制一张好看的散点图及pearson和spearman相关性分析的选择
  16. QScrollArea样式设置
  17. instagram授权流程(第二篇)
  18. 【无标题】Windows10安全中心永久关闭教程
  19. struggle for English college test band 6
  20. 4 security management strategies for data center consolidation

热门文章

  1. edge浏览器受信任_Win10解决浏览器被强制默认为Edge的两种方法
  2. oppo导出照片计算机找不到了,oppo手机手机照片找不到了,怎么办
  3. 腾讯CSIG暑期后端实习面经(已offer)
  4. 原乡打谷节|十一黄金周,来原乡赏“刀山火海”,享丰收喜悦
  5. footer属性css,CSS基础-footer元素始终粘在浏览器底部的四种方法
  6. Python进阶,使用 opencv 调用摄像头进行拍照
  7. 区块链技术如何刺激物联网变革
  8. 往国外电子邮箱发邮件会进垃圾箱吗?
  9. 这款游戏的猫宠狗宠能上天!
  10. 测试面试题:cookie/session/token 分别表示什么意思,有什么区别?