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

fix(bug): fix bug where footer not attached to keyboard in some device and update flutter_keyboard_visibility #35

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

ryanaidilp
Copy link
Contributor

@ryanaidilp ryanaidilp commented Apr 5, 2024

PR Description

This PR introduces several enhancements and bug fixes to the keyboard_attachable package, significantly improving its reliability and functionality across different devices and scenarios. Here are the key changes:

Enhancements:

  • Linting Improvement: Removed an unnecessary linter rule from analysis_options.yaml to streamline code analysis and ensure consistency with Flutter's recommended linter rules.
  • Dependency Update: Upgraded the flutter_keyboard_visibility package from version 5.4.1 to 6.0.0. This update embraces the latest improvements and fixes from flutter_keyboard_visibility, ensuring better keyboard visibility handling. (Should resolve Update flutter_keyboard_visibility to 6.0.0 #34)

Bug Fixes:

  • Keyboard Height Calculation: Addressed an issue where the footer widget, when using KeyboardAttachable, sometimes did not attach correctly above the keyboard. This problem was due to incorrect keyboard height calculations on some devices, where MediaQuery.of(context).viewInsets.bottom returned 0. The fix involves using MediaQueryData.fromWindow(WidgetsBinding.instance.window) to obtain more accurate keyboard height measurements.
  • Animation and Bottom Inset Handling: Encapsulated bottomInset and animationBegin within a new KeyboardAnimationData class. This encapsulation promotes better data management and streamlines animation handling.
  • Metrics Change Listener: Implemented the WidgetBindingObserver mixin and utilized didChangeMetrics to listen to changes in the app's metrics. This approach ensures that the _updateBottomSizeIfNeeded logic is executed promptly, adjusting the UI in response to any metrics changes, including keyboard appearance.
  • State Management: Transitioned to using a ValueNotifier with KeyboardAnimationData instead of relying solely on local variables. This change guarantees that the UI is rebuilt when there are changes to the keyboard's visibility or size, addressing issues where the UI did not update on some devices.

These improvements aim to make keyboard_attachable more robust and versatile, providing a better developer experience and ensuring more consistent behavior across various devices.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class encapsulates bottomInset and animationBegin, allowing these properties to be bundled together. By encapsulating them within this class, we facilitate their use in a ValueNotifier, promoting a cleaner and more efficient way to manage and react to changes in these values.

Example:

ValueNotifier<KeyboardAnimationData> _keyboardAnimationDataNotifier = ValueNotifier(const KeyboardAnimationData());

This approach simplifies the tracking of keyboard animation data changes, enabling more responsive and straightforward UI updates.

@ryanaidilp
Copy link
Contributor Author

Please kindly review @drogel

@dantehemerson
Copy link

@drogel Can you check it please?

@arnab
Copy link

arnab commented Jul 30, 2024

Hello @drogel - would appreciate a review, merge and release of this (thanks @ryanaidilp for the change).

Our app is stuck on some other dependencies because of this version.

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

Successfully merging this pull request may close these issues.

Update flutter_keyboard_visibility to 6.0.0
3 participants