Текстовое поле скрывается под дрожанием клавиатуры - PullRequest
0 голосов
/ 30 мая 2020

Раньше текстовое поле использовалось для go с клавиатурой, но теперь оно не скрывается под клавиатурой. Я пробовал все решения в inte rnet, такие как resizeToAvoidBottomInset, resizeToAvoidBottomPadding и c. но ни один из них у меня не работал. Это очень расстраивает. Вы можете мне помочь?

import 'package:darpandentalhome/services/auth.dart';
import 'package:darpandentalhome/shared/const.dart';
import 'package:darpandentalhome/shared/loading.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:flutter_svg/flutter_svg.dart';

class SignIn extends StatefulWidget {

  final Function toggleView;
  SignIn({this.toggleView});

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

class _SignInState extends State<SignIn> {

  final AuthService _auth = AuthService();
  final _formKey = GlobalKey<FormState>();
  GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey();

  bool loading = false;

  String email = '';
  String password = '';

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      key: _scaffoldKey,
      backgroundColor: Color(0xfff9f9f9),
      body: SingleChildScrollView(
        child: Column(
          children: <Widget>[
            Container(
              width: MediaQuery. of(context). size. width,
              child: SvgPicture.asset('assets/images/Illustration.svg', fit: BoxFit.cover,),
            ),
            Padding(
              padding: const EdgeInsets.all(8.0),
              child: Center(
                child: Text(
                  'Darpan Dental Home',
                  style: GoogleFonts.rubik(
                    textStyle: TextStyle(
                      fontSize: 35,
                      fontWeight: FontWeight.w500
                    ),
                  ),
                ),
              ),
            ),
            loading ? Loading() : SizedBox(height: 6),
            Form(
              key: _formKey,
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  Padding(
                      padding: const EdgeInsets.fromLTRB(25,10,20,0),
                      child: Text(
                        'Email:',
                        style: GoogleFonts.rubik(
                          textStyle: TextStyle(
                              fontSize: 18,
                          ),
                        )
                      )
                  ),
                  Padding(
                    padding: const EdgeInsets.fromLTRB(20,10,20,10),
                    child: TextFormField(
                      textInputAction: TextInputAction.next,
                      onEditingComplete: () => FocusScope.of(context).nextFocus(),
                      validator: (val) => val.isEmpty ? "Please Enter your email" : null,
                      onChanged: (val) {
                        setState(() {
                          email = val;
                        });
                      },
                      style: GoogleFonts.rubik(
                        textStyle: TextStyle(
                          fontSize: 15,
                        ),
                      ),
                      cursorColor: Colors.black,
                      decoration: textInputDecoration.copyWith(hintText: 'sanjivgurung@gmail.com'),
                    ),
                  ),
                  Padding(
                      padding: const EdgeInsets.fromLTRB(25,10,20,0),
                      child: Text(
                        'Password:',
                          style: GoogleFonts.rubik(
                            textStyle: TextStyle(
                              fontSize: 18,
                            ),
                          )
                      )
                  ),
                    Padding(
                      padding: const EdgeInsets.fromLTRB(20,10,20,20),
                      child: TextFormField(
                        textInputAction: TextInputAction.done,
                        validator: (val) => val.length<6 ? "Please enter a password 6+ character" : null,
                        onChanged: (val) {
                          setState(() {
                            password = val;
                          });
                        },
                          style: GoogleFonts.rubik(
                            textStyle: TextStyle(
                              fontSize: 15,
                            ),
                          ),
                          obscureText: true,
                          cursorColor: Colors.black,
                          decoration: textInputDecoration.copyWith(hintText: '**********'),
                      ),
                  )
                ],
              ),
            ),
            MaterialButton(
              height: 55,
              minWidth: 230,
              elevation: 0,
              shape: RoundedRectangleBorder(borderRadius: new BorderRadius.circular(10.0)),
              color: Color(0xff4CBBB9),
              onPressed: () async {
                if(_formKey.currentState.validate()){
                  setState(() {
                    loading = true;
                  });
                  dynamic result = await _auth.signInWithEmailAndPassword(email, password);
                  if(result==null) {
                    setState(() {
                      loading = false;
                    });
                    _scaffoldKey.currentState.showSnackBar(
                        SnackBar(
                          behavior: SnackBarBehavior.floating,
                          elevation: 0,
                          duration: Duration(milliseconds: 800),
                          backgroundColor: Colors.red[700],
                          content: Text(
                              'Error Signing In',
                              style: GoogleFonts.rubik(
                                textStyle: TextStyle(
                                    color: Colors.white,
                                    fontSize: 18,
                                  letterSpacing: 1.5
                                ),
                              )
                          ),
                        )
                    );
                  }
                }
              },
              child: Text(
                'Sign In',
                  style: GoogleFonts.rubik(
                    textStyle: TextStyle(
                      fontSize: 17,
                      color: Colors.white,
                      fontWeight: FontWeight.w500
                    ),
                  )
              ),
            ),
            Center(
                child: Padding(
                  padding: EdgeInsets.only(top: 10, bottom: 10),
                  child: InkWell(
                    onTap: () {
                      widget.toggleView();
                    },
                    child: Text(
                      'Want a new account?',
                      style: GoogleFonts.rubik(
                        textStyle: TextStyle(
                          fontSize: 15,
                          color: Color(0xffCE5B51),
                        ),
                      ),
                    ),
                  ),
                )
            ),
          ],
        ),
      ),
    );
  }
}

Я также получаю это сообщение, когда нажимаю на текстовое поле. Есть ли проблемы?

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

Экран после включения клавиатуры

Экран до включения клавиатуры

1 Ответ

0 голосов
/ 01 июня 2020

Эта проблема устранена путем удаления этой строки кода из файла AndroidManifest. xml и полного перезапуска приложения. Раньше это не работало, потому что я просто удалял строку и перезапускал приложение. Чтобы сохранить изменения в файле AndroidManifest. xml, вам необходимо полностью перезапустить приложение, чтобы увидеть изменения.

<item name="android:windowFullscreen">true</item>

Спасибо.

...