Priyanshu Rajput
Priyanshu Rajput

Reputation: 21

Flutter keyboard hides textfield in android but working fine in iOS

When the text field is focused then the content is scrolled up in iOS but not working in android. Do I need to change the hierarchy of widgets or some configuration needed to change in the AndroidManifest file? I have also tried resizeToAvoidBottomInset and resizeToAvoidBottomPadding properties of Scaffold

Widget build(BuildContext context) {
return Scaffold(
  body: Container(
    margin: EdgeInsets.all(0.0),
    decoration: BoxDecoration(
      image: DecorationImage(
          image: AssetImage("assets/images/background.png"),
          fit: BoxFit.fill),
    ),
    child: Stack(
      children: <Widget>[
        Center(
          child: Padding(
            padding: const EdgeInsets.symmetric(horizontal: 16.0),
            child: signUpCardView,
          ),
        ),
        userLogin(bloc),
      ],
    ),
  ),
);

}

Widget get signUpCardView {
return SingleChildScrollView(
      child: Card(
    color: Colors.white,
    child: Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      mainAxisSize: MainAxisSize.min,
      children: <Widget>[
        Padding(
          padding: EdgeInsets.symmetric(vertical: 30.0),
          child: Center(
            child: Column(
              children: <Widget>[
                Text(
                  "${AppTranslations.of(context).text("signUp")}",
                  style: TextStyle(
                    color: AppColors.BUTTON_SECONDARY_BACKGROUND_COLOR,
                    fontFamily: customFontFamily,
                    fontSize: 30.0,
                  ),
                ),
                SizedBox(
                  width: 50,
                  height: 20,
                  child: Divider(
                    thickness: 4.0,
                    color: AppColors.BUTTON_SECONDARY_BACKGROUND_COLOR,
                  ),
                )
              ],
            ),
          ),
        ),
        Padding(
          padding: const EdgeInsets.symmetric(vertical: 0.0),
          child: nameField(bloc),
        ),
        Padding(
          padding: const EdgeInsets.symmetric(vertical: 0.0),
          child: mobileField(bloc),
        ),
        Padding(
          padding: const EdgeInsets.symmetric(vertical: 0.0),
          child: emailField(bloc),
        ),
        Padding(
          padding: const EdgeInsets.symmetric(vertical: 0.0),
          child: passwordField(bloc),
        ),
        confirmPasswordField(bloc),
        Center(
          child: Padding(
            padding: const EdgeInsets.symmetric(vertical: 16.0),
            child: submitButton(bloc),
          ),
        ),
        Padding(
          padding: EdgeInsets.symmetric(vertical: 8.0),
          child: Center(
            child: Padding(
              padding: const EdgeInsets.only(bottom: 50.0),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  Text(
                    "${AppTranslations.of(context).text("alreadyHaveAnAccount")}?",
                    style: TextStyle(
                      color: Colors.grey.shade600,
                      fontFamily: customFontFamily,
                    ),
                  ),
                  InkWell(
                    onTap: () {
                      _openSignInScreen();
                    },
                    child: Text(
                      " ${AppTranslations.of(context).text("signIn")}",
                      style: TextStyle(
                        color: AppColors.BUTTON_SECONDARY_BACKGROUND_COLOR,
                        fontFamily: customFontFamily,
                      ),
                    ),
                  ),
                ],
              ),
            ),
          ),
        ),
      ],
    ),
  ),
);

}

This is the UI

Upvotes: 1

Views: 467

Answers (2)

Priyanshu Rajput
Priyanshu Rajput

Reputation: 21

Finally resolved my issue. It was due to <item name="android:windowFullscreen">true</item> in styles.xml.

Upvotes: 1

jbarat
jbarat

Reputation: 2470

To make the screen "resize" ie move to the cursor your android manifest should have this in it:

<application
  ...
  <activity
    ...
    android:windowSoftInputMode="adjustResize"

Upvotes: 1

Related Questions