Flutter TextField 底部溢出 TabBar

时间:2020-12-19 10:55:13

标签: flutter dart

嘿,伙计们,我需要你们的帮助,我已经尝试让它工作了一段时间,但它是否找到了我错的地方,这里是代码,所以你们可以看到。

Widget build(BuildContext context) {
SystemChrome.setEnabledSystemUIOverlays([]);
SizeConfig().init(context);
return Scaffold(
  appBar: AppBar(
    elevation: 20,
    actions: [
      Padding(
        padding: EdgeInsets.only(right: SizeConfig.defaultSize * 3),
        child: MyProfile.routeName != '/my-profile'
            ? CircleAvatar(
                radius: 15,
                child: ClipOval(
                  child: Container(
                    height: SizeConfig.defaultSize * 3,
                    width: SizeConfig.defaultSize * 3,
                    color: Colors.red,
                  ),
                ),
              )
            : Container(),
      ),
    ],
    centerTitle: true,
    backgroundColor: Color(0xff578ED3),
    title: Text(
      "BMW Balkan",
      style: TextStyle(color: Colors.white),
    ),
  ),
  bottomNavigationBar: MyBottomNavBar(),
  body: Column(
    mainAxisSize: MainAxisSize.min,
    mainAxisAlignment: MainAxisAlignment.start,
    children: [
      SingleChildScrollView(
        child: Column(
          children: [
            SwipeDetector(
              onSwipeLeft: () {
                _nextImage();
              },
              onSwipeRight: () {
                _previousImage();
              },
              child: Center(
                child: Stack(
                  children: <Widget>[
                    Container(
                      decoration: BoxDecoration(
                          image: DecorationImage(
                              image: AssetImage(photos[photoIndex]),
                              fit: BoxFit.fill)),
                      height: SizeConfig.defaultSize * 30,
                      width: SizeConfig.screenWidth,
                    ),
                    Positioned(
                      top: SizeConfig.defaultSize * 28,
                      left: SizeConfig.screenWidth / 2.2,
                      child: SelectedPhoto(
                          numberOfDots: photos.length,
                          photoIndex: photoIndex),
                    ),
                    Positioned(
                      left: SizeConfig.screenWidth / 1.15,
                      child: Column(
                        children: [
                          SizedBox(
                            height: SizeConfig.defaultSize * 2,
                          ),
                          GestureDetector(
                            onTap: () {
                              // delete photo
                            },
                            child: Icon(
                              Icons.remove_circle,
                              color: Colors.white,
                              size: 30,
                            ),
                          ),
                          SizedBox(
                            height: SizeConfig.defaultSize * 20,
                          ),
                          GestureDetector(
                            onTap: () {
                              _getFromGallery();
                            },
                            child: Icon(
                              Icons.add_circle,
                              color: Colors.white,
                              size: 30,
                            ),
                          ),
                        ],
                      ),
                    ),
                  ],
                ),
              ),
            ),
            Container(
              color: Color(0xff578ED3),
              height: SizeConfig.defaultSize * 6,
              child: TabBar(
                controller: _controller,
                indicatorSize: TabBarIndicatorSize.label,
                labelColor: Colors.white,
                unselectedLabelColor: Colors.grey,
                unselectedLabelStyle:
                    TextStyle(fontSize: 12, fontWeight: FontWeight.bold),
                labelStyle:
                    TextStyle(fontSize: 12, fontWeight: FontWeight.bold),
                tabs: [
                  Tab(
                    iconMargin: EdgeInsets.all(
                      SizeConfig.defaultSize * 0.3,
                    ),
                    icon: Icon(Icons.settings_applications),
                    text: 'Specifikacije',
                  ),
                  Tab(
                    iconMargin: EdgeInsets.all(
                      SizeConfig.defaultSize * 0.3,
                    ),
                    icon: Icon(Icons.favorite),
                    text: 'Lajkovani',
                  ),
                  Tab(
                    iconMargin: EdgeInsets.all(
                      SizeConfig.defaultSize * 0.3,
                    ),
                    icon: Icon(Icons.comment),
                    text: 'Komentari',
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
      Expanded(
        child: new TabBarView(
          controller: _controller,
          children: <Widget>[
            specifikacije(),
            lajkovani(),
            komentari(),
          ],
        ),
      ),
    ],
  ),
);

}

Widget komentari() {
return Column(
  children: [
    Expanded(
      child: ListView(
        children: [
          CommentWidget(),
          CommentWidget(),
          CommentWidget(),
          CommentWidget(),
          CommentWidget(),
          CommentWidget(),
        ],
      ),
    ),
    TextField(
      maxLines: 2,
      textCapitalization: TextCapitalization.sentences,
      autocorrect: false,
      keyboardType: TextInputType.text,
      onSubmitted: (value) {
        _komentarProfilaText = value;
        _komentar.clear();
      },
      focusNode: _focusNodeKomentariProfil,
      controller: _komentar,
      decoration: InputDecoration(
        hintText: "Dodaj komentar...",
        contentPadding: EdgeInsets.only(
            left: SizeConfig.defaultSize * 1.5,
            top: SizeConfig.defaultSize * 1.5),
        fillColor: Colors.white,
      ),
    ),
  ],
);

}

这是怎么回事 This is the error

我想要实现的是将 TextField 置于键盘顶部,但我不想滚动页面。 如果可能的话,像这样的事情。 enter image description here

0 个答案:

没有答案