fitted_text_field_container 1.0.0+1 copy "fitted_text_field_container: ^1.0.0+1" to clipboard
fitted_text_field_container: ^1.0.0+1 copied to clipboard

outdated

A Container that automatically resizes to fit a the text value of a Material TextField.

Fitted TextField Container #

A Container that automatically resizes it's width to fit the containing TextField's text value.

Usage #

FittedTextFieldContainer #

Param Default Description
textField The TextField to contain

Example

FittedTextFieldContainer(
    textField: TextField(
        style: TextStyle(fontSize: 48),
        keyboardType: TextInputType.numberWithOptions(decimal: true),
        textAlign: TextAlign.right,
        decoration: InputDecoration(
            prefixText: "£",
            hintText: "0",
        ),
    ),
)

Here I've used hintText: "0" to keep the textfield from becoming very narrow when the TextField is empty.

AnimatedFittedTextFieldContainer #

Param Default Description
growDuration Duration(milliseconds: 300) Duration to animate the container's width when text is longer
shrinkDuration Duration(milliseconds: 600) Duration to animate the container's width when text is shorter
growCurve Curves.easeOutCirc The curve to use in the grow animation
shrinkCurve Curves.easeInCirc The curve to use in the shrink animation
textField The TextField to contain

Example

AnimatedFittedTextFieldContainer(
    growDuration: Duration(milliseconds: 300),
    shrinkDuration: Duration(milliseconds: 600),
    growCurve: Curves.easeOutCirc,
    shrinkCurve: Curves.easeInCirc,
    textField: TextField(
        style: TextStyle(fontSize: 48),
        keyboardType: TextInputType.numberWithOptions(decimal: true),
        textAlign: TextAlign.right,
        decoration: InputDecoration(
            prefixText: "£",
            hintText: "0",
        ),
    ),
)

Again, hintText: "0" helps to keep the textfield from becoming very narrow when the TextField is empty.

Contribute #

Pull requests are welcome!

Licence #

MIT License

Copyright (c) 2020 Huy Dinh

27
likes
0
pub points
79%
popularity

Publisher

verified publishersu93rheroes.com

A Container that automatically resizes to fit a the text value of a Material TextField.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on fitted_text_field_container