-
Notifications
You must be signed in to change notification settings - Fork 29.1k
Open
Description
Environment
- Device: Xiaomi Redmi Pad 2
- OS: Android 15 (API 35) – HyperOS 2.0.202.0
- Flutter version: 3.35.1
Steps to Reproduce
- Run the following minimal app:
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(home: HomePage());
}
}
class HomePage extends StatelessWidget {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
final mediaQuery = MediaQuery.of(context);
return Scaffold(
body: Container(
alignment: Alignment.center,
padding: EdgeInsets.all(32),
child: SingleChildScrollView(
child: Column(
children: [
Text('MediaQuery.size'),
Text('${mediaQuery.size}'),
Divider(),
Text('MediaQuery.padding'),
Text('${mediaQuery.padding}'),
Divider(),
Text('MediaQuery.viewPadding'),
Text('${mediaQuery.viewPadding}'),
Divider(),
Text('MediaQuery'),
Text('$mediaQuery'),
],
),
),
),
);
}
}
- Switch the app to floating window mode.
- Switch the app to split-screen mode.
Expected Results
MediaQuery.padding
andMediaQuery.viewPadding
should reflect the correct safe insets for the current window size (floating or split-screen).
Actual Results
Full Screen (works correctly):
MediaQuery.size: (1137.8, 711.1)
MediaQuery.padding: (0.0, 31.1, 0.0, 16.0)
MediaQuery.viewPadding: (0.0, 31.1, 0.0, 16.0)

Floating Window (incorrect):
MediaQuery.size: (420.4, 750.2)
MediaQuery.padding: (0.0, 750.2, 0.0, 31.1)
MediaQuery.viewPadding: (0.0, 750.2, 0.0, 31.1)

Split Screen (incorrect):
MediaQuery.size: (563.6, 711.1)
MediaQuery.padding: (0.0, 711.1, 0.0, 16.0)
MediaQuery.viewPadding: (0.0, 711.1, 0.0, 16.0)

Impact
This unexpected behavior makes it impossible to correctly use the SafeArea
widget in floating window or split-screen mode. Currently, any layout or calculation that depends on MediaQuery.padding
(or viewPadding
) produces incorrect results, since the values are based on the full device height instead of the actual window size.
Metadata
Metadata
Assignees
Labels
No labels