2

I was using a text field when I encountered this problem. I have placed a flat button below my text field. Now, what has happened is that when I tap on the text field to write anything, my mobile keyboard appears. Everything seems normal until here. Now after I enter any data in my text field and press on the done button on the mobile keyboard, the mobile keyboard disappears. And I can press on the flat button below the text field. If I do this, everything is performed smoothly. BUT......... When I enter any data in my text field, and if I directly tap on the flat button that I placed, without pressing on the done button on the mobile keyboard, then I get to see an overflow message for a second. Though the overflow message is seen just for a second, it is still annoying. I don't know what I should do. Please help me. I have attached a small video link that shows the problem. In the video recording i have tapped on the done button on the mobile keyboard and tapped on the flat button. Then, the second time, I have again typed something on the text field and without pressing on the done button, I have tapped on the flat button. You will also see the overflow warning. Please help me friends. Thanks!!

Here is a recording of the problem that I have been facing. Please have a look at it and help me. Thanks!!

Container(
  padding: EdgeInsets.all(20.0),
  child: TextField(
    style: TextStyle(
      color: Colors.black,
      fontSize: 18,
    ),
    decoration: kTextFieldInputDecoration,
    onChanged: (value) {
      cityName = value;
    },
  ),
),
1
  • 1
    Use SingleChildScrollView in your code. Commented Aug 18, 2019 at 17:42

1 Answer 1

3

please reference this doc https://medium.com/@rubensdemelo/flutter-forms-improving-ui-ux-with-singlechildscrollview-7b91aa981475

You can wrap your Container with SingleChildScrollView

example code

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void main() {
  SystemChrome.setEnabledSystemUIOverlays([]);
  runApp(
    MyApp(),
  );
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Forms',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Forms'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

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

class _MyHomePageState extends State<MyHomePage> {
  final TextStyle textstyle =
      TextStyle(color: Colors.white, fontWeight: FontWeight.bold);
  final InputDecoration decoration = InputDecoration(
    border: OutlineInputBorder(),
  );
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: SingleChildScrollView(
          padding: const EdgeInsets.all(8.0),
          child: Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: <Widget>[
                FlutterLogo(
                  size: 190,
                ),
                SizedBox(
                  height: 15,
                ),
                TextFormField(
                  decoration: decoration,
                ),
                SizedBox(
                  height: 15,
                ),
                TextFormField(
                  decoration: decoration,
                ),
                SizedBox(
                  height: 15,
                ),
                MaterialButton(
                  color: Colors.red,
                  minWidth: 160,
                  child: Text(
                    'Google',
                    style: textstyle,
                  ),
                ),
                MaterialButton(
                  color: Colors.blue,
                  minWidth: 160,
                  child: Text(
                    'Facebook',
                    style: textstyle,
                  ),
                ),
                MaterialButton(
                  color: Colors.orange,
                  minWidth: 160,
                  child: Text(
                    'E-mail',
                    style: textstyle,
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.