Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
Tags
- Snackbar
- AppBar
- Flutter 앱 배포
- Flutter Example
- Row
- Flutter 강좌
- Load Image
- InkWell
- listview
- flutter
- WillPopScope
- ListTile
- Flutter Tutorial
- Row Widget
- FutureBuilder
- Cached Image
- node.js
- HTTP
- Column Widget
- Flutter 예제
- ListView.builder
- Hello World
- Networking
- MainAxisAlignment
- navigator
- 반석천
- sqlite
- Image.network
- CrossAxisAlignment
- Scaffold
Archives
- Today
- Total
꿈꾸는 시스템 디자이너
Flutter Example - Expanded Widget 본문
import 'package:flutter/material.dart';
ExpandedWidgetState pageState;
class ExpandedWidget extends StatefulWidget {
@override
ExpandedWidgetState createState() {
pageState = ExpandedWidgetState();
return pageState;
}
}
class ExpandedWidgetState extends State<ExpandedWidget> {
List<int> flexList = [1, 1, 1, 1, 1, 1];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("ExpandedWidget")),
body: ListView(
children: <Widget>[
Text("Row"),
Container(
decoration: BoxDecoration(
color: Colors.grey[200],
border: Border.all(color: Colors.indigo, width: 0.5)),
height: 100,
child: Row(
children: <Widget>[
Expanded(
flex: flexList[0],
child: boxWidget(0),
),
Expanded(
flex: flexList[1],
child: boxWidget(1),
),
Expanded(
flex: flexList[2],
child: boxWidget(2),
),
],
),
),
Text("\nColumn"),
Container(
decoration: BoxDecoration(
color: Colors.grey[200],
border: Border.all(color: Colors.indigo, width: 0.5)),
height: 300,
child: Column(
children: <Widget>[
Expanded(
flex: flexList[3],
child: boxWidget(3),
),
Expanded(
flex: flexList[4],
child: boxWidget(4),
),
Expanded(
flex: flexList[5],
child: boxWidget(5),
),
],
),
),
Center(
child: FlatButton(
color: Colors.orange,
child: Text("reset", style: TextStyle(color: Colors.white)),
onPressed: () {
setState(() {
flexList = [1, 1, 1, 1, 1, 1];
});
},
),
)
],
),
);
}
boxWidget(int flexIndex) {
return GestureDetector(
child: Container(
// height: 30,
// width: 50,
decoration: BoxDecoration(
color: Colors.blue[400],
border: Border.all(color: Colors.indigo, width: 0.5)),
child: Center(
child: Text("flex: ${flexList[flexIndex]}",
style: TextStyle(
fontSize: 12,
color: Colors.white,
fontWeight: FontWeight.bold))),
),
onTap: () {
print(flexIndex);
setState(() {
flexList[flexIndex] = flexList[flexIndex] + 1;
});
},
);
}
}
▶ Go to Table of Contents | 강의 목차로 이동
※ This example is also available in the Flutter Code Examples app. | 본 예제는 Flutter Code Examples 앱에서도 제공됩니다.
'Tutorial > Flutter with App' 카테고리의 다른 글
Flutter Example - SnackBar Widget (0) | 2019.09.26 |
---|---|
Flutter Example - Container Widget (0) | 2019.09.26 |
Flutter Example - Column Widget - Alignment (0) | 2019.09.24 |
Flutter Example - Column Widget - Basic (0) | 2019.09.24 |
Flutter Example - Row Widget - CrossAxisAlignment (0) | 2019.09.24 |
Comments