Last active
May 26, 2021 05:14
-
-
Save vladnicula/d4edbf7256e7c6cdc6ffaad45f2d32f3 to your computer and use it in GitHub Desktop.
Flutter Basic Responsiveness
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'; | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
debugShowCheckedModeBanner: false, | |
home: Scaffold( | |
body: Layout(), | |
), | |
); | |
} | |
} | |
class Box extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
var screenWidth = MediaQuery.of(context).size.width; | |
double boxSize = 132; | |
Color boxColor = Color.fromRGBO(133, 162, 163, 1); | |
if (screenWidth > 600) { | |
boxSize = 264; | |
boxColor = Color.fromRGBO(23, 114, 117, 1); | |
} | |
return Container( | |
child: Text("Box"), width: boxSize, height: boxSize, color: boxColor); | |
} | |
} | |
class Layout extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Row( | |
mainAxisSize: MainAxisSize.max, | |
crossAxisAlignment: CrossAxisAlignment.center, | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: [Box()]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment