Skip to content

Instantly share code, notes, and snippets.

@felipecastrosales
Last active January 26, 2021 01:00
Show Gist options
  • Save felipecastrosales/5c9234cfda7c6d6b8b6f4a86ab7112a7 to your computer and use it in GitHub Desktop.
Save felipecastrosales/5c9234cfda7c6d6b8b6f4a86ab7112a7 to your computer and use it in GitHub Desktop.
FractionallySizedBoxSpace
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