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 ...
随机推荐
- 排序算法(冒泡、选择)-python代码展示
冒泡排序: def bubble_sort(list): for i in range(len(list) - 1): # 这个循环负责设置冒泡排序进行的次数 for j in range(len(l ...
- 用js刷剑指offer(用两个栈实现队列)
题目描述 用两个栈来实现一个队列,完成队列的Push和Pop操作. 队列中的元素为int类型. 牛客网链接 js代码 let stack1 = [] let stack2 = [] function ...
- SP116 INTERVAL - Intervals
题意翻译 区间取数 题目描述 有n个区间,在区间[ai,bi]中至少取任意互不相同的ci个整数.求在满足n个区间的情况下,至少要取多少个正整数. 输入输出格式 输入格式 多组数据. 第一行的一个整数T ...
- 堆排序Heap_Sort
堆排序就是借助二叉堆进行排序,不了解二叉堆的可以先看这里.本文以升序排序为例,首先将待排序数组放置在最小堆中,此时堆顶一定是数组中最小的元素,然后删除堆顶元素,此时调整后的最小堆顶会是第二小的元素,从 ...
- python_面向对象——对象之间的关联关系
1.将类中的对象关联起来(简单的方法) class Person: def __init__(self,name,age,sex): self.name = name self.age = age s ...
- 15-Node.js学习笔记-Express的安装及检验
最新的node已经把一些命令工具单独的分出来了,所以我们应该先下安装他的打包函数,再安装express,在进行检验就安装成功了 如需require还需在文件夹内单独安装 sudo npm instal ...
- yii 查询垃圾分类接口
public function actionGarbage() { // $param = \Yii::$app->request->post('rubbish', ''); // 接收j ...
- sql server 的 out 和output
sql中out与output --SQLQuery Create By Faywool create proc Proc_OutPutTest--创建 @numA int,--nu ...
- Codeforces Educational Codeforces Round 67
目录 Contest Info Solutions A. Stickers and Toys B. Letters Shop C. Vasya And Array D. Subarray Sortin ...
- 2018CCPCFINAL B Balance of the Force 枚举最大值
题意 n个人能选择黑暗面和光明面,选择两个面分别能获得\(L_i\)和\(R_i\)的力量,有m对人不能选择同一面,问n个人的力量中的最大值-最小值尽可能小为多少. \(1<=n<=2\t ...