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';
|
||||
|
||||
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}) {
|
||||
try {
|
||||
final maxExtent = position.maxScrollExtent;
|
||||
|
||||
+7
-3
@@ -22,9 +22,13 @@ extension HandleOpenAttachmentListExtension on SingleEmailController {
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (PlatformInfo.isWeb && attachmentListKey != null) {
|
||||
scrollController.scrollToWidgetTop(
|
||||
key: attachmentListKey!,
|
||||
padding: 70,
|
||||
final context = attachmentListKey!.currentContext;
|
||||
if (context == null) return;
|
||||
|
||||
Scrollable.ensureVisible(
|
||||
context,
|
||||
duration: const Duration(milliseconds: 500),
|
||||
curve: Curves.easeInOut,
|
||||
);
|
||||
} else {
|
||||
final emailContentHeight =
|
||||
|
||||
Reference in New Issue
Block a user