Input text turns red when hit limit

This commit is contained in:
Kelrap 2024-07-18 16:33:54 -04:00
parent 16df497e8a
commit 08da254bae
2 changed files with 9 additions and 1 deletions

View file

@ -504,6 +504,9 @@ class InputBar extends StatelessWidget {
onSubmitted!(text);
},
// #Pangea
style: controller?.text.length == 1000
? const TextStyle(color: Colors.red)
: null,
onTap: () {
controller!.onInputTap(
context,

View file

@ -61,6 +61,11 @@ class InputBarWrapperState extends State<InputBarWrapper> {
super.dispose();
}
void refreshOnChange(String text) {
widget.onChanged!(text);
setState(() {});
}
@override
Widget build(BuildContext context) {
return InputBar(
@ -73,7 +78,7 @@ class InputBarWrapperState extends State<InputBarWrapper> {
focusNode: widget.focusNode,
controller: widget.controller,
decoration: widget.decoration,
onChanged: widget.onChanged,
onChanged: widget.onChanged != null ? refreshOnChange : null,
autofocus: widget.autofocus,
textInputAction: widget.textInputAction,
readOnly: widget.readOnly,