| 1 | // Copyright 2014 The Flutter Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | import 'package:flutter/material.dart'; |
| 6 | |
| 7 | /// Flutter code sample for [Expanded]. |
| 8 | |
| 9 | void main() => runApp(const ExpandedApp()); |
| 10 | |
| 11 | class ExpandedApp extends StatelessWidget { |
| 12 | const ExpandedApp({super.key}); |
| 13 | |
| 14 | @override |
| 15 | Widget build(BuildContext context) { |
| 16 | return MaterialApp( |
| 17 | home: Scaffold( |
| 18 | appBar: AppBar(title: const Text('Expanded Row Sample' )), |
| 19 | body: const ExpandedExample(), |
| 20 | ), |
| 21 | ); |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | class ExpandedExample extends StatelessWidget { |
| 26 | const ExpandedExample({super.key}); |
| 27 | |
| 28 | @override |
| 29 | Widget build(BuildContext context) { |
| 30 | return Center( |
| 31 | child: Row( |
| 32 | children: <Widget>[ |
| 33 | Expanded(flex: 2, child: Container(color: Colors.amber, height: 100)), |
| 34 | Container(color: Colors.blue, height: 100, width: 50), |
| 35 | Expanded(child: Container(color: Colors.amber, height: 100)), |
| 36 | ], |
| 37 | ), |
| 38 | ); |
| 39 | } |
| 40 | } |
| 41 | |