MediaQuery
` class provided by the Flutter framework. This class provides a number of static methods that you can use to retrieve information about the device's display, such as the width and height of the screen, the orientation of the device, and the device's pixel density.import 'package:flutter/material.dart';
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
final mediaQuery = MediaQuery.of(context);
return Scaffold(
body: Container(
width: mediaQuery.size.width,
height: mediaQuery.size.height,
child: Center(
child: Text('Hello, world!'),
),
),
);
}
}
In this example, we use the `MediaQuery.of()
` method to retrieve a reference to the `MediaQueryData
` object, which contains information about the device's display. We then use the `size
` property of this object to set the width and height of a `Container
` widget, which is used as the background for the page.