logo
down
shadow

Show a text field dialog without being covered by keyboard?


Show a text field dialog without being covered by keyboard?

By : Donald Wong
Date : November 22 2020, 03:01 PM
To fix the issue you can do If your use case is to add multiple TextFields inside your Dialog so your main Form does not get crowded, I think it is better if you build something more customizable than AlertDialog and SimpleDialog as they are used for simple activities (confirmations, radios..etc).
Otherwise, why do you want to use a Dialog for a single TextField ?
code :
import 'package:flutter/material.dart';


void main() {
  runApp(new MaterialApp(home: new MyApp(),));
}

class MyApp extends StatefulWidget {
  @override
  MyAppState createState() => new MyAppState();
}

class MyAppState extends State<MyApp> {
  FullScreenDialog _myDialog = new FullScreenDialog();

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
        appBar: new AppBar(
          title: new Text("Fill this form"),
        ),
        body: new Column(
          children: <Widget>[
            new TextField(controller: new TextEditingController(
                text: "Add a single text field"),),

            new Card(child: new ListTile(
              title: new Text("Click to add your top 3 amazing skills"),
              subtitle: new Text(
                  "${_myDialog._skillOne} ${_myDialog._skillTwo} ${_myDialog
                      ._skillThree}"),
              onTap: () {
                Navigator.push(context, new MaterialPageRoute(
                  builder: (BuildContext context) => _myDialog,
                  fullscreenDialog: true,
                ));
              },
            ),
            ),
          ],
        )
    );
  }

}


class FullScreenDialog extends StatefulWidget {
  String _skillOne = "You have";
  String _skillTwo = "not Added";
  String _skillThree = "any skills yet";

  @override
  FullScreenDialogState createState() => new FullScreenDialogState();
}

class FullScreenDialogState extends State<FullScreenDialog> {
  TextEditingController _skillOneController = new TextEditingController();
  TextEditingController _skillTwoController = new TextEditingController();

  TextEditingController _skillThreeController = new TextEditingController();

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
        appBar: new AppBar(
          title: new Text("Add your top 3 skills"),
        ),
        body: new Padding(child: new ListView(
          children: <Widget>[
            new TextField(controller: _skillOneController,),
            new TextField(controller: _skillTwoController,),
            new TextField(controller: _skillThreeController,),
            new Row(
              children: <Widget>[
                new Expanded(child: new RaisedButton(onPressed: () {
                  widget._skillThree = _skillThreeController.text;
                  widget._skillTwo = _skillTwoController.text;
                  widget._skillOne = _skillOneController.text;
                  Navigator.pop(context);
                }, child: new Text("Save"),))
              ],
            )
          ],
        ), padding: const EdgeInsets.symmetric(horizontal: 20.0),)
    );
  }


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

void main() {
  runApp(new MaterialApp(home: new FocusVisibilityDemo()));
}

class FocusVisibilityDemo extends StatefulWidget {
  @override
  _FocusVisibilityDemoState createState() => new _FocusVisibilityDemoState();
}


class _FocusVisibilityDemoState extends State<FocusVisibilityDemo> {
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(title: new Text('Text Dialog Demo')),
      body: new Center(
        child: new RaisedButton(
          onPressed: _showDialog,
          child: new Text("Push Me"),
        ),
      ),
    );
  }

  _showDialog() async {
    await showDialog<String>(
      context: context,
      child: new _SystemPadding(child: new AlertDialog(
        contentPadding: const EdgeInsets.all(16.0),
        content: new Row(
          children: <Widget>[
            new Expanded(
              child: new TextField(
                autofocus: true,
                decoration: new InputDecoration(
                    labelText: 'Full Name', hintText: 'eg. John Smith'),
              ),
            )
          ],
        ),
        actions: <Widget>[
          new FlatButton(
              child: const Text('CANCEL'),
              onPressed: () {
                Navigator.pop(context);
              }),
          new FlatButton(
              child: const Text('OPEN'),
              onPressed: () {
                Navigator.pop(context);
              })
        ],
      ),),
    );
  }
}


class _SystemPadding extends StatelessWidget {
  final Widget child;

  _SystemPadding({Key key, this.child}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    var mediaQuery = MediaQuery.of(context);
    return new AnimatedContainer(
        padding: mediaQuery.viewInsets,
        duration: const Duration(milliseconds: 300),
        child: child);
  }
}


Share : facebook icon twitter icon
iOS how to combine keyboard with a text field and show them together?

iOS how to combine keyboard with a text field and show them together?


By : user2899130
Date : March 29 2020, 07:55 AM
like below fixes the issue Your current attempt doesn't work because the text field in the accessory view isn't in the view hierarchy when you try to make it the first responder.
What you need to do is something like have a 'dummy' text field that is part of the view hierarchy but which is off screen, so you can't see it but you can make it the first responder and then switch the first responder to your other text field once the keyboard is displayed.
I set scroll view offset to show text field hidden by keyboard. If the user scrolls while keyboard is show, scroll view

I set scroll view offset to show text field hidden by keyboard. If the user scrolls while keyboard is show, scroll view


By : Aleksandr Alyushin
Date : March 29 2020, 07:55 AM
hope this fix your issue You need to change the contentInset. The contentOffset is the current scroll position so when the user scrolls it gets reset.
An example of this can be found here: https://stackoverflow.com/a/16806736/78496
Disable multiline in prompt dialog text field and choose keyboard layout

Disable multiline in prompt dialog text field and choose keyboard layout


By : mathader
Date : March 29 2020, 07:55 AM
should help you out This feature for {N} prompt dialog is not currently supported but you have some options for your application. There are some posibilities .. one of them involves creating a custom prompt-page with showModal()
The idea is that you can create your custom prompt page with all the setting as required and then show it as a modal view and tehn use closeModal() to close it. More about modal pages you can get from the {N} documentation here : https://docs.nativescript.org/ApiReference/ui/page/Page.html
Error text in TextInputLayout is covered by keyboard

Error text in TextInputLayout is covered by keyboard


By : Jerry Bayani
Date : March 29 2020, 07:55 AM
seems to work fine To make sure the error message is visible without the user acting to see it, I subclassed TextInputLayout and placed it inside a ScrollView. This lets me scroll down if needed to reveal the error message, on every occasion the error message is set. There are no changes needed in the activity/fragment class that uses it.
Android Edit Text Covered By Keyboard on Second Tap

Android Edit Text Covered By Keyboard on Second Tap


By : hiby
Date : March 29 2020, 07:55 AM
this one helps. So I have an EditText that does not get covered by the keyboard the first time around. Then when you close the keyboard and tap the edittext again it covers the edittext. , Add this in your manifest for activity. It works fine
Related Posts Related Posts :
  • Any tips on how I would render widgets based on phone direction?
  • How to get constraints like Height and Width of container in flutter
  • SliverAppBar and Listview with controller
  • flutter: CircleAvatar with fallback text
  • how to send data through different classes in different screens in flutter
  • How to convert an array of complex numbers into real within flutter?
  • Unwanted space appearing between RaisedButton widgets in a column
  • flutter: perform size error while building the ui?
  • What is Modal's onClose equivalent to Dart/Flutter's Dialog?
  • How to properly enable/disable Flutter's Button
  • How to align single widgets in Flutter?
  • Convert from Set to List in Dart / Flutter?
  • Flutter listening to textField value changes from other widget
  • how to supply data to a class extending DataTableSource
  • giving the header and body of ExpansionPanelList different colors
  • How to solve scrolling in list view when gridview as a child?
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org