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;
|
||||
|
||||
Reference in New Issue
Block a user