Last active
January 26, 2021 01:00
-
-
Save felipecastrosales/5c9234cfda7c6d6b8b6f4a86ab7112a7 to your computer and use it in GitHub Desktop.
FractionallySizedBoxSpace
This file contains 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(FractionallySizedBoxWidgetSpace()); | |
class FractionallySizedBoxWidgetSpace extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter Responsive', | |
debugShowCheckedModeBanner: false, | |
home: Scaffold( | |
appBar: AppBar( | |
title: Text('FractionallySizedBox - Space'), | |
centerTitle: true, | |
), | |
body: FractionallySizedBoxSpace(), | |
), | |
); | |
} | |
} | |
class FractionallySizedBoxSpace extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: [ | |
WidgetBlue(), | |
Flexible( | |
child: FractionallySizedBox( | |
heightFactor: 0.2, | |
), | |
), | |
WidgetRed(), | |
], | |
); | |
} | |
} | |
class WidgetBlue extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Container( | |
width: MediaQuery.of(context).size.width, | |
height: MediaQuery.of(context).size.height / 5, | |
color: Colors.blue, | |
); | |
} | |
} | |
class WidgetRed extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Container( | |
width: MediaQuery.of(context).size.width, | |
height: MediaQuery.of(context).size.height / 5, | |
color: Colors.red, | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment