Created
October 2, 2022 11:24
-
-
Save iamEtornam/e36d8d3cf7e47eb6bf417f0c63481cf9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
class MediaQueryExample extends StatelessWidget { | |
const MediaQueryExample({Key? key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
final size = .of(context).size; | |
return Scaffold( | |
appBar: AppBar(title: const Text('MediaQuery Example')), | |
body: Column( | |
children: [ | |
if (size.width < 400) ...{ | |
Container( | |
height: size.height, | |
color: Colors.red, | |
padding: const EdgeInsets.symmetric(vertical: 40, horizontal: 16), | |
child: const Center(child: Text('mobile view'))), | |
} else ...{ | |
Row( | |
children: [ | |
Container( | |
width: size.width / 4, | |
height: size.height, | |
color: Colors.red, | |
padding: const EdgeInsets.symmetric(vertical: 40, horizontal: 16), | |
child: const Center(child: Text('Side navigation'))), | |
Expanded( | |
child: Container( | |
width: size.width, | |
height: size.height, | |
color: Colors.blue, | |
child: const Center(child: Text('main view')), | |
)) | |
], | |
) | |
} | |
], | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment