My Text area is nothing show in flutter app

Viewed 131

hi I am learning flutter and new to programming i have a issue with that whenever i am write in app text field i have got only 2 values after writing no more values a writing in text field and got this

Changing the content within the the composing region may cause the input method to behave strangely, and is therefore discouraged. See https://github.com/flutter/flutter/issues/78827 for more details W/ListenableEditingState( 9055): a listener was added to EditingState while a batch edit was in progress W/IInputConnectionWrapper( 9055): getSelectedText on inactive InputConnection E/FlutterView( 9055): dispatchKeyEvent: KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_A, scanCode=30, metaState=0, flags=0x8, repeatCount=0, eventTime=9164435, downTime=9164435, deviceId=0, source=0x101 }`

    import 'package:flutter/material.dart';
    import 'class_object.dart';
    import 'package:flash_chat/constants.dart';
    class RegistrationScreen extends StatefulWidget {
      static const String id = 'registration_Screen';
      @override
      _RegistrationScreenState createState() => _RegistrationScreenState();
    }

    class _RegistrationScreenState extends State<RegistrationScreen> {
      String email;
      String password;
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          backgroundColor: Colors.white,
          body: SingleChildScrollView(
            child: Padding(
              padding: EdgeInsets.symmetric(horizontal: 24.0),
              child:  Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.stretch,
                  children: <Widget>[
                    Hero(
                      tag: 'logo',
                      child: Container(
                        height: 200.0,
                        child: Image.asset('images/logo.png'),
                      ),
                    ),
                    SizedBox(
                      height: 48.0,
                    ),
                    TextFormField(
                      onChanged: (value) {
                        //Do something with the user input.
                        email = value;
                      },
                      decoration:  kTextFieldDecoration.copyWith(
                          hintText: 'Enter Your Password'
                      ),
                    ),
                    SizedBox(
                      height: 8.0,
                    ),
                    TextFormField(
                      onChanged: (value) {
                        //Do something with the user input.
                        password=value;

                      },
                      decoration: kTextFieldDecoration.copyWith(
                          hintText: 'Enter Your Email'
                      )
                    ),
                    SizedBox(
                      height: 24.0,
                    ),
                    RoundButton(
                      Lable: 'Register',
                      Colour: Colors.blue,
                      onPress: () {
                        print(email);
                        print(password);
                        // Go to the Registration Screen
                        Navigator.pushNamed(context, RegistrationScreen.id);
                      },
                    ),
                  ],
                ),
              ),
          ),
          );
      }
    }

W/IInputConnectionWrapper( 9055): beginBatchEdit on inactive InputConnection W/IInputConnectionWrapper( 9055): getTextBeforeCursor on inactive InputConnection W/IInputConnectionWrapper( 9055): getTextAfterCursor on inactive InputConnection W/IInputConnectionWrapper( 9055): getSelectedText on inactive InputConnection W/IInputConnectionWrapper( 9055): endBatchEdit on inactive InputConnection W/IInputConnectionWrapper( 9055): beginBatchEdit on inactive InputConnection W/IInputConnectionWrapper( 9055): getTextBeforeCursor on inactive InputConnection W/IInputConnectionWrapper( 9055): endBatchEdit on inactive InputConnection

1 Answers

Ahh simple mistake you haven’t passed the text-editing controllers to text field, here's your completed code :-`

 import 'package:flutter/material.dart';
 import 'class_object.dart';
 import 'package:flash_chat/constants.dart';
class RegistrationScreen extends StatefulWidget {
 static const String id = 'registration_Screen';
  @override
_RegistrationScreenState createState() => _RegistrationScreenState();
}

class _RegistrationScreenState extends State<RegistrationScreen> {
TextEditingController emailController;
TextEditingController passwordController;
String email;
String password;

@override
void initState() {
emailController = TextEditingController();
passwordController = TextEditingController();
super.initState(); }
@override
Widget build(BuildContext context) {
return Scaffold(
  backgroundColor: Colors.white,
  body: SingleChildScrollView(
    child: Padding(
      padding: EdgeInsets.symmetric(horizontal: 24.0),
      child:  Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: <Widget>[
            Hero(
              tag: 'logo',
              child: Container(
                height: 200.0,
                child: Image.asset('images/logo.png'),
              ),
            ),
            SizedBox(
              height: 48.0,
            ),
            TextFormField(
            controller:emailController,
              onChanged: (value) {
                //Do something with the user input.
                email = value;
              },
              decoration:  kTextFieldDecoration.copyWith(
                  hintText: 'Enter Your Password'
              ),
            ),
            SizedBox(
              height: 8.0,
            ),
            TextFormField(
              controller:phoneController
              onChanged: (value) {
                //Do something with the user input.
                password=value;

              },
              decoration: kTextFieldDecoration.copyWith(
                  hintText: 'Enter Your Email'
              )
            ),
            SizedBox(
              height: 24.0,
            ),
            RoundButton(
              Lable: 'Register',
              Colour: Colors.blue,
              onPress: () {
                print(email);
                print(password);
                // Go to the Registration Screen
                Navigator.pushNamed(context, RegistrationScreen.id);
              },
            ),
          ],
        ),
      ),
  ),
  );
 }
}

`

Related