抖动问题:底部溢出 57 像素

问题描述 投票:0回答:1

这是我在appBar中的底部preferredSize(preferredSize:Size.fromHeight(148.0))。

此错误仅在 IOS 中引发,而不是在 Android 中引发。我不知道为什么? 在每个选项卡上都会引发此错误,因此我认为我通过首选大小得到了此错误。 但如何解决这个问题我不明白。

此错误仅在 IOS 中引发,而不是在 Android 中引发。我不知道为什么? 在每个选项卡上都会引发此错误,因此我认为我通过首选大小得到了此错误。 但如何解决这个问题我不明白。

这是我的代码


import 'package:flutter/material.dart';
import 'package:showcaseview/showcaseview.dart';
import 'package:url_launcher/url_launcher.dart' as UrlLauncher;
import 'package:dropdown_button2/dropdown_button2.dart';
import 'dart:developer';
import '../../../APIMnager/APIManager.dart';
import '../../../APIMnager/preferences.dart';
import '../../../Constants/constants.dart';
import 'action_page.dart';
import 'holding_page.dart';
import 'overview_page.dart';
import 'report_page.dart';

class PMSListDataPage extends StatelessWidget {
  final panNum;
  final singlePMSData;
  final allPMSListData;

  const PMSListDataPage(
      {Key? key, this.panNum, this.singlePMSData, this.allPMSListData})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: ShowCaseWidget(
        onStart: (index, key) {
          log('onStart: $index, $key');
        },
        onComplete: (index, key) {
          log('onComplete: $index, $key');
          print("here me");
          if (index == 0) {
            Preferences.saveData("showCaseCount2", "2");
          }
        },
        blurValue: 1,
        builder: Builder(
            builder: (context) => PMSListDataPage1(
                panNum: panNum,
                singlePMSData: singlePMSData,
                allPMSListData: allPMSListData)),
        autoPlayDelay: const Duration(seconds: 3),
      ),
    );
  }
}

class PMSListDataPage1 extends StatefulWidget {
  final panNum;
  final singlePMSData;
  final allPMSListData;

  const PMSListDataPage1(
      {Key? key, this.panNum, this.singlePMSData, this.allPMSListData})
      : super(key: key);

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

class _PMSListDataPage1State extends State<PMSListDataPage1> {
  var selectedValue;

  ApiManager apiManager = ApiManager();

  final GlobalKey _one = GlobalKey();
  final GlobalKey _two = GlobalKey();
  final GlobalKey _three = GlobalKey();
  final scrollController = ScrollController();

  @override
  void initState() {
    super.initState();
  }


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: DefaultTabController(
          length: 4,
          child: Scaffold(
            resizeToAvoidBottomInset: false,
            appBar: AppBar(
              leading: Builder(
                builder: (BuildContext context) {
                  return IconButton(
                    icon: Icon(Icons.arrow_back_ios_rounded),
                    onPressed: () {
                      Navigator.pop(context);
                    },
                    tooltip: '',
                  );
                },
              ),
              elevation: 0,
              backgroundColor: skyBlue,
              title: Text(
                "PMS",
                style: TextStyle(fontSize: tSize16),
              ),
              actions: [
                Row(
                  children: [
                    Padding(
                        padding: const EdgeInsets.only(right: 8.0),
                        child: IconButton(
                            icon: Image.asset(
                              "assets/phone_icon.png",
                              height: 25,
                              width: 25,
                            ),
                            onPressed: () {
                              UrlLauncher.launch('tel:+91$UserRMNumber');
                            }))
                  ],
                )
              ],
              bottom: PreferredSize(
                preferredSize: Size.fromHeight(148.0),
                child: Column(
                  children: [
                    Container(
                      color: skyBlue,
                      height: 90,
                      child:
                      nameView(widget.singlePMSData, widget.allPMSListData),
                    ),
                    Padding(
                      padding: const EdgeInsets.only(bottom: 10.0),
                      child: TabBar(
                        overlayColor:
                        MaterialStateProperty.all(Colors.transparent),
                        indicatorColor: Colors.white,
                        unselectedLabelColor: lightBlue,
                        onTap: (v) {
                          searchHoldingsQuery.clear();
                          FocusScope.of(context).unfocus();
                        },
                        indicator: UnderlineTabIndicator(
                            borderSide: BorderSide(
                                color: Colors.white,
                                width: 3.2,
                                style: BorderStyle.solid),
                            insets: EdgeInsets.only(left: 30.0, right: 30)),
                        isScrollable: true,
                        labelColor: Colors.white,
                        tabs: [
                          Tab(
                            child: Text(
                              'OVERVIEW',
                            ),
                          ),
                          Tab(
                            child: Text(
                              'HOLDINGS',
                            ),
                          ),
                          Tab(
                            child: Text(
                              'REPORTS',
                            ),
                          ),
                          Tab(
                            child: Text(
                              'ACTIONS',
                            ),
                          ),
                        ],
                      ),
                    ),
                  ],
                ),
              ),
            ),
            body:
            TabBarView(physics: NeverScrollableScrollPhysics(), children: [
              Padding(
                padding: const EdgeInsets.only(top: 12.0),
                child: OverviewPage(),
              ),
              Padding(
                padding: const EdgeInsets.only(top: 12.0),
                child: HoldingPage(),
              ),
              Padding(
                padding: const EdgeInsets.only(top: 12.0),
                child: ReportPage(),
              ),
              Padding(
                padding: const EdgeInsets.only(top: 12.0),
                child: ActionPage(),
              ),
            ]),
          )),
    );
  }
}

extension WidgetExtension on _PMSListDataPage1State {
  nameView(singlePMSData, allPMSListData) {
    return Padding(
      padding: const EdgeInsets.only(left: 20, right: 20, top: 5, bottom: 0),
      child: Container(
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(15),
          color: Colors.white,
        ),
        child: DropdownButtonHideUnderline(
          child: DropdownButton2(
            onMenuClose: () {},
            onTap: () {},
            isExpanded: true,
            hint: Row(
              children: [
                SizedBox(
                  width: 10,
                ),
                Expanded(
                  child: Row(
                    children: [
                      Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Text(
                            singlePMSData['name'].toString(),
                            style: TextStyle(
                              fontSize: tSize16,
                              fontWeight: FontWeight.w600,
                              color: blackColor,
                            ),
                            overflow: TextOverflow.ellipsis,
                          ),
                          SizedBox(
                            height: 6,
                          ),
                          Row(
                            children: [
                              Text(
                                '₹ ${singlePMSData["current_value"]}',
                                style: TextStyle(
                                  fontSize: tSize16,
                                  fontWeight: FontWeight.w600,
                                  color: green2Color,
                                ),
                                overflow: TextOverflow.ellipsis,
                              ),
                              SizedBox(
                                width: 10,
                              ),
                            ],
                          ),
                        ],
                      ),
                    ],
                  ),
                ),
              ],
            ),
            items: allPMSListData.map<DropdownMenuItem<Object>>((option) {
              return DropdownMenuItem(
                value: option,
                child: Container(
                    width: double.infinity,
                    alignment: Alignment.centerLeft,
                    // padding: const EdgeInsets.fromLTRB(0,8.0,0,6.0),
                    child: Row(
                      children: [
                        SizedBox(
                          width: 10,
                        ),
                        Text(
                          option["name"],
                          style: TextStyle(
                            fontSize: tSize16,
                            fontWeight: FontWeight.w600,
                            color: blackColor,
                          ),
                          overflow: TextOverflow.ellipsis,
                        ),
                      ],
                    ),
                    decoration: BoxDecoration(
                        border: Border(
                            top: BorderSide(color: lightGreyColor, width: 1)))),
              );
            }).toList(),
            selectedItemBuilder: (con) {
              return allPMSListData.map<Widget>((item) {
                return Row(
                  children: [
                    SizedBox(
                      width: 10,
                    ),
                    Expanded(
                      child: Row(
                        children: [
                          Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: [
                              Text(
                                item['name'].toString(),
                                style: TextStyle(
                                  fontSize: tSize16,
                                  fontWeight: FontWeight.w600,
                                  color: blackColor,
                                ),
                                overflow: TextOverflow.ellipsis,
                              ),
                              SizedBox(
                                height: 6,
                              ),
                              Row(
                                children: [
                                  Text(
                                    "₹ ${item["current_value"]}",
                                    style: TextStyle(
                                      fontSize: tSize16,
                                      fontWeight: FontWeight.w600,
                                      color: green2Color,
                                    ),
                                    overflow: TextOverflow.ellipsis,
                                  ),
                                  SizedBox(
                                    width: 10,
                                  ),
                                ],
                              ),
                            ],
                          ),
                        ],
                      ),
                    ),
                  ],
                );
              }).toList();
            },
            value: selectedValue,
            onChanged: (dynamic value) {
              setState(() {
              });
            },
            icon: Container(
              width: 22,
              height: 22,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(3),
                color: skyBlue,
              ),
              child: Icon(
                Icons.keyboard_arrow_down,
                color: Colors.white,
                size: 17,
              ),
            ),
            iconOnClick: Container(
              width: 22,
              height: 22,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(3),
                color: skyBlue,
              ),
              child: Icon(
                Icons.keyboard_arrow_up,
                color: Colors.white,
                size: 17,
              ),
            ),
            iconSize: 14,
            buttonHeight: 70,
            buttonPadding: const EdgeInsets.only(left: 14, right: 14),
            buttonDecoration: BoxDecoration(
              borderRadius: BorderRadius.circular(14),
              border: Border.all(
                color: lightBlue,
              ),
              color: Colors.white,
            ),
            buttonElevation: 1,
            itemHeight: 44,
            itemPadding: const EdgeInsets.only(left: 14, right: 14),
            dropdownMaxHeight: 200,
            dropdownPadding: null,
            dropdownDecoration: BoxDecoration(
              borderRadius: BorderRadius.circular(14),
              color: Colors.white,
            ),
            dropdownElevation: 1,
            scrollbarRadius: const Radius.circular(40),
            scrollbarThickness: 3,
            scrollbarAlwaysShow: false,
            // offset: const Offset(-10, 0),
          ),
        ),
      ),
    );
  }
}

flutter flutter-layout flutter-dependencies flutter-animation flutter-test
1个回答
0
投票

-- 尝试包装 singleChild ScrollView 或包装到展开的小部件来解决此错误。

© www.soinside.com 2019 - 2024. All rights reserved.