lzhuor / auto_size_text_field

Flutter TextField widget that automatically resizes text field to fit perfectly within its bounds.
https://pub.dev/packages/auto_size_text_field
MIT License
52 stars 35 forks source link

Allow decoration: null #11

Open LizDresserDev opened 3 years ago

LizDresserDev commented 3 years ago

I started converting some of our TextField() widgets into AutoSizeTextField() widgets. In our TextField() widgets, we allowed for a null decoration like this:

                Flexible(
                  child: TextField(
                    controller: _dateOrTaskNameController,
                    decoration: null,
                  ),
                ),

Simple conversion to AutoSizeTextField() looks like this:

                Flexible(
                  child: AutoSizeTextField(
                    controller: _dateOrTaskNameController,
                    decoration: null,
                  ),
                ),

The exception is below:

I/flutter ( 6673): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════ I/flutter ( 6673): The following NoSuchMethodError was thrown building LayoutBuilder: I/flutter ( 6673): The getter 'prefixText' was called on null. I/flutter ( 6673): Receiver: null I/flutter ( 6673): Tried calling: prefixText I/flutter ( 6673): I/flutter ( 6673): The relevant error-causing widget was: I/flutter ( 6673): AutoSizeTextField lib\dependency\dependency_form.dart I/flutter ( 6673): I/flutter ( 6673): When the exception was thrown, this was the stack: I/flutter ( 6673): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5) I/flutter ( 6673): #1 _AutoSizeTextFieldState._checkTextFits package:auto_size_text_field/src/auto_size_text_field.dart:752

Could we get the AutoSizeTextField widget to have the same decoration handling as the TextField widget?

lzhuor commented 3 years ago

Thanks @LizDW I will need to dig more into the issue. Keep you posted. It will be good if you can help dig into the source code and take look as well.

lzhuor commented 2 years ago

Working in progress.