์ฐ์ ์์ ๊ฐ์ ํ๋ฉด์ ๊ทธ๋ฆฌ๊ธฐ ์ํด์ Scaffold ๋ด์์ ๋๊ฐ์ง๋ก ๋๋๋ค.
1. AppBar
2. Body
๊ทธ๋ฆฌ๊ณ Body - Column ๋ด์์ ํฌ๊ฒ ๋ค๊ฐ์ง ์์ญ์ผ๋ก ๋๋์๋ค.
1. ํ๋กํ ์์ญ
2. Text ์์ญ
3. ๋ฒํผ ์์ญ
4. Tab ์์ญ
appBar: AppBar(
backgroundColor: Colors.white,
title: Text(widget.title, style: TextStyle(color: Colors.black)),
leading: IconButton(icon: Icon(Icons.arrow_back_ios, color: Colors.blue), onPressed: () {}),
actions: [
IconButton(onPressed: () {}, icon: Icon(Icons.menu, color: Colors.blue))
],
),
Expanded(child: Row(
children: [
Expanded(child: CircleAvatar(
radius: 70,
backgroundImage: AssetImage("images/img1.jpeg"),
),flex: 1,),
Expanded(
child: SizedBox(
height: 100,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(_name, style : TextStyle(fontSize: 20, fontWeight: FontWeight.bold)),
Text(_job, style : TextStyle(fontSize: 18)),
Text(_detail, style : TextStyle(fontSize: 15)),
],
),
),
flex: 1,
)
],
),
flex: 2,
),
Expanded(
child: Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("50"),
Text("Posts")
],
),
),
Container(height: 50, width: 2, color: Colors.grey),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("10"),
Text("Likes")
],
),
),
Container(height: 50, width: 2, color: Colors.grey),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("3"),
Text("Shares")
],
),
)
],
),
flex: 1,
),
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
InkWell(
child: Container(
height: 50,
width: 180,
child: Text("Follow",
style: Theme.of(context).textTheme.caption?.copyWith(
color: Colors.white,
fontWeight: FontWeight.w500
),),
padding: EdgeInsets.all(10),
alignment: Alignment.center,
decoration: BoxDecoration(
color: Colors.blueAccent,
borderRadius: BorderRadius.circular(10),
),
),
onTap: () {},
),
InkWell(
child: Container(
height: 50,
width: 180,
child: Text("Message",
style: Theme.of(context).textTheme.caption?.copyWith(
color: Colors.black,
fontWeight: FontWeight.w500
),),
padding: EdgeInsets.all(10),
alignment: Alignment.center,
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(),
borderRadius: BorderRadius.circular(10),
),
),
onTap: () {},
),
],
),
flex: 1,
),
์ค๋๊ฑธ๋ ธ๋ ๋ถ๋ถ.. Tab์์ญ!
Tabbar์ TabBarView๋ฅผ ๊ฐ๊ฐ Expanded๋ก ๋ฌถ์ด DefaultTabController๋ก ๊ฐ์ธ์ฃผ์๋ค.
Expanded(child: DefaultTabController(
length: 2,
initialIndex: 0,
child: Column(
children: <Widget> [
Expanded(child: TabBar())
Expanded(child: TabBarView())
...
์๋ฐ์์ผ๋ก!
Expanded(
child: TabBar(
tabs: <Widget> [
new Tab(
icon: const Icon(Icons.directions_car, color: Colors.black),
),
new Tab(
icon: const Icon(Icons.train, color: Colors.black),
)
]
),flex: 1,
),
Expanded(
child: TabBarView(
children: <Widget>[
new Container(
child: GridView.count(
padding: const EdgeInsets.all(20),
crossAxisSpacing: 10,
mainAxisSpacing: 10,
crossAxisCount: 3,
children: <Widget> [
Expanded(
child: Ink.image(image: AssetImage("images/img1.jpeg")),
),
Expanded(
child: Ink.image(image: AssetImage("images/img1.jpeg")),
),
Expanded(
child: Ink.image(image: AssetImage("images/img1.jpeg")),
),
Expanded(
child: Ink.image(image: AssetImage("images/img1.jpeg")),
),
Expanded(
child: Ink.image(image: AssetImage("images/img1.jpeg")),
),
Expanded(
child: Ink.image(image: AssetImage("images/img1.jpeg")),
),
Expanded(
child: Ink.image(image: AssetImage("images/img1.jpeg")),
),
Expanded(
child: Ink.image(image: AssetImage("images/img1.jpeg")),
),
Expanded(
child: Ink.image(image: AssetImage("images/img1.jpeg")),
),
],
),
),
new Container(
child: GridView.count(
padding: const EdgeInsets.all(20),
crossAxisSpacing: 10,
mainAxisSpacing: 10,
crossAxisCount: 3,
children: <Widget> [
Expanded(
child: Ink.image(image: AssetImage("images/img1.jpeg")),
),
Expanded(
child: Ink.image(image: AssetImage("images/img1.jpeg")),
),
],
),
)
]
),flex: 5,
)
๊ทธ๋ฆฌ๊ณ ์ ์ฒด ์ฝ๋ ๐ฅ ๐ท ๐ป ๐ธ
import 'package:flutter/material.dart';
import 'package:flutter/src/material/colors.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
// This widget is the root of your application.
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primaryColor: Colors.black
),
home: const MyHomePage(title: 'Profile'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
String _name = "Soyun Jo";
String _job = "Engineer";
String _detail = "Flutter Developing";
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
backgroundColor: Colors.white,
title: Text(widget.title, style: TextStyle(color: Colors.black)),
leading: IconButton(icon: Icon(Icons.arrow_back_ios, color: Colors.blue), onPressed: () {}),
actions: [
IconButton(onPressed: () {}, icon: Icon(Icons.menu, color: Colors.blue))
],
),
body:
Column(
children: [
Expanded(child: Row(
children: [
Expanded(child: CircleAvatar(
radius: 70,
backgroundImage: AssetImage("images/img1.jpeg"),
),flex: 1,),
Expanded(
child: SizedBox(
height: 100,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(_name, style : TextStyle(fontSize: 20, fontWeight: FontWeight.bold)),
Text(_job, style : TextStyle(fontSize: 18)),
Text(_detail, style : TextStyle(fontSize: 15)),
],
),
),
flex: 1,
)
],
), flex: 2,
),
Expanded(
child: Row(
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("50"),
Text("Posts")
],
),
),
Container(height: 50, width: 2, color: Colors.grey),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("10"),
Text("Likes")
],
),
),
Container(height: 50, width: 2, color: Colors.grey),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("3"),
Text("Shares")
],
),
)
],
),
flex: 1,
),
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
InkWell(
child: Container(
height: 50,
width: 180,
child: Text("Follow",
style: Theme.of(context).textTheme.caption?.copyWith(
color: Colors.white,
fontWeight: FontWeight.w500
),),
padding: EdgeInsets.all(10),
alignment: Alignment.center,
decoration: BoxDecoration(
color: Colors.blueAccent,
borderRadius: BorderRadius.circular(10),
),
),
onTap: () {},
),
InkWell(
child: Container(
height: 50,
width: 180,
child: Text("Message",
style: Theme.of(context).textTheme.caption?.copyWith(
color: Colors.black,
fontWeight: FontWeight.w500
),),
padding: EdgeInsets.all(10),
alignment: Alignment.center,
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(),
borderRadius: BorderRadius.circular(10),
),
),
onTap: () {},
),
],
),
flex: 1,
),
Expanded(
child: DefaultTabController(
length: 2,
initialIndex: 0,
child: Column(
children: <Widget> [
Expanded(
child: TabBar(
tabs: <Widget> [
new Tab(
icon: const Icon(Icons.directions_car, color: Colors.black),
),
new Tab(
icon: const Icon(Icons.train, color: Colors.black),
)
]
),flex: 1,
),
Expanded(
child: TabBarView(
children: <Widget>[
new Container(
child: GridView.count(
padding: const EdgeInsets.all(20),
crossAxisSpacing: 10,
mainAxisSpacing: 10,
crossAxisCount: 3,
children: <Widget> [
Expanded(
child: Ink.image(image: AssetImage("images/img1.jpeg")),
),
Expanded(
child: Ink.image(image: AssetImage("images/img1.jpeg")),
),
Expanded(
child: Ink.image(image: AssetImage("images/img1.jpeg")),
),
Expanded(
child: Ink.image(image: AssetImage("images/img1.jpeg")),
),
Expanded(
child: Ink.image(image: AssetImage("images/img1.jpeg")),
),
Expanded(
child: Ink.image(image: AssetImage("images/img1.jpeg")),
),
Expanded(
child: Ink.image(image: AssetImage("images/img1.jpeg")),
),
Expanded(
child: Ink.image(image: AssetImage("images/img1.jpeg")),
),
Expanded(
child: Ink.image(image: AssetImage("images/img1.jpeg")),
),
],
),
),
new Container(
child: GridView.count(
padding: const EdgeInsets.all(20),
crossAxisSpacing: 10,
mainAxisSpacing: 10,
crossAxisCount: 3,
children: <Widget> [
Expanded(
child: Ink.image(image: AssetImage("images/img1.jpeg")),
),
Expanded(
child: Ink.image(image: AssetImage("images/img1.jpeg")),
),
],
),
)
]
),flex: 5,
)
],
),
),
flex: 5,
),
],
)
);
}
}
์์ง์ Flutter๋ก ํ๋ฉด์ ๊ทธ๋ฆฐ์ง ์ผ๋ง ๋์ง ์์
๊ฐ๋
์ฑ ์๋ ์ฝ๋๋ฅผ ์์ฑํ๊ธฐ ๋ณด๋ค๋
์ฐ์ ์ฅํฉํ๋๋ผ๋ ํ๋์ฝ๋ฉ + ๋น ๋ฅด๊ฒ ํ๋ฉด ๊ทธ๋ฆฌ๊ธฐ์ ์ค์ ์ ๋๊ณ ์๋ค.
ํ๋ฉด์ ๋ค ๊ทธ๋ฆฐ ์์ค์๋ ์ค๋ฅ๊ฐ....ใ ๋์ณ๋ฒ๋ ค