added image cache managing
This commit is contained in:
parent
b7045fc242
commit
2ff4d44d25
14 changed files with 188 additions and 80 deletions
|
@ -0,0 +1,11 @@
|
|||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import 'const_colors.dart';
|
||||
|
||||
abstract class ConstText {
|
||||
static const _imageOverlayTextStyle = TextStyle(
|
||||
color: ConstColours.white,
|
||||
fontSize: 28,
|
||||
);
|
||||
static TextStyle imageOverlayTextStyle(BuildContext context) => _imageOverlayTextStyle;
|
||||
}
|
|
@ -11,16 +11,13 @@ class OverlayService {
|
|||
|
||||
final LoggingService _loggingService;
|
||||
|
||||
final Map<int, AnimationController> _animationControllerMap = const {};
|
||||
final Map<int, OverlayEntry> _overlayEntryMap = const {};
|
||||
|
||||
Future<void> playOverlayEntry({
|
||||
required BuildContext context,
|
||||
required AnimationController animationController,
|
||||
required OverlayEntry overlayEntry,
|
||||
}) async {
|
||||
try {
|
||||
_animationControllerMap[animationController.hashCode] = animationController;
|
||||
_overlayEntryMap[overlayEntry.hashCode] = overlayEntry;
|
||||
Overlay.of(
|
||||
context,
|
||||
|
@ -28,12 +25,9 @@ class OverlayService {
|
|||
)!
|
||||
.insert(overlayEntry);
|
||||
|
||||
await animationController.forward();
|
||||
if (overlayEntry.mounted) overlayEntry.remove();
|
||||
|
||||
_overlayEntryMap.remove(overlayEntry.hashCode);
|
||||
animationController.dispose();
|
||||
_animationControllerMap.remove(animationController.hashCode);
|
||||
} catch (error, stackTrace) {
|
||||
_loggingService.handle(error, stackTrace);
|
||||
}
|
||||
|
@ -46,12 +40,6 @@ class OverlayService {
|
|||
}
|
||||
}
|
||||
_overlayEntryMap.clear();
|
||||
for (final animationController in _animationControllerMap.values) {
|
||||
if (animationController.isAnimating) {
|
||||
animationController.dispose();
|
||||
}
|
||||
}
|
||||
_animationControllerMap.clear();
|
||||
}
|
||||
|
||||
static OverlayService get locate => Locator.locate();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue