Files
PiliPlus/lib/utils/extension.dart
2024-08-30 14:07:46 +08:00

21 lines
531 B
Dart

import 'package:flutter/material.dart';
import 'package:get/get.dart';
extension ImageExtension on num {
int cacheSize(BuildContext context) {
return (this * MediaQuery.of(context).devicePixelRatio).round();
}
}
extension ScrollControllerExt on ScrollController {
void animToTop() {
if (!hasClients) return;
if (offset >= MediaQuery.of(Get.context!).size.height * 5) {
jumpTo(0);
} else {
animateTo(0,
duration: const Duration(milliseconds: 500), curve: Curves.easeInOut);
}
}
}