MKJ
MKJ

Reputation: 326

Bottom overflow inside SingleChildScrollView when TextFormFields expand on error

I have a signup page with a bunch of TextFormFields that are inside a SingleChildScrollView so the user can scroll when the keyboard pops up. If I hit the signup button while the entries don't pass validation, the TextFormFields expand in height because the error text pops up underneath and my widgets no longer fit on the screen. I don't want to add resizeToAvoidBottomInset=false to my Scaffold because then the bottom TextFormFields may get hidden under the keyboard. Why doesn't the SingleChildScrollView still work with these expanded widgets?

Some of my code:

@override
  Widget build(BuildContext context) {
    final screenWidth = MediaQuery.of(context).size.width;
    final screenHeight = MediaQuery.of(context).size.height;

    return Scaffold(
      body: SafeArea(
        child: SingleChildScrollView(
          child: Container(
            height: screenHeight - screenHeight * 0.03,
            child: Column(
              children: [
                // Back button here
                Spacer(),
                // Whole bunch of TextFormFields here
                SizedBox(height: screenHeight * 0.03),
              ],
            ),
          ),
        ),
      ),
    );
  }

Upvotes: 0

Views: 41

Answers (0)

Related Questions