1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] Flutter how change dynamic the lable of textfield

Discussão em 'Mobile' iniciado por Stack, Setembro 27, 2021.

  1. Stack

    Stack Membro Participativo

    I'm trying to change the lable of a textfield after klick on a radio button.

    Here my example:

    [​IMG]

    [​IMG]

    If im klick on radio button private the textfield lable should change. I try to change a variable if im click on radio button. The value of variable change but not update the lable.

    Here my textfield:

    //name
    class BuildAppFieldName extends StatefulWidget {
    @override
    _BuildAppFieldName createState() => _BuildAppFieldName();
    }

    //name
    class _BuildAppFieldName extends State<BuildAppFieldName> {
    @override
    Widget build(BuildContext context) {
    return Container(
    width: MediaQuery.of(context).size.width * 0.8,
    height: MediaQuery.of(context).size.height * 0.09,
    child: TextFormField(
    //controller: _controller_companyName,
    style: TextStyle(
    color: Colors.black,
    ),
    decoration: InputDecoration(
    labelText: 'Name*',
    labelStyle: TextStyle(
    color: Colors.black,
    ),
    enabledBorder: UnderlineInputBorder(
    borderSide: BorderSide(
    color: Colors.black,
    ),
    ),
    ),
    onChanged: (value) {},
    ),
    );
    }
    }



    Here my radio button:

    //radio button
    class BuildAppRadioButton extends StatefulWidget {
    @override
    _BuildAppRadioButton createState() => _BuildAppRadioButton();
    }

    //radio button
    class _BuildAppRadioButton extends State<BuildAppRadioButton> {
    @override
    Widget build(BuildContext context) {
    return Row(
    children: [
    //spacer
    Spacer(),

    //radio button
    Container(
    width: MediaQuery.of(context).size.width * 0.37,
    child: CustomRadioButtonRegister(
    isPressed: btn_radio[0],
    label: 'Private',
    padding: const EdgeInsets.symmetric(horizontal: 5.0),
    value: true,
    groupValue: btn_radio[0],
    onChanged: (bool newValue) {
    setState(() {
    btn_radio[0] = true;
    btn_radio[1] = false;
    });
    },
    ),
    ),

    //spacer
    Spacer(),

    //radion button
    Container(
    width: MediaQuery.of(context).size.width * 0.37,
    child: CustomRadioButtonRegister(
    isPressed: btn_radio[1],
    label: "Company",
    padding: const EdgeInsets.symmetric(horizontal: 5.0),
    value: true,
    groupValue: btn_radio[1],
    onChanged: (bool newValue) {
    setState(() {
    btn_radio[1] = true;
    btn_radio[0] = false;
    });
    },
    ),
    ),

    //spacer
    Spacer(),
    ],
    );
    }
    }



    Anyone have a idea how i can do this. Many thx :)

    Continue reading...

Compartilhe esta Página