-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[webview_flutter] Fix scroll bar position for Android non-hybrid WebViews #3765
Conversation
…e comment here, this layout direction affects the rendering of the scroll bar.
| // WebView content is not affected by the Android view's layout direction, | ||
| // we explicitly set it here so that the widget doesn't require an ambient | ||
| // directionality. | ||
| layoutDirection: TextDirection.rtl, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have you tested it with older Android versions? https://github.com/flutter/plugins/pull/1618/files suggests that this is necessary for some version of Android.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not seeing anywhere in that PR that specifically talks about this choice, or any indication that it would affect older Android versions. I'll do my best to test on a couple versions of Android though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested on M, O, and R, and haven't seen any negative side effects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if Amir meant TextDirection.ltr.
I noted is that this is technically a small breaking change as now a parent widget must provide the layout direction. I don't know how common it's, but by looking at the changes to the unit test, I wonder if changing this value to TextDirection.ltr removes potential failures in other unit tests that we don't own.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsurprisingly, that introduces the inverse problem that in an RTL locale, the scroll bars are on the wrong side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also use https://api.flutter.dev/flutter/widgets/Directionality/maybeOf.html to detect the current direction, and if null we set LTR as the default. wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oooh that's a neat trick. I left the default as RTL to minimize side effects, but I can swap to LTR if you'd prefer.
…ally specify a layoutDirection, it must have a Directionality widget as an ancestor to derive the direction from.
…t internally specify a layoutDirection, it must have a Directionality widget as an ancestor to derive the direction from." This reverts commit 793902f. # Conflicts: # packages/webview_flutter/test/webview_flutter_test.dart
…tDirection without introducing a possibly-breaking change.
blasten
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fixes a bug where scroll bars on the Android non-hybrid WebView are rendered on the wrong side of the screen.
fixes flutter/flutter#79312
fixes flutter/flutter#66208
Pre-launch Checklist
[shared_preferences]///).If you need help, consider asking for advice on the #hackers-new channel on Discord.