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( |
19 | title: const Text('Expanded Row Sample'), |
20 | ), |
21 | body: const ExpandedExample(), |
22 | ), |
23 | ); |
24 | } |
25 | } |
26 | |
27 | class ExpandedExample extends StatelessWidget { |
28 | const ExpandedExample({super.key}); |
29 | |
30 | @override |
31 | Widget build(BuildContext context) { |
32 | return Center( |
33 | child: Row( |
34 | children: <Widget>[ |
35 | Expanded( |
36 | flex: 2, |
37 | child: Container( |
38 | color: Colors.amber, |
39 | height: 100, |
40 | ), |
41 | ), |
42 | Container( |
43 | color: Colors.blue, |
44 | height: 100, |
45 | width: 50, |
46 | ), |
47 | Expanded( |
48 | child: Container( |
49 | color: Colors.amber, |
50 | height: 100, |
51 | ), |
52 | ), |
53 | ], |
54 | ), |
55 | ); |
56 | } |
57 | } |
58 |