flutter 页面中间tab切换

本文探讨了在Flutter中处理页面中间Tab切换时遇到的问题,特别是面对页面高度不一致的场景,目前尚无理想解决方案,当前采取的是隐藏后再显示的临时对策。
摘要由CSDN通过智能技术生成
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get/get_utils/get_utils.dart';
import 'package:nb_utils/nb_utils.dart';
import 'package:toptongpin/app/common/widgets/image/local_image.dart';
import 'package:toptongpin/app/pages/MyAccount/views/widgets/EmptyCard.dart';
import 'package:toptongpin/app/pages/makeMoneryCenter/views/page_view_scroll_utils.dart';
import 'package:toptongpin/app/utils/config_util.dart';
import 'package:toptongpin/app/utils/extensions/size_fit.dart';
import 'package:toptongpin/app/utils/object_util.dart';
import 'package:toptongpin/app/utils/screen_util.dart';

import '../../../common/widgets/button/gradient_button.dart';
import '../../../common/widgets/tab/round_indicator.dart';
import '../../../res/colors.dart';
import '../../../res/styles.dart';
import '../controllers/my_earnings_controller.dart';
import '../model/myEarning.dart';
import '../model/tab.dart';
import '../widget/indicator.dart';

class ProfitPage extends StatefulWidget {
  @override
  _ProfitPageState createState() => _ProfitPageState();
}

class _ProfitPageState extends State<ProfitPage>
    with SingleTickerProviderStateMixin {
  late TabController _tabController;
  PageViewScrollUtils? _pageViewScrollUtils;
  PageController _pageController = PageController();
 MyEarningsController controller = Get.find();
  List<Tabs> listTabs = [];

  @override
  void initState() {
    listTabs = [];
    listTabs.add(Tabs(
        tabName: '动态', moneyNum: controller.myProfit?.dycProfitNum ?? 0.0));
    listTabs.add(Tabs(
        tabName: '聊天', moneyNum: controller.myProfit?.msgProfitNum ?? 0.0));
    listTabs.add(Tabs(
        tabName: '赚钱', moneyNum: controller.myProfit?.makeProfitNum ?? 0.0));
    super.initState();
    _tabController =
        TabController(initialIndex: controller.i, length: 3, vsync: this)
          ..addListener(() {
            if (!_tabController.indexIsChanging) {
              controller.setType(_tabController.index);
            }
          });
    _pageViewScrollUtils = PageViewScrollUtils(_pageController, _tabController);
  }

  //height: (200.w * _.taskTyroList.length) + 172.w,
  @override
  Widget build(BuildContext context) {
    return GetBuilder<MyEarningsController>(builder: (_) {
      return EmptyCard(Container(
          height: _.tabIcon.length == 0
              ? 650.w
              : ((_.tabIcon.length) * 160.w + 350.w),
          child: Column(
            mainAxi
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值