반응형
[Flutter] 플러터 기초 (9) - 로그인 페이지 예제(login page tutorial)
Flutter 플러터 기초 (9) - 로그인 페이지 예제(login page tutorial)
이모티콘・01・고양이 마멋 친구들 - Google Play 앱
이모티콘・01・고양이 마멋 친구들: 무료 이모티콘, 회원가입 없이! 카톡, SNS로 감정 표현이 쉬워져요. 귀여움 가득, 대화창을 더 풍성하게!
play.google.com
안녕하세요 정보처리마법사 입니다.
이번 포스팅의 주제는 로그인 페이지 예제에 관한 내용입니다.
main.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
import 'package:flutter/material.dart';
import 'login_page.dart';
void main() {
runApp(new MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'login demo',
theme: new ThemeData(
primarySwatch: Colors.blue,
),
home: new LoginPage(),
);
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |
login_page.dart
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
import 'package:flutter/material.dart';
class LoginPage extends StatefulWidget {
@override
_LoginPageState createState() => _LoginPageState();
}
class _LoginPageState extends State<LoginPage> {
final formKey = new GlobalKey<FormState>();
String _email;
String _password;
void validateAndSave() {
final form = formKey.currentState;
if (form.validate()) {
print('Form is valid Email: $_email, password: $_password');
} else {
print('Form is invalid Email: $_email, password: $_password');
}
}
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text('login demo'),
),
body: new Container(
padding: EdgeInsets.all(16),
child: new Form(
key: formKey,
child: new Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
new TextFormField(
decoration: new InputDecoration(labelText: 'Email'),
validator: (value) =>
value.isEmpty ? 'Email can\'t be empty' : null,
onSaved: (value) => _email = value,
),
new TextFormField(
obscureText: true,
decoration: new InputDecoration(labelText: 'Password'),
validator: (value) =>
value.isEmpty ? 'Password can\'t be empty' : null,
onSaved: (value) => _password = value,
),
new RaisedButton(
child: new Text(
'Login',
style: new TextStyle(fontSize: 20.0),
),
onPressed: validateAndSave,
),
],
),
),
),
);
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |
Ctrl + C , Ctrl + V
Fin.
잘 못 된 정보가 있으면 말씀해주세요~
공감버튼 클릭은 작성자에게 큰 힘이 됩니다. 행복한 하루 되세요.
반응형