Media Query in Flutter

0

 Media Query in Flutter




Another way to reap a responsive graph in Flutter is to use the MediaQuery widget. This widget affords records about the dimensions and competencies of the show screen, such as the display width and height, the machine pixel ratio, and the orientation. You can use this facts to construct widgets that adapt to the modern-day display screen conditions.


Example of the utilization of the media question widget 

@override

Widget build(BuildContext context) {

  var mediaQueryData = MediaQuery.of(context);

  var screenWidth = mediaQueryData.size.width;

  var screenHeight = mediaQueryData.size.height;

  var screenOrientation = mediaQueryData.orientation;


  return Container(

    width: screenWidth,

    height: screenHeight,

    child: Column(

      mainAxisAlignment: MainAxisAlignment.center,

      children: [

        Text('Screen Width: $screenWidth'),

        Text('Screen Height: $screenHeight'),

        Text('Screen Orientation: $screenOrientation'),

      ],

    ),

  );

}




Post a Comment

0Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.
Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !