'How to set data to TextEditingController using StreamBuilder?

I'm loading some data from database (data that user previously saved, for editing). I used StreamBuilder to set data.
I have form , which i used to display data , i used TextFormField because i need to use validations. I connected TextEditingController to TextFormField then i connected StreamBuilder to TextEditingController But when i edit the data after load it gives me exception.

Here is my form code.

Widget _formUI() {
    return StreamBuilder<ConcreteEstimationForm>(
        stream: _bloc.inputObservable(),
        builder: (context, AsyncSnapshot<ConcreteEstimationForm> snapshot) {
          if (snapshot.hasData) {
    ConcreteEstimationForm form = snapshot.data;
    
    _descriptionController.value = _descriptionController.value.copyWith(text: form.description) ;
    _lengthController.text =
        form.length == 0 ? "" : form.length.toString();
    _widthController.text =
        form.width == 0 ? "" : form.width.toString();
    _thickController.text =
        form.thick == 0 ? "" : form.thick.toString();

    _selectedRatio = ratioArr.indexOf(form.mixRatio);

    return Column(
      children: <Widget>[
        TextFormField(
          decoration: const InputDecoration(labelText: "Description"),
          keyboardType: TextInputType.text,
          validator: _descriptionValidator,
          controller: _descriptionController,
        ),
        Row(
          children: <Widget>[
            Expanded(
              child: TextFormField(
                decoration: const InputDecoration(labelText: "Concrete Length"),
                keyboardType: TextInputType.number,
                validator: _lengthValidator,
                controller: _lengthController,
              ),
            ),
            Expanded(
                child: Text(
              'm',
              textAlign: TextAlign.center,
              overflow: TextOverflow.ellipsis,
              style: TextStyle(fontWeight: FontWeight.bold),
            ))
          ],
        ),
        Row(
          children: <Widget>[
            Expanded(
              child: TextFormField(
                decoration: const InputDecoration(labelText: "Concrete Width"),
                keyboardType: TextInputType.number,
                validator: _widthValidator,
                controller: _widthController,
              ),
            ),
            Expanded(
              child: Text(
                'm',
                textAlign: TextAlign.center,
                overflow: TextOverflow.ellipsis,
                style: TextStyle(fontWeight: FontWeight.bold),
              ),
            )
          ],
        ),
        Row(
          children: <Widget>[
            Expanded(
              child: TextFormField(
                decoration: const InputDecoration(labelText: "Concrete Thick"),
                keyboardType: TextInputType.number,
                validator: _thickValidator,
                controller: _thickController,
              ),
            ),
            Expanded(
              child: Text(
                'm',
                textAlign: TextAlign.center,
                overflow: TextOverflow.ellipsis,
                style: TextStyle(fontWeight: FontWeight.bold),
              ),
            )
          ],
        )
      ],
    );

      } else {
        return new Center(
          child: new CircularProgressIndicator(),
        );
      }

    });
  }

I got this exception

I/flutter ( 2626): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════ 
I/flutter ( 2626): The following assertion was thrown building Builder(dirty): 
I/flutter ( 2626): 'package:flutter/src/widgets/basic.dart': Failed assertion: line 6220 pos 15: 'builder != null': is  
I/flutter ( 2626): not true.  
I/flutter ( 2626): I/flutter ( 2626): Either the assertion indicates an error in the framework itself, or we should provide substantially  
I/flutter ( 2626): more information in this error message to help you determine and fix the underlying cause.  
I/flutter ( 2626): In either case, please report this assertion by filing a bug on GitHub:  
I/flutter ( 2626):   https://github.com/flutter/flutter/issues/new?template=BUG.md


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source