flutter9 商品详情顶部tab切换 顶部下拉菜单 底部浮动导航

本文介绍了如何使用Flutter构建商品详情页面的顶部Tab切换效果和底部下拉菜单功能,详细讲解了相关组件的使用及交互实现,适用于Android和iOS平台的开发。
摘要由CSDN通过智能技术生成

import 'package:flutter/material.dart';
import 'package:fultter/flutter_jdshop/pages/ProductContent/ProductContentFirst.dart';
import 'package:fultter/flutter_jdshop/pages/ProductContent/ProductContentSecond.dart';
import 'package:fultter/flutter_jdshop/pages/ProductContent/ProductContentThird.dart';
import 'package:fultter/flutter_jdshop/services/ScreenAdaper.dart';

class ProductContentPage extends StatefulWidget {
  final Map arguments;
  const ProductContentPage({Key? key,required this.arguments}) : super(key: key);

  @override
  _ProductContentPageState createState() => _ProductContentPageState();
}

class _ProductContentPageState extends State<ProductContentPage> {
  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
        length: 3,
        child: Scaffold(
          appBar: AppBar(
            title: Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Container(
                  width: ScreenAdaper.width(400),
                  child: TabBar(
                    indicatorColor: Colors.red,
                    indicatorSize: TabBarIndicatorSize.label,
                    tabs: [
                      Tab(
                        child: Text('商品'),
                      ),
                      Tab(
                        child: Text('详情'),
                      ),
                      Tab(
                        child: Text('评价'),
                      ),
                    ],
                  ),
                  
                )
              ],
            ),
            actions: [
              IconButton(
                  icon: Icon(Icons.more_horiz),
                  onPressed: (){
                    showMenu(
                        context: context,
                        position: RelativeRect.fromLTRB(ScreenAdaper.width(600), 76, 10, 0),
                        items: [
                          PopupMenuItem(
                              child: Row(
                                children: [
                                  Icon(Icons.home),
                                  Text("首页")
                                ],
                              )
                          ),
                          PopupMenuItem(
                              child: Row(
                                children: [
                                  Icon(Icons.search),
                                  Text("搜索")
                                ],
                              )
                          )
                        ]
                    );
                  },
                  )
            ],
          ),
          body: Stack(
            children: [
              TabBarView(
                  children: [
                    ProductContentFirst(),
                    ProductContentSecond(),
                    ProductContentThird(),
                  ]
              ),
              Positioned(
                  width: ScreenAdaper.width(750),
                  height: ScreenAdaper.height(80),
                  bottom: 0,
                  child:Container(
                    color: Colors.red,
                    child: Text("底部"),
                  ) 
              )
            ],
          ),
        ));
  }
}
ProductContentFirst.dart
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:fultter/flutter_jdshop/services/ScreenAdaper.dart';

class ProductContentFirst extends StatefulWidget {
  const ProductContentFirst({Key? key}) : super(key: key);

  @override
  _ProductContentFirstState createState() => _ProductContentFirstState();
}

class _ProductContentFirstState extends State<ProductContentFirst> {
  @override
  Widget build(BuildContext context) {
    return
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值