Question: hey guys i have some question.
why my text does not change after the button is pressed and setstate is call.

here is my code

```
class noname extends StatefulWidget {
  const noname({Key? key}) : super(key: key);

  @override
  _nonameState createState() => _nonameState();
}

class _nonameState extends State<noname> {
  @override
  Widget build(BuildContext context) {
    String newtext = 'hello ';
    final TextEditingController descriptioncontroller = TextEditingController();
    final formKey = GlobalKey<FormState>();
    return Scaffold(
      body: Column(children: [
        Form(
            key: formKey,
            child: Column(children: [
              TextFormField(
                controller: descriptioncontroller,
                autofocus: true,
                validator: (title) {
                  if (title!.length < 0) {
                    return 'enter a title ';
                  } else {
                    return null;
                  }
                },
                decoration: InputDecoration(
                  border: InputBorder.none,
                  labelText: 'input your title ',
                ),
              ),
            ])),
        ElevatedButton(onPressed: () {
          setState(() {
            newtext =  descriptioncontroller.text;
          });
          print('your user input is ' + descriptioncontroller.text);
        }, child: Text('saved')),
        Text(newtext)
      ]),
    );
  }
}

```

i have try onchange, controller but the error still present

Answer: 
Change this line of code,

```
class _nonameState extends State<noname> {
 @override
 Widget build(BuildContext context) {
  String newtext = 'hello '; // <======== move this up in the class level
 ...

```

to this,

```
    class _nonameState extends State<noname> {
     String newtext = 'hello '; // <======== move it here

     @override
     Widget build(BuildContext context) {
     ...

```

In fact all of these needs to be class level not build function level,

```
   String newtext = 'hello ';
   final TextEditingController descriptioncontroller = TextEditingController();
   final formKey = GlobalKey<FormState>();

```
you should just `String newtext = 'hello ';` move over build context