[FEAT] working on the image widget for dynamic memory management and caching.

This commit is contained in:
2025-09-12 19:24:14 -04:00
parent 08e4d97865
commit 02dd66516d

View File

@@ -1,5 +1,7 @@
//s1 Imports
//s2 Core Package Imports
import 'dart:ui';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'dart:convert';
@@ -301,9 +303,10 @@ class AstromicImage extends StatelessWidget {
// imageQuality is used as a downscale factor: 1.0 -> full target resolution, 0.5 -> half resolution
final double factor = imageQuality.clamp(0.1, 1.0);
// If size is infinite for a dimension, we skip resize for that dim (pass 0)
final int? targetWidth = size.width.isFinite ? (size.width * factor).clamp(1, 4096).toInt() : null;
final int? targetHeight = size.height.isFinite ? (size.height * factor).clamp(1, 4096).toInt() : null;
final double dpr = PlatformDispatcher.instance.views.first.devicePixelRatio;
final int? targetWidth = size.width.isFinite ? (size.width * factor * dpr).clamp(1, 4096).toInt() : null;
final int? targetHeight = size.height.isFinite ? (size.height * factor * dpr).clamp(1, 4096).toInt() : null;
ImageProvider baseProvider;
switch (type) {