19 Flutter仿京东商城项目 商品详情 底部浮动导航布局 商品页面布局
效果:
widget/JdButton.dart
import 'package:flutter/material.dart';
import '../services/ScreenAdaper.dart'; class JdButton extends StatelessWidget { final Color color;
final String text;
final Object cb;
JdButton({Key key,this.color=Colors.black,this.text='按钮',this.cb=null}) : super(key: key); @override
Widget build(BuildContext context) {
return InkWell(
onTap:this.cb,
child: Container(
margin: EdgeInsets.all(),
padding: EdgeInsets.all(),
height: ScreenAdaper.height(),
width: double.infinity,
decoration: BoxDecoration(
color: color,
borderRadius: BorderRadius.circular()),
child: Center(
child: Text(text, style: TextStyle(color: Colors.white)),
),
),
);
}
}
pages/ProductContent.dart
import 'package:flutter/material.dart';
import '../services/ScreenAdaper.dart';
import 'ProductContent/ProductContentFirst.dart';
import 'ProductContent/ProductContentSecond.dart';
import 'ProductContent/ProductContentThird.dart';
import '../widget/JdButton.dart';
class ProductContentPage extends StatefulWidget {
final Map arguments;
ProductContentPage({Key key, this.arguments}) : super(key: key); _ProductContentPageState createState() => _ProductContentPageState();
} class _ProductContentPageState extends State<ProductContentPage> {
@override
Widget build(BuildContext context) {
return DefaultTabController(
length: ,
child: Scaffold(
appBar: AppBar(
title: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
width: ScreenAdaper.width(),
child: TabBar(
indicatorColor: Colors.red,
indicatorSize: TabBarIndicatorSize.label,
tabs: <Widget>[
Tab(
child: Text('商品'),
),
Tab(
child: Text('详情'),
),
Tab(
child: Text('评价'),
)
],
),
)
],
),
actions: <Widget>[
IconButton(
icon: Icon(Icons.more_horiz),
onPressed: () {
showMenu(
context: context,
position: RelativeRect.fromLTRB(
ScreenAdaper.width(), , , ),
items: [
PopupMenuItem(
child: Row(
children: <Widget>[Icon(Icons.home), Text('首页')],
),
),
PopupMenuItem(
child: Row(
children: <Widget>[Icon(Icons.search), Text('搜索')],
),
),
]);
},
)
],
),
body: Stack(
children: <Widget>[
TabBarView(
children: <Widget>[
ProductContentFirst(),
ProductContentSecond(),
ProductContentThird()
],
),
Positioned(
width: ScreenAdaper.width(),
height: ScreenAdaper.height(),
bottom: ,
child: Container(
decoration: BoxDecoration(
border: Border(
top: BorderSide(color: Colors.black54, width: )),
color: Colors.white),
child: Row(
children: <Widget>[
Container(
padding: EdgeInsets.only(top: ScreenAdaper.height()),
width: ,
height: ScreenAdaper.height(),
child: Column(
children: <Widget>[
Icon(
Icons.shopping_cart,
size: ,
),
Text('购物车')
],
),
),
Expanded(
flex: ,
child: JdButton(
color: Color.fromRGBO(, , , 0.9),
text: "加入购物车",
cb: (){
print('加入购物车');
},
),
),
Expanded(
flex: ,
child: JdButton(
color: Color.fromRGBO(, , , 0.9),
text: "立即购物",
cb: (){
print('立即购物');
},
),
)
],
),
),
)
],
),
),
);
}
}
pages/ProductContent/ProductContentFirst.dart
import 'package:flutter/material.dart';
import '../../services/ScreenAdaper.dart';
class ProductContentFirst extends StatefulWidget {
ProductContentFirst({Key key}) : super(key: key); _ProductContentFirstState createState() => _ProductContentFirstState();
} class _ProductContentFirstState extends State<ProductContentFirst> {
@override
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.all(),
child:ListView(
children: <Widget>[
AspectRatio(
aspectRatio: /,
child: Image.network("https://www.itying.com/images/flutter/p1.jpg",fit: BoxFit.cover,)
),
Container(
padding: EdgeInsets.only(top: ),
child: Text("联想ThinkPad联想ThinkPad联想ThinkPad联想ThinkPad联想ThinkPad联想ThinkPad联想ThinkPad",style: TextStyle(
color: Colors.black87,
fontSize: ScreenAdaper.size()
)),
),
Container(
padding: EdgeInsets.only(top: ),
child: Text("联想ThinkPad联想ThinkPad联想ThinkPad联想ThinkPad联想ThinkPad联想ThinkPad联想ThinkPad",style: TextStyle(
color: Colors.black54,
fontSize: ScreenAdaper.size()
)),
),
Container(
padding: EdgeInsets.only(top:),
child: Row(
children: <Widget>[ Expanded(
flex: ,
child: Row(
children: <Widget>[
Text('特价'),
Text('¥28',style: TextStyle(
color: Colors.red,
fontSize: ScreenAdaper.size()
))
],
),
), Expanded(
flex: ,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Text('原价'),
Text('¥50',style: TextStyle(
color: Colors.black38,
fontSize: ScreenAdaper.size(),
decoration: TextDecoration.lineThrough
))
],
),
) ],
),
),
//筛选:
Container(
margin: EdgeInsets.only(top:),
height: ScreenAdaper.height(),
child: Row(
children: <Widget>[
Text('已选',style: TextStyle(
fontWeight: FontWeight.bold
)),
Text('115,黑色')
],
),
),
Divider(),
Container(
height: ScreenAdaper.height(),
child: Row(
children: <Widget>[
Text('运费',style: TextStyle(
fontWeight: FontWeight.bold
)),
Text('免运费')
],
),
),
Divider()
],
)
);
}
}
pages/ProductContent/ProductContentSecond.dart
import 'package:flutter/material.dart';
class ProductContentSecond extends StatefulWidget {
ProductContentSecond({Key key}) : super(key: key); _ProductContentSecondState createState() => _ProductContentSecondState();
} class _ProductContentSecondState extends State<ProductContentSecond> {
@override
Widget build(BuildContext context) {
return Container(
child: Text('商品详情'),
);
}
}
pages/ProductContent/ProductContentThird.dart
import 'package:flutter/material.dart';
class ProductContentThird extends StatefulWidget {
ProductContentThird({Key key}) : super(key: key); _ProductContentThirdState createState() => _ProductContentThirdState();
} class _ProductContentThirdState extends State<ProductContentThird> {
@override
Widget build(BuildContext context) {
return Container(
child: Text('商品评论'),
);
}
}
19 Flutter仿京东商城项目 商品详情 底部浮动导航布局 商品页面布局的更多相关文章
- 01-02 Flutter仿京东商城项目 功能分析、底部导航Tab切换以及路由配置、架构搭建:(Flutter仿京东商城项目 首页布局以及不同终端屏幕适配方案)
Flutter和Dart交流学习群:交流群:452892873 01Flutter仿京东商城项目 功能分析.底部导航Tab切换以及路由配置.架构搭建 02Flutter仿京东商城项目 首页布局以及不同 ...
- 18 Flutter仿京东商城项目 商品详情顶部tab切换 顶部下拉菜单 底部浮动导航
ProductContent.dart import 'package:flutter/material.dart'; import '../services/ScreenAdaper.dart'; ...
- 42 Flutter仿京东商城项目 修改默认收货地址 显示默认收货地址
CheckOut.dart import 'package:flutter/material.dart'; import '../services/ScreenAdapter.dart'; impor ...
- 41 Flutter 仿京东商城项目签名验证 增加收货地址、显示收货地址 事件广播
加群452892873 下载对应41课文件,运行方法,建好项目,直接替换lib目录 AddressAdd.dart import 'package:dio/dio.dart'; import 'pac ...
- 36 Flutter仿京东商城项目 用户登录 退出登录 事件广播更新状态
Login.dart import 'dart:convert'; import 'package:dio/dio.dart'; import 'package:flutter/material.da ...
- 20 Flutter仿京东商城项目 商品详情 底部弹出筛选属性 以及筛选属性页面布局
ProductContentFirst.dart import 'package:flutter/material.dart'; import '../../widget/JdButton.dart' ...
- 22 Flutter仿京东商城项目 inappbrowser 加载商品详情、保持页面状态、以及实现属性筛选业务逻辑
加群452892873 下载对应21可文件,运行方法,建好项目,直接替换lib目录,在往pubspec.yaml添加上一下扩展. cupertino_icons: ^0.1.2 flutter_swi ...
- 21 Flutter仿京东商城项目 商品详情 请求接口渲染数据 商品属性数据渲染
加群452892873 下载对应21可文件,运行方法,建好项目,直接替换lib目录,在往pubspec.yaml添加上一下扩展. cupertino_icons: ^0.1.2 flutter ...
- 13 Flutter仿京东商城项目 商品列表筛选以及上拉分页加载更多
ProductList.dart import 'package:flutter/material.dart'; import '../services/ScreenAdaper.dart'; imp ...
随机推荐
- c#通用语言运行时CLR
- spring实例化一:InstantiationStrategy
DefaultListableBeanFactory对bean的管理工厂,包括bean的生成,从class到bean的实例化.spring特为这个实例化过程,定义了接口Instantiat ...
- Oracle12c-ADG搭建
实验环境: 角色 IP hostname CDB name db_unique_name pdb name 版本 主 192.168.0.115 Node11 cdb1 cdb_p pdb1 12.2 ...
- C语言学习系列(三)C程序结构
一.C程序结构 C 程序主要包括以下部分: 预处理器指令 函数 变量 语句 & 表达式 注释 new C program demo: #include <stdio.h> /*预处 ...
- .Net Core: 跨域Cros概要
读取配置 public class AppConfig { public static IConfigurationRoot Configuration { get; set; } public st ...
- SP703 SERVICE - Mobile Service
思路:DP 提交:1次 题解: 我们把处理到的要求作为阶段. \(f[i][x][y][z]\)表示第 \(i\) 个要求,三个人分别的位置. 发现这样有很多无用状态,因为显然在第 \(i\) 个要求 ...
- Vue中用props给data赋初始值遇到的问题解决
Vue中用props给data赋初始值遇到的问题解决 更新时间:2018年11月27日 10:09:14 作者:yuyongyu 我要评论 这篇文章主要介绍了Vue中用props给dat ...
- ICP、MRR、BKA等特性
一.Index Condition Pushdown(ICP) Index Condition Pushdown (ICP)是 mysql 使用索引从表中检索行数据的一种优化方式,从mysql5.6开 ...
- 将省市县三级联动的json数据,转化为element-ui能用的格式,并使用
var options=[]; var cities = { '北京': { '北京': ['东城区', '西城区', '崇文区', '宣武区', '朝阳区', '丰台区', '石景山区', '海淀区 ...
- 7月清北学堂培训 Day 3
今天是丁明朔老师的讲授~ 数据结构 绪论 下面是天天见的: 栈,队列: 堆: 并查集: 树状数组: 线段树: 平衡树: 下面是不常见的: 主席树: 树链剖分: 树套树: 下面是清北学堂课程表里的: S ...