Skip to content

Instantly share code, notes, and snippets.

@felipecastrosales
Last active January 23, 2021 16:54
Show Gist options
  • Save felipecastrosales/6bdbe66fbd351ea05c804fb3c5945be4 to your computer and use it in GitHub Desktop.
Save felipecastrosales/6bdbe66fbd351ea05c804fb3c5945be4 to your computer and use it in GitHub Desktop.
flexible_loose_tight.dart
import 'package:flutter/material.dart';
void main() => runApp(FlexibleExample03());
class FlexibleExample03 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
title: Text('Flexible - Tight & Loose'),
centerTitle: true,
),
body: Column(
children: [
Flexible(
flex: 3,
fit: FlexFit.tight, // loose
child: Container(
height: 250,
color: Colors.orange,
),
),
Flexible(
flex: 1,
child: WidgetPurple(),
),
Flexible(
flex: 1,
child: WidgetBlue(),
),
],
),
),
);
}
}
class WidgetPurple extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
color: Colors.purple,
);
}
}
class WidgetBlue extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
color: Colors.teal,
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment