fix: Avoid using MediaQuery.of()

This commit is contained in:
imnotlxy 2025-08-01 06:15:23 +08:00
commit d2c2fd48d4
13 changed files with 20 additions and 21 deletions

View file

@ -23,7 +23,7 @@ Future<T?> showModalActionPopup<T>({
clipBehavior: Clip.hardEdge,
constraints: BoxConstraints(
maxWidth: 512,
maxHeight: MediaQuery.of(context).size.height - 32,
maxHeight: MediaQuery.sizeOf(context).height - 32,
),
builder: (context) => ListView(
shrinkWrap: true,

View file

@ -7,7 +7,7 @@ class EmptyPage extends StatelessWidget {
const EmptyPage({super.key});
@override
Widget build(BuildContext context) {
final width = min(MediaQuery.of(context).size.width, EmptyPage._width) / 2;
final width = min(MediaQuery.sizeOf(context).width, EmptyPage._width) / 2;
final theme = Theme.of(context);
return Scaffold(
// Add invisible appbar to make status bar on Android tablets bright.

View file

@ -73,7 +73,7 @@ class _MxcImageState extends State<MxcImage> {
final event = widget.event;
if (uri != null) {
final devicePixelRatio = MediaQuery.of(context).devicePixelRatio;
final devicePixelRatio = MediaQuery.devicePixelRatioOf(context);
final width = widget.width;
final realWidth = width == null ? null : width * devicePixelRatio;
final height = widget.height;

View file

@ -35,7 +35,7 @@ class MxcImageViewer extends StatelessWidget {
maxScale: 10.0,
onInteractionEnd: (endDetails) {
if (endDetails.velocity.pixelsPerSecond.dy >
MediaQuery.of(context).size.height * 1.5) {
MediaQuery.sizeOf(context).height * 1.5) {
Navigator.of(context, rootNavigator: false).pop();
}
},