Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No items can be selected if a text has been written into a TextFormField immediately before (focus still active) #50

Open
teilzeitgeist opened this issue Jul 19, 2022 · 0 comments

Comments

@teilzeitgeist
Copy link

teilzeitgeist commented Jul 19, 2022

The two widgets:

CustomScrollView(shrinkWrap: true, slivers: [
                  SliverToBoxAdapter(
                      child: Column(children: [
                    Container(
                      height: 1,
                      color: kColorUltraLightGrey,
                    ),
                    SizedBox(height: 28),
                    EditTextField(
                      label: Utils.t(context, 'interim_note_form.note'),
                      padding: EdgeInsets.symmetric(horizontal: 16),
                      isExpandable: true,
                      controller: _messageController,
                    ),
                    FileUpload(
                      label: Utils.t(context, 'interim_note_form.action_add_photo'),
                      fileType: FileType.image,
                      didSelectFiles: (files) => _files = files,
                      files: _files,
                    ),
                    Padding(
                      padding: EdgeInsets.symmetric(horizontal: 16, vertical: 12),
                      child: Stack(
                        key: multiSelectFormFieldKey,
                        children: [
                          MultiSelectFormField(
                            title: Text(Utils.t(context, 'interim_note_form.concerned_modules'), style: TextStyle(fontSize: 11, color: kColorLabel)),
                            fillColor: kColorBackgroundFormField,
                            dataSource: _moduleOptions ?? [],
                            initialValue: _selectedModuleIds,
                            textField: 'display',
                            valueField: 'value',
                            hintWidget: Padding(
                              padding: const EdgeInsets.only(bottom: 4.0),
                              child: Text(Utils.t(context, 'form.choose'), style: kTextStyleBody.copyWith(color: kColorLabel)),
                            ),
                            chipBackGroundColor: kColorWhite,
                            chipLabelStyle: TextStyle(fontSize: 13, color: kColorLabel, fontWeight: FontWeight.w600),
                            dialogShapeBorder: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(12.0))),
                            dialogTextStyle: kTextStyleAlertContent,
                            cancelButtonLabel: Utils.t(context, 'form.cancel').toUpperCase(),
                            onSaved: (value) {
                              if (value == null) return;
                              setState(() {
                                _selectedModuleIds = value;
                              });
                            },
                          ),
                          Positioned.fill(
                              right: 12,
                              bottom: _selectedModuleIds.length > 0 ? 24 : 10,
                              child: Container(
                                alignment: Alignment.bottomRight,
                                child: IgnorePointer(
                                  child: Container(
                                    color: kColorBackgroundFormField,
                                    height: double.infinity,
                                    width: 25,
                                    alignment: Alignment.bottomCenter,
                                    child: Icon(
                                      Icons.arrow_drop_down_sharp,
                                      size: 25,
                                    ),
                                  ),
                                ),
                              ))
                        ],
                      ),
                    ),
                    SizedBox(height: 132),
                  ]))
                ])

The error message is

E/flutter (13216): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: setState() called after dispose(): FormFieldState<dynamic>#03479(lifecycle state: defunct, not mounted)
E/flutter (13216): This error happens if you call setState() on a State object for a widget that no longer appears in the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error can occur when code calls setState() from a timer or an animation callback.
E/flutter (13216): The preferred solution is to cancel the timer or stop listening to the animation in the dispose() callback. Another solution is to check the "mounted" property of this object before calling setState() to ensure the object is still in the tree.
E/flutter (13216): This error might indicate a memory leak if setState() is being called because another object is retaining a reference to this State object after it has been removed from the tree. To avoid memory leaks, consider breaking the reference to this object during dispose().
E/flutter (13216): #0      State.setState.<anonymous closure> (package:flutter/src/widgets/framework.dart:1073:9)
E/flutter (13216): #1      State.setState (package:flutter/src/widgets/framework.dart:1108:6)
E/flutter (13216): #2      FormFieldState.didChange (package:flutter/src/widgets/form.dart:409:5)
E/flutter (13216): #3      new MultiSelectFormField.<anonymous closure>.<anonymous closure> (package:multiselect_formfield/multiselect_formfield.dart:120:25)
E/flutter (13216): <asynchronous suspension>
E/flutter (13216): 

Have anyone the same problem or can help me please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant