本文介绍了使用SingleChildScrollView whit灵活小部件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试Textfield Widget时遇到问题:底部被48个像素溢出".此后,我尝试使用SingleChildScrollView Widget,但它变得更加复杂,现在显示此错误:

i ran in to Problem while trying Textfield Widget :"bottom overflowed by 48pixels".after that i tried to use SingleChildScrollView widget,but it became more complicated,it shows now this error:

========渲染库捕获了异常====================================================未布置RenderBox:RenderCustomPaint#7fee2 relayoutBoundary = up3 NEEDS-PAINT

任何建议如何解决此问题?!

any Suggestion how can i solve this Problem?!

不使用SingleCHildScrollView的模拟器

import 'package:flutter/material.dart';
import 'package:filter_list/filter_list.dart';



class FilterPage extends StatefulWidget {
  const FilterPage({Key key, this.allTextList}) : super(key: key);
  final List<String> allTextList;
  @override
  _FilterPageState createState() => _FilterPageState();
}
class _FilterPageState extends State<FilterPage> {
  @override
  Widget build(BuildContext context) {
    List<String> countList = [
      "Art",
      "Markt",
      "Photography",

    ];
    return Scaffold(

      appBar: AppBar(
      title: Text("Filter list Page"),
      ),
      body: SafeArea(

        child: SingleChildScrollView(
          child: Column(
                children: [
                  Flexible(

                    flex: 2,
                    child: FilterListWidget(
                      allTextList: countList,
                      hideheaderText: true,
                      selectedTextBackgroundColor: Colors.red,
                      applyButonTextBackgroundColor: Colors.red,
                      allResetButonColor: Colors.grey,
                      onApplyButtonClick: (list) {
                        //Navigator.pop(context, list);
                      },
                    ),
                  ),
                  Flexible(

                    flex: 3,
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.start,
                      children: [
                        Row(
                          children: [
                            Container(
                              width: 160,
                              child: TexstInput(lable: 'min-Upvote',icons: Icons.favorite,),
                            ),
                            Container(
                              width: 160,
                              child: TexstInput(lable: 'max-Upvote'),
                            ),
                          ],
                        ),
                        SizedBox(height: 25),
                        Row(
                          children: [
                            Container(
                              width: 160,
                              child: TexstInput(lable: 'min ',icons: Icons.person,),
                            ),
                            Container(
                              width: 160,
                              child: TexstInput(lable: 'max '),
                            ),
                          ],
                        ),
                        SizedBox(height: 25,),
                     Row(
                       children: [

                         SizedBox(width: 10),
                         RaisedButton(child:Text(
                                  'back'
                              ),onPressed: (){},),

                       ],
                     ),

                         SizedBox(height: 25),
                         Row(
                          mainAxisAlignment: MainAxisAlignment.center,


                            children: [
                              RaisedButton(child:Text(
                                  'back'
                              ),onPressed: (){},),
                              SizedBox(width: 10,),
                              RaisedButton(child:Text(
                                  'apply'
                              ),onPressed: (){})
                            ],
                          ),


                      ],
                    ),
                  ),
                ],
              ),
        ),
          ),


    );
  }

}


class TexstInput extends StatelessWidget {
  TexstInput({
    @required this.lable, this.icons
  }) ;
  IconData icons;
  String lable;
  @override
  Widget build(BuildContext context) {
    return TextField(
      keyboardType: TextInputType.number,
      decoration: InputDecoration(
          icon: Icon(icons),
          contentPadding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 20.0),
          labelText: lable,
          focusedBorder: OutlineInputBorder(
            borderSide: BorderSide(color: Colors.red, width: 5.0),
          ),
          enabledBorder: OutlineInputBorder(
            borderSide: BorderSide(color: Colors.grey, width: 0.8),
          )
      ),
    );
  }
}

推荐答案

我注意到该错误来自FilterListWidget.也许这可以解决您的问题

I noticed that the error is coming from the FilterListWidget. Maybe this can solve your issue

Scaffold(
  appBar: AppBar(
    title: Text("Filter list Page"),
  ),
  body: Column(
    children: [
      Flexible(
        child: FilterListWidget(
          allTextList: countList,
          hideheaderText: true,
          selectedTextBackgroundColor: Colors.red,
          applyButonTextBackgroundColor: Colors.red,
          allResetButonColor: Colors.grey,
          onApplyButtonClick: (list) {
            //Navigator.pop(context, list);
          },
        ),
      ),
      Expanded(
        child: SingleChildScrollView(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            children: [
              Row(
                children: [
                  Container(
                    width: 160,
                    child: TexstInput(lable: 'min-Upvote',icons: Icons.favorite,),
                  ),
                  Container(
                    width: 160,
                    child: TexstInput(lable: 'max-Upvote'),
                  ),
                ],
              ),
              SizedBox(height: 25),
              Row(
                children: [
                  Container(
                    width: 160,
                    child: TexstInput(lable: 'min ',icons: Icons.person,),
                  ),
                  Container(
                    width: 160,
                    child: TexstInput(lable: 'max '),
                  ),
                ],
              ),
              SizedBox(height: 25,),
              Row(
                children: [

                  SizedBox(width: 10),
                  RaisedButton(child:Text(
                      'back'
                  ),onPressed: (){},),

                ],
              ),
              SizedBox(height: 25),
              Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  RaisedButton(child:Text(
                      'back'
                  ),onPressed: (){},),
                  SizedBox(width: 10,),
                  RaisedButton(child:Text(
                      'apply'
                  ),onPressed: (){})
                ],
              ),
            ],
          ),
        ),
      ),
    ],
  ),
)

这篇关于使用SingleChildScrollView whit灵活小部件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 02:42