mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-01 00:28:18 +08:00
opt: get cacheSize
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -83,7 +83,6 @@ class NetworkImgLayer extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget placeholder(BuildContext context) {
|
Widget placeholder(BuildContext context) {
|
||||||
int cacheWidth = width.cacheSize(context);
|
|
||||||
return Container(
|
return Container(
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
@@ -106,7 +105,7 @@ class NetworkImgLayer extends StatelessWidget {
|
|||||||
: 'assets/images/loading.png',
|
: 'assets/images/loading.png',
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
cacheWidth: cacheWidth == 0 ? null : cacheWidth,
|
cacheWidth: width.cacheSize(context),
|
||||||
// cacheHeight: height.cacheSize(context),
|
// cacheHeight: height.cacheSize(context),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -4,9 +4,12 @@ import 'package:floating/floating.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
|
|
||||||
extension ImageExtension on num {
|
extension ImageExtension on num? {
|
||||||
int cacheSize(BuildContext context) {
|
int? cacheSize(BuildContext context) {
|
||||||
return (this * MediaQuery.of(context).devicePixelRatio).round();
|
if (this == null || this == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return (this! * MediaQuery.of(context).devicePixelRatio).round();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user