Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gap between top of the action bar and page content #172

Closed
BenjiFarquhar opened this issue Dec 25, 2021 · 11 comments
Closed

Gap between top of the action bar and page content #172

BenjiFarquhar opened this issue Dec 25, 2021 · 11 comments

Comments

@BenjiFarquhar
Copy link
Contributor

flutter_keyboard_actions is adding a gap between the keyboard action bar and my page content. How can I make my page content go all the way down to the keyboard action bar?

IMG_1954
IMG_1955

@diegoveloper
Copy link
Owner

Try to reproduce the issue on a minimum sample code, then paste the code here.

@BenjiFarquhar
Copy link
Contributor Author

Not sure if this code is minimal enough. I think it is my code that is causing it actually. Maybe the Expanded is stretching it out:

    return [
      Expanded(
          child: KeyboardActions(
              tapOutsideBehavior: TapOutsideBehavior.opaqueDismiss,
              config: KeyboardActionsConfig(
                defaultDoneWidget: const VpKeyboardDoneButton(),
                actions: [
                  KeyboardActionsItem(
                    focusNode: focusNodeName,
                  ),
                  KeyboardActionsItem(
                    focusNode: focusNodeLocationName,
                  ),
                  KeyboardActionsItem(
                    focusNode: focusNodeCompanyName,
                  ),
                  KeyboardActionsItem(
                    focusNode: focusNodeDescription,
                  ),
                ],
              ),
              child: Column(mainAxisSize: MainAxisSize.min, children: [
                nameTextField(context: context!, form: form),
                locationNameTextField(context: context, form: form!),
                companyNameTextField(context: context, form: form),
                descriptionTextField(context: context, vm: vm),
              ])))
    ];

@diegoveloper
Copy link
Owner

diegoveloper commented Dec 25, 2021 via email

@BenjiFarquhar
Copy link
Contributor Author

I am having trouble with that. But if this helps, it doesn't have the gap when I do disableScroll: true. It is the area that scrolls which becomes empty.

@BenjiFarquhar
Copy link
Contributor Author

I'm pretty sure it is this: #48 It seems like a bug with autoscroll.

@BenjiFarquhar
Copy link
Contributor Author

BenjiFarquhar commented Dec 26, 2021

If I have anything that takes up space below my KeyboardActions(), it increases that gap. If I remove everything below it, then it is fixed. But I need to have a button below it.

@BenjiFarquhar
Copy link
Contributor Author

BenjiFarquhar commented Dec 26, 2021

It is a bug.

When you calculate the offset to "avoid" EG:

BottomAreaAvoider(
                key: bottomAreaAvoiderKey,
                areaToAvoid: _offset

It calculates the action bar height (45) + the device keyboard height:

    double newOffset = _currentAction!.displayActionBar
        ? _kBarSize
        : 0; // offset for the actions bar
    newOffset += MediaQuery.of(context)
        .viewInsets
        .bottom; // + offset for the system keyboard

The KeyboardActions widget then applies this offset, starting from the bottom of the KeyboardActions widget, which means if the KeyboardActions widget isn't at the bottom of the page, the offset will be too high - by the height of whatever is below it (The keyboard starts at the bottom of the view port, not the bottom of the KeyboardActions widget). It needs to at the very least have an offset parameter to pass to the KeyboardActions widget which is the distance from the bottom of the screen to the bottom of the KeyboardActions widget.

@diegoveloper
Copy link
Owner

Would you mind creating a PR to fix this issue? :D

@BenjiFarquhar
Copy link
Contributor Author

@diegoveloper Sure, I will give it a go

@BenjiFarquhar
Copy link
Contributor Author

@diegoveloper I have tried to push to my new branch "benjamin-farquhar/bug/172-fix-offset"; however, access is denied. Do you need to permit me?

@diegoveloper
Copy link
Owner

diegoveloper commented Dec 26, 2021 via email

diegoveloper pushed a commit that referenced this issue Dec 27, 2021
* #172 Fix gap between actions bar and page content

Fix a bug where if anything was below the KeyboardActions widget, it created a gap between the actions bar and page content

* Test with dialogs

* remove red testing background

* Fix bug pointed out by Diegoveloper in Sample 3

* Add Sample 5 to show bug behaviour
diegoveloper pushed a commit that referenced this issue Dec 27, 2021
…effects (#176)

Also tested in landscape mode which is now working (it wouldn't have before because _widgetHeight used to be only set once)
diegoveloper pushed a commit that referenced this issue Dec 28, 2021
Please see https://stackoverflow.com/a/64473806/3935156 for details on why there was so many inconsistencies in behaviour
diegoveloper pushed a commit that referenced this issue Jan 31, 2022
* #172 apply offset fix to dialogs

* Make more null safe, someone was experiencing a null reference exception
diegoveloper added a commit that referenced this issue Feb 14, 2022
* #172 Fix bugs found in "avoid" offset after more testing (#177)

Please see https://stackoverflow.com/a/64473806/3935156 for details on why there was so many inconsistencies in behaviour

* validation added

* #172 apply offset fix to dialogs (#178)

* Full null reference exception (#180)

* #172 apply offset fix to dialogs

* Make more null safe, someone was experiencing a null reference exception

* new version ready

* nit: clean readme

Co-authored-by: Benjamin Farquhar <bt.farquhar@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants