TF-4075 Use Scrollable.ensureVisible replace for animateTo
(cherry picked from commit aa187c17f7952a66d237abbe1f66efb2f01fd298)
This commit is contained in:
@@ -1,31 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
extension ScrollControllerExtension on ScrollController {
|
extension ScrollControllerExtension on ScrollController {
|
||||||
void scrollToWidgetTop({
|
|
||||||
required GlobalKey key,
|
|
||||||
double padding = 70,
|
|
||||||
}) {
|
|
||||||
final context = key.currentContext;
|
|
||||||
if (context == null) return;
|
|
||||||
|
|
||||||
final renderBox = context.findRenderObject();
|
|
||||||
if (renderBox is! RenderBox) return;
|
|
||||||
|
|
||||||
final offsetY = renderBox.localToGlobal(Offset.zero).dy;
|
|
||||||
final currentScroll = offset;
|
|
||||||
|
|
||||||
final targetOffset = (currentScroll + offsetY - padding).clamp(
|
|
||||||
position.minScrollExtent,
|
|
||||||
position.maxScrollExtent,
|
|
||||||
);
|
|
||||||
|
|
||||||
animateTo(
|
|
||||||
targetOffset,
|
|
||||||
duration: const Duration(milliseconds: 500),
|
|
||||||
curve: Curves.easeInOut,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void scrollToBottomWithPadding({required double padding}) {
|
void scrollToBottomWithPadding({required double padding}) {
|
||||||
try {
|
try {
|
||||||
final maxExtent = position.maxScrollExtent;
|
final maxExtent = position.maxScrollExtent;
|
||||||
|
|||||||
+7
-3
@@ -22,9 +22,13 @@ extension HandleOpenAttachmentListExtension on SingleEmailController {
|
|||||||
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
if (PlatformInfo.isWeb && attachmentListKey != null) {
|
if (PlatformInfo.isWeb && attachmentListKey != null) {
|
||||||
scrollController.scrollToWidgetTop(
|
final context = attachmentListKey!.currentContext;
|
||||||
key: attachmentListKey!,
|
if (context == null) return;
|
||||||
padding: 70,
|
|
||||||
|
Scrollable.ensureVisible(
|
||||||
|
context,
|
||||||
|
duration: const Duration(milliseconds: 500),
|
||||||
|
curve: Curves.easeInOut,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
final emailContentHeight =
|
final emailContentHeight =
|
||||||
|
|||||||
Reference in New Issue
Block a user