logo
Tags down

shadow

Flutter listening to textField value changes from other widget


By : user2174941
Date : October 16 2020, 08:10 PM
I think the issue was by ths following , Below is a dialog to capture users input by using a textField and a button. The button is disabled when textField is empty, however it continues to become disabled when textField is filled with values. This is because the _textController.text state is not being updated (rendered again in this widget). , You just have to listen the TextEditingController for text changes.
code :
      var _textController = TextEditingController();

      @override
      void dispose() {
        // Clean up the controller when the Widget is disposed
        _textController.dispose();
        super.dispose();
      }

      @override
      void initState() {
        _textController.addListener((){
            //here you have the changes of your textfield
            print("value: ${_textController.text}");
            //use setState to rebuild the widget
            setState(() {

                    });
        });
        super.initState();
      }


Share : facebook icon twitter icon

Flutter widget rebuilding when TextField widget clicked


By : ManualPhoto_graphy
Date : March 29 2020, 07:55 AM
I hope this helps you . I'm sure this is a rookie error however I can't seem to figure this one out. In the app below, when the textfield in the second route is clicked the keyboard opens and immediately closes. On closer investigation it seems that the widget is being rebuilt whenever it gets focus, causing the route to reset, making it impossible for the user to enter text. , you have to declare _formKey as static outside of build method.

The prefixIcon of TextField widget in flutter disappears on focusing TextField. How to solve?


By : user3028986
Date : March 29 2020, 07:55 AM
Any of those help The issue was that I had set the primary colour to white. So whenever the field was focused it was disappering as the background was also white. My bad.

Flutter Overlay Widget with textField


By : diego
Date : March 29 2020, 07:55 AM
wish helps you As flutter said, TextField needs a material widget as parent. You can wrap your TextField in one of these widgets that has Material widget in them: Card , Dialog , Drawer , Scaffold . Or you can directly use Material.
code :
void showOverlay(BuildContext context) async {
    OverlayState overlayState = Overlay.of(context);
    OverlayEntry overlayEntry = OverlayEntry(
      builder: (context) => Material( //Use a Material Widget
        child: TextField(
          decoration: InputDecoration(
            border: OutlineInputBorder(),
            labelText: 'Enter text',
          ),
        ),
      ),
    );

    overlayState.insert(overlayEntry);
  }

Centering a TextField wrapped in Flexible in a Row widget that resides in a Column widget in Flutter


By : user3390509
Date : March 29 2020, 07:55 AM
this will help A Row Widget will try to use as much space as possible (https://api.flutter.dev/flutter/widgets/Row-class.html) if you wrap your children widgets inside a Flex and centre the Main Axis, you will see the children elements centred
code :
Row(
  mainAxisAlignment: MainAxisAlignment.center,
  children: <Widget>[
    Flexible(
      flex: 1,
      child: Text("Email:"),
    ),
    Flexible(
      flex: 1,
      child: TextField(
        textAlign: TextAlign.justify,
        decoration: InputDecoration(
          border: InputBorder.none,
          hintText: "Enter Email",
        ),
      ),
    ),
  ],
),

Trying to print the text of Textfield from another widget and always print empty ( just I/flutter ( 9049): ) in flutter


By : user3595018
Date : March 29 2020, 07:55 AM
With these it helps , Change this
code :
Future<String> randomFun() async{
    return _name.text;
  }
Future<String> randomFun() async {
    return Future.value(_name.text);
  }
shadow
Privacy Policy - Terms - Contact Us © voile276.org