Flutter   发布时间:2022-05-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了当我滚动时,颤动的表格数据消失了大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个小部件,它有一个图像元素和表单元素的扩展列表视图,当我填写并滚动数据时它会在图像后面滚动时消失.我在调试时没有抛出任何错误,它发生在滚动窗口小部件顶部图像后面的任何字段上.有任何想法吗?

@override
  Widget build(BuildContext context) {
    var _children = <Widget>[
      new Center(
        child: new Text(widget.prov.fname + widget.prov.lname,style: new TextStyle(fontSize: 20.0,fontWeight: FontWeight.bold),),new Center(
          child: new Container(
            padding: new EdgeInsets.only(
                left: 125.0,right: 125.0,bottom: 50.0),child: new Image.network('http://174.138.61.246:8080/getimage/'+widget.prov.pic.assetName),)
      ),new Form(
          key: _formKey,autovalidate: _autovalidate,onWillPop: _warnUserAboutInvalidData,child: new Expanded(
              child: new ListView(
                padding: const EdgeInsets.symmetric(horizontal: 16.0),children: <Widget>[
                  new TextFormField(
                    decoration: const InputDecoration(
                      icon: const Icon(Icons.person),hintText: 'First Name?',labelText: 'First Name *',onSaved: (String value) { referral.fname = value; },validator: _validatename,new TextFormField(
                    decoration: const InputDecoration(
                      icon: const Icon(Icons.person),hintText: 'last name?',labelText: 'last name *',onSaved: (String value) { referral.lname = value; },new TextFormField(
                    decoration: const InputDecoration(
                        icon: const Icon(Icons.phonE),hintText: 'How to contact?',labelText: 'Phone number *',prefixText: '+1'
                    ),keyboardType: TexTinputType.phone,onSaved: (String value) { referral.contact = value; },validator: _validatePhonenumber,// TexTinputFormatters are applied in sequence.
                    inputFormatters: <TexTinputFormatter> [
                      WhitelisTingTexTinputFormatter.digitsOnly,// Fit the validaTing format.
                      _phonenumberFormatter,],new TextFormField(
                    decoration: const InputDecoration(
                      hintText: 'Tell us about patient',HelperText: 'It does not have to be detailed yet',labelText: 'Referral Details',maxLines: 5,new _datetiR_796_11845@ePicker(
                    labelText: 'DOB',SELEctedDate: _fromDate,SELEctDate: (datetiR_796_11845@e datE) {
                      setState(() {
                        referral.dob = date;
                      });
                    },new InputDecorator(
                    decoration: const InputDecoration(
                      labelText: 'Type of Appointment',hintText: 'Choose an Appointment Type',isEmpty: _typeAppt == null,child: new DropdownButton<String>(
                      value: _typeAppt,isDense: true,onChanged: (String newvalue) {
                        setState(() {
                          _typeAppt = newValue;
                        });
                      },items: _allTypeAppt.map((String value) {
                        return new DropdownMenuItem<String>(
                          value: value,child: new Text(value),);
                      }).toList(),)
          )
      ),/*new refreshInDicator(
        child: new ListView.builder(
          itemBuilder: _itemBuilder,itemCount: listcount,onrefresh: _onrefresh,*/

    ];
    return new Scaffold(
      appBar: new AppBar(title: new Text("My Provider")),body: new column(
        children: _children,);
  }

解决方法

我认为问题是你没有保存放入TextFields的值(例如一个状态).
从您的代码我假设您使用ListView.builder()来设置ListView.如 documentation中所述,此方法仅呈现视野中的孩子.将子项滚动到视图外后,它将从ListView中删除,只有在将其滚动到视图中后才会再次添加.由于删除了TextField,因此也会删除该值.

要永久保存值,我建议使用TextFields并将输入保存到TextField的onChanged()方法中,或者使用TextEditingController.

大佬总结

以上是大佬教程为你收集整理的当我滚动时,颤动的表格数据消失了全部内容,希望文章能够帮你解决当我滚动时,颤动的表格数据消失了所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。