Search
Duplicate

์ž…๋ ฅ ์œ„์ ฏ

์ž…๋ ฅ ์œ„์ ฏ

โ€ข
TextField
โ€ข
Checbox
โ€ข
Radio
โ€ข
Switch
โ€ข
Button
โ—ฆ
TextButton
โ—ฆ
ElevatedButton
โ—ฆ
OutlineButton

TextField

์‚ฌ์šฉ์ž๋กœ๋ถ€ํ„ฐ ํ…์ŠคํŠธ๋ฅผ ์ž…๋ ฅ๋ฐ›์„ ์ˆ˜ ์žˆ๋Š” ์œ„์ ฏ

๋ฌธ๋ฒ•

TextField( controller: TextEditingController(), // ํ…์ŠคํŠธ ํ•„๋“œ์˜ ๊ฐ’๊ณผ ์ƒํ˜ธ ์ž‘์šฉํ•˜๊ธฐ ์œ„ํ•œ ์ปจํŠธ๋กค๋Ÿฌ (์˜ต์…˜) decoration: InputDecoration( labelText: 'Enter your text', // ํ…์ŠคํŠธ ํ•„๋“œ์˜ ๋ผ๋ฒจ (์˜ต์…˜) hintText: 'Type something...', // ํ…์ŠคํŠธ ํ•„๋“œ ๋‚ด์— ํžŒํŠธ๋ฅผ ์ œ๊ณต (์˜ต์…˜) ), onChanged: (value) { // ํ…์ŠคํŠธ๊ฐ€ ๋ณ€๊ฒฝ๋  ๋•Œ ์‹คํ–‰๋˜๋Š” ์ฝœ๋ฐฑ ํ•จ์ˆ˜ }, )
Dart
๋ณต์‚ฌ

์˜ˆ์‹œ

import 'package:flutter/material.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( title: Text('TextField Example'), ), body: Center( child: TextField( controller: TextEditingController(), decoration: InputDecoration( labelText: 'Enter your text', hintText: 'Type something...', ), onChanged: (value) { print('Text value changed: $value'); }, ), ), ), ); } }
Dart
๋ณต์‚ฌ

Checbox

์‚ฌ์šฉ์ž๊ฐ€ ์„ ํƒ ์—ฌ๋ถ€๋ฅผ ๋‚˜ํƒ€๋‚ผ ์ˆ˜ ์žˆ๋Š” ์œ„์ ฏ

๋ฌธ๋ฒ•

Checkbox( value: true, // ์ฒดํฌ๋ฐ•์Šค์˜ ์ดˆ๊ธฐ๊ฐ’ (true ๋˜๋Š” false) onChanged: (value) { // ์ฒดํฌ๋ฐ•์Šค์˜ ์ƒํƒœ๊ฐ€ ๋ณ€๊ฒฝ๋  ๋•Œ ์‹คํ–‰๋˜๋Š” ์ฝœ๋ฐฑ ํ•จ์ˆ˜ }, )
Dart
๋ณต์‚ฌ

์˜ˆ์‹œ

import 'package:flutter/material.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( title: Text('Checkbox Example'), ), body: Center( child: Checkbox( value: true, onChanged: (value) { print('Checkbox value changed: $value'); }, ), ), ), ); } }
Dart
๋ณต์‚ฌ

Radio

์—ฌ๋Ÿฌ ์˜ต์…˜ ์ค‘ ํ•˜๋‚˜๋ฅผ ์„ ํƒํ•  ์ˆ˜ ์žˆ๋Š” ๋ผ๋””์˜ค ๋ฒ„ํŠผ ์œ„์ ฏ

๋ฌธ๋ฒ•

Radio( value: 1, // ๋ผ๋””์˜ค ๋ฒ„ํŠผ์˜ ๊ฐ’ groupValue: selectedValue, // ๊ทธ๋ฃน ๋‚ด์—์„œ ํ˜„์žฌ ์„ ํƒ๋œ ๊ฐ’ onChanged: (value) { // ๋ผ๋””์˜ค ๋ฒ„ํŠผ์˜ ์ƒํƒœ๊ฐ€ ๋ณ€๊ฒฝ๋  ๋•Œ ์‹คํ–‰๋˜๋Š” ์ฝœ๋ฐฑ ํ•จ์ˆ˜ }, )
Dart
๋ณต์‚ฌ

์˜ˆ์‹œ

import 'package:flutter/material.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { int selectedValue = 1; Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( title: Text('Radio Example'), ), body: Center( child: Radio( value: 1, groupValue: selectedValue, onChanged: (value) { print('Radio value changed: $value'); }, ), ), ), ); } }
Dart
๋ณต์‚ฌ

Switch

์‚ฌ์šฉ์ž๊ฐ€ ํŠน์ • ์˜ต์…˜์˜ ์ƒํƒœ๋ฅผ ํ† ๊ธ€ํ•  ์ˆ˜ ์žˆ๋Š” ์Šค์œ„์น˜ ์œ„์ ฏ

๋ฌธ๋ฒ•

Switch( value: true, // ์Šค์œ„์น˜์˜ ์ดˆ๊ธฐ๊ฐ’ (true ๋˜๋Š” false) onChanged: (value) { // ์Šค์œ„์น˜์˜ ์ƒํƒœ๊ฐ€ ๋ณ€๊ฒฝ๋  ๋•Œ ์‹คํ–‰๋˜๋Š” ์ฝœ๋ฐฑ ํ•จ์ˆ˜ }, )
Dart
๋ณต์‚ฌ

์˜ˆ์‹œ

import 'package:flutter/material.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( title: Text('Switch Example'), ), body: Center( child: Switch( value: true, onChanged: (value) { print('Switch value changed: $value'); }, ), ), ), ); } }
Dart
๋ณต์‚ฌ

Button

โ€ข
TextButton
โ€ข
ElevatedButton
โ€ข
OutlineButton

TextButton

๊ฐ„๋‹จํ•œ ํ…์ŠคํŠธ ๋ฒ„ํŠผ

๋ฌธ๋ฒ•

TextButton( onPressed: () { // ๋ฒ„ํŠผ์ด ๋ˆŒ๋ ธ์„ ๋•Œ ์‹คํ–‰๋˜๋Š” ์ฝœ๋ฐฑ ํ•จ์ˆ˜ }, child: Text('Press me'), // ๋ฒ„ํŠผ์— ํ‘œ์‹œ๋  ํ…์ŠคํŠธ )
Dart
๋ณต์‚ฌ

์˜ˆ์‹œ

import 'package:flutter/material.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( title: Text('TextButton Example'), ), body: Center( child: TextButton( onPressed: () { print('TextButton pressed'); }, child: Text('Press me'), ), ), ), ); } }
Dart
๋ณต์‚ฌ

ElevatedButton

๋†’์€ ํ‘œ๋ฉด์—์„œ ๋– ์˜ค๋ฅด๋Š” ํšจ๊ณผ๋ฅผ ๊ฐ€์ง„ ๋ฒ„ํŠผ

๋ฌธ๋ฒ•

ElevatedButton( onPressed: () { // ๋ฒ„ํŠผ์ด ๋ˆŒ๋ ธ์„ ๋•Œ ์‹คํ–‰๋˜๋Š” ์ฝœ๋ฐฑ ํ•จ์ˆ˜ }, child: Text('Press me'), // ๋ฒ„ํŠผ์— ํ‘œ์‹œ๋  ํ…์ŠคํŠธ )
Dart
๋ณต์‚ฌ

์˜ˆ์‹œ

import 'package:flutter/material.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( title: Text('ElevatedButton Example'), ), body: Center( child: ElevatedButton( onPressed: () { print('ElevatedButton pressed'); }, child: Text('Press me'), ), ), ), ); } }
Dart
๋ณต์‚ฌ

OutlineButton

์™ธ๊ณฝ์„ ์ด ์žˆ๋Š” ๋ฒ„ํŠผ

๋ฌธ๋ฒ•

OutlinedButton( onPressed: () { // ๋ฒ„ํŠผ์ด ๋ˆŒ๋ ธ์„ ๋•Œ ์‹คํ–‰๋˜๋Š” ์ฝœ๋ฐฑ ํ•จ์ˆ˜ }, child: Text('Press me'), // ๋ฒ„ํŠผ์— ํ‘œ์‹œ๋  ํ…์ŠคํŠธ )
Dart
๋ณต์‚ฌ

์˜ˆ์‹œ

import 'package:flutter/material.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( title: Text('OutlinedButton Example'), ), body: Center( child: OutlinedButton( onPressed: () { print('OutlinedButton pressed'); }, child: Text('Press me'), ), ), ), ); } }
Dart
๋ณต์‚ฌ

Flutter ์ž…๋ ฅ ์œ„์ ฏ ๋ถ„๋ฅ˜

1. ์ผ๋ฐ˜ ์ž…๋ ฅ ์œ„์ ฏ (Form๊ณผ ๊ด€๊ณ„ ์—†์Œ)

Form์˜ validate(), save()์™€ ์—ฐ๊ฒฐ๋˜์ง€ ์•Š๋Š” ์œ„์ ฏ
์œ„์ ฏ
์„ค๋ช…
TextField
ํ…์ŠคํŠธ ์ž…๋ ฅ
Checkbox
์ฒดํฌ๋ฐ•์Šค
Radio
๋ผ๋””์˜ค ๋ฒ„ํŠผ
Switch
์Šค์œ„์น˜
Slider
์Šฌ๋ผ์ด๋”
DropdownButton
๋“œ๋กญ๋‹ค์šด
Button
์ผ๋ฐ˜ ๋ฒ„ํŠผ
TextButton
ํ…์ŠคํŠธ ๋ฒ„ํŠผ
ElevatedButton
๊ฐ•์กฐ ๋ฒ„ํŠผ
OutlinedButton
ํ…Œ๋‘๋ฆฌ ๋ฒ„ํŠผ

ํŠน์ง•

โ€ข
Form ์—†์ด ์‚ฌ์šฉ
โ€ข
validator ์—†์Œ
โ€ข
onSaved ์—†์Œ
โ€ข
onChanged๋กœ ๊ฐ’ ์ฒ˜๋ฆฌ
โ€ข
Controller๋กœ ๊ฐ’ ๊ด€๋ฆฌ

์˜ˆ์‹œ

TextField( onChanged: (value) { print(value); }, ) Checkbox( value: isChecked, onChanged: (value) { setState(() { isChecked = value!; }); }, )
Dart
๋ณต์‚ฌ

2. Form์šฉ ์ž…๋ ฅ ์œ„์ ฏ (FormField ๊ณ„์—ด)

Form ์•ˆ์—์„œ ์‚ฌ์šฉํ•˜๋ฉฐ, validate(), save() ์‚ฌ์šฉ ๊ฐ€๋Šฅ
Form ์œ„์ ฏ
์„ค๋ช…
TextFormField
ํ…์ŠคํŠธ ์ž…๋ ฅ
DropdownButtonFormField
๋“œ๋กญ๋‹ค์šด
FormField
์ปค์Šคํ…€ ํผ ์œ„์ ฏ
Checkbox โ†’ FormField๋กœ ๊ฐ์‹ธ์„œ ์‚ฌ์šฉ
Radio โ†’ FormField๋กœ ๊ฐ์‹ธ์„œ ์‚ฌ์šฉ
Switch โ†’ FormField๋กœ ๊ฐ์‹ธ์„œ ์‚ฌ์šฉ

ํŠน์ง•

โ€ข
Form ์•ˆ์—์„œ ์‚ฌ์šฉ
โ€ข
validator ์‚ฌ์šฉ ๊ฐ€๋Šฅ
โ€ข
onSaved ์‚ฌ์šฉ ๊ฐ€๋Šฅ
โ€ข
FormState.validate()
โ€ข
FormState.save()

์˜ˆ์‹œ

TextFormField( validator: (value) { if (value!.isEmpty) return "๊ฐ’ ์ž…๋ ฅ"; return null; }, onSaved: (value) { print(value); }, )
Dart
๋ณต์‚ฌ

3. Checkbox / Radio / Switch ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•

checkbox, radio, switch ์ด ์œ„์ ฏ๋“ค์€ Form ์ „์šฉ ์œ„์ ฏ์ด ์—†์–ด์„œ, FormField๋กœ ๊ฐ์‹ธ์„œ ์‚ฌ์šฉ
FormField<bool>( initialValue: false, onSaved: (value) { print(value); }, builder: (state) { return CheckboxListTile( value: state.value, onChanged: (value) { state.didChange(value); }, title: Text("์•ฝ๊ด€ ๋™์˜"), ); }, )
Dart
๋ณต์‚ฌ

ํ•ต์‹ฌ ์ฝ”๋“œ

state.didChange(value);
Dart
๋ณต์‚ฌ
โ†’ Form์— ๊ฐ’ ์ „๋‹ฌ

4. ์ „์ฒด ์œ„์ ฏ ๋ถ„๋ฅ˜ ์ •๋ฆฌ (๋งค์šฐ ์ค‘์š”)

์ผ๋ฐ˜ ์ž…๋ ฅ ์œ„์ ฏ

TextField Checkbox Radio Switch Slider DropdownButton
Plain Text
๋ณต์‚ฌ

Form ์ž…๋ ฅ ์œ„์ ฏ

TextFormField DropdownButtonFormField FormField (Checkbox, Radio, Switch ์ปค์Šคํ…€)
Plain Text
๋ณต์‚ฌ

๋ฒ„ํŠผ

TextButton ElevatedButton OutlinedButton
Plain Text
๋ณต์‚ฌ
๋ฒ„ํŠผ์€ Form ์œ„์ ฏ์ด ์•„๋‹ˆ๋ผ
Form ์‹คํ–‰ ํŠธ๋ฆฌ๊ฑฐ ์—ญํ• 

5. Flutter Form ๊ตฌ์กฐ (์ค‘์š”)

Form โ”œโ”€ TextFormField โ”œโ”€ DropdownButtonFormField โ”œโ”€ FormField (Checkbox) โ”œโ”€ FormField (Radio) โ””โ”€ ElevatedButton (Submit)
Plain Text
๋ณต์‚ฌ

6. ์‹ค๋ฌด ๊ธฐ์ค€ ์‚ฌ์šฉ ๊ตฌ๋ถ„

ํ™”๋ฉด
์œ„์ ฏ
๋กœ๊ทธ์ธ
TextFormField
ํšŒ์›๊ฐ€์ž…
TextFormField + Form
๊ฒ€์ƒ‰์ฐฝ
TextField
์„ค์ • ํ™”๋ฉด
Switch
์„ค๋ฌธ์กฐ์‚ฌ
FormField
๊ฒŒ์‹œ๊ธ€ ์ž‘์„ฑ
TextFormField
ํ•„ํ„ฐ
DropdownButton

์ •๋ฆฌ

โ€ข
์ผ๋ฐ˜ ์ž…๋ ฅ ์œ„์ ฏ: TextField, Checkbox, Radio, Switch (Form ์—†์ด ์‚ฌ์šฉ)
โ€ข
Form ์ž…๋ ฅ ์œ„์ ฏ: TextFormField, DropdownButtonFormField, FormField (validate/save ๊ฐ€๋Šฅ)
โ€ข
Button: TextButton, ElevatedButton, OutlinedButton (Form ์‹คํ–‰ ํŠธ๋ฆฌ๊ฑฐ)
graph TD
    A["์ž…๋ ฅ ์œ„์ ฏ"] --> B{"Form ์‚ฌ์šฉ?"}
    B -->|"No"| C["์ผ๋ฐ˜ ์ž…๋ ฅ ์œ„์ ฏ"]
    B -->|"Yes"| D["Form ์ž…๋ ฅ ์œ„์ ฏ"]
    
    C --> C1["TextField"]
    C --> C2["Checkbox"]
    C --> C3["Radio"]
    C --> C4["Switch"]
    
    D --> D1["TextFormField"]
    D --> D2["DropdownButtonFormField"]
    D --> D3["FormField"]
    
    D1 --> E["Form"]
    D2 --> E
    D3 --> E
    
    E --> F["FormState"]
    F --> F1["validate()"]
    F --> F2["save()"]
    F --> F3["reset()"]
    
    G["Button"] --> H["Form ์‹คํ–‰"]
    H --> F1
Mermaid
๋ณต์‚ฌ

Flutter ์ž…๋ ฅ ์œ„์ ฏ ๊ตฌ์กฐ ํ•ต์‹ฌ ๊ฐœ๋…

Flutter ์ž…๋ ฅ ์‹œ์Šคํ…œ ๊ตฌ์กฐ๋ฅผ ์ดํ•ดํ•˜๋Š” ๊ฒƒ์ด ์ค‘์š”ํ•ฉ๋‹ˆ๋‹ค.
graph TD
    A["Input Widget"] --> B["FormField"]
    B --> C["Form"]
    C --> D["FormState"]
    D --> E["validate()"]
    D --> F["save()"]
    D --> G["reset()"]
Mermaid
๋ณต์‚ฌ
์ด ๊ตฌ์กฐ ์ดํ•ดํ•˜๋ฉด Flutter Form ๊ฑฐ์˜ ์™„์ „ํžˆ ์ดํ•ดํ•œ ๊ฒƒ์ž…๋‹ˆ๋‹ค.
๊ฐ•์˜๋…ธํŠธ์šฉ์œผ๋กœ Flutter ์ž…๋ ฅ ์œ„์ ฏ ๋ฐ์ดํ„ฐ ์ฒ˜๋ฆฌ ๋ฐฉ๋ฒ• 3๊ฐ€์ง€ ์ •๋ฆฌํ•ด๋“œ๋ฆฌ๊ฒ ์Šต๋‹ˆ๋‹ค.
์ด๊ฑฐ ์‹ค๋ฌด์—์„œ ๋งค์šฐ ์ค‘์š”ํ•œ ๊ฐœ๋…์ž…๋‹ˆ๋‹ค.

Flutter ์ž…๋ ฅ ์œ„์ ฏ ๊ฐ’ ๊ฐ€์ ธ์˜ค๋Š” ๋ฐฉ๋ฒ• 3๊ฐ€์ง€

1. Controller ๋ฐฉ์‹

2. Form ๋ฐฉ์‹

3. Map ๋ฐฉ์‹ (Form + onSaved)

1. Controller ๋ฐฉ์‹

๊ฐ€์žฅ ๊ธฐ๋ณธ์ ์ธ ๋ฐฉ๋ฒ•
๊ฐ TextField / TextFormField๋งˆ๋‹ค Controller๋ฅผ ์—ฐ๊ฒฐํ•˜๊ณ 
controller.text ๋กœ ๊ฐ’์„ ๊ฐ€์ ธ์˜ต๋‹ˆ๋‹ค.

๊ตฌ์กฐ

TextEditingController controller = TextEditingController();
Dart
๋ณต์‚ฌ
TextField( controller: controller, )
Dart
๋ณต์‚ฌ
print(controller.text);
Dart
๋ณต์‚ฌ

์˜ˆ์ œ

final emailController = TextEditingController(); final passwordController = TextEditingController(); ElevatedButton( onPressed: () { print(emailController.text); print(passwordController.text); }, child: Text("๋กœ๊ทธ์ธ"), )
Dart
๋ณต์‚ฌ

ํŠน์ง•

ํ•ญ๋ชฉ
์„ค๋ช…
๊ฐ’ ๊ฐ€์ ธ์˜ค๊ธฐ
controller.text
์‹ค์‹œ๊ฐ„ ๋ณ€๊ฒฝ
๊ฐ€๋Šฅ
์ดˆ๊ธฐ๊ฐ’ ์„ค์ •
controller.text =
์ž…๋ ฅ๊ฐ’ ์ œ์–ด
๊ฐ€๋Šฅ
๋‹จ์ 
ํ•„๋“œ ๋งŽ์œผ๋ฉด controller ๋งŽ์•„์ง

์–ธ์ œ ์‚ฌ์šฉ?

๋กœ๊ทธ์ธ ๊ฒ€์ƒ‰์ฐฝ ์ฑ„ํŒ… ์ž…๋ ฅ ํ”„๋กœํ•„ ์ˆ˜์ • ํ…์ŠคํŠธ ์ œ์–ด ํ•„์š”ํ•  ๋•Œ
Plain Text
๋ณต์‚ฌ

2. Form ๋ฐฉ์‹ (onSaved)

Form + TextFormField + onSaved ์‚ฌ์šฉ
Form์˜ save()๊ฐ€ ํ˜ธ์ถœ๋  ๋•Œ
๊ฐ TextFormField์˜ onSaved ์‹คํ–‰๋จ

๊ตฌ์กฐ

Form TextFormField onSaved formKey.currentState!.save()
Dart
๋ณต์‚ฌ

์˜ˆ์ œ

final _formKey = GlobalKey<FormState>(); String email = ''; String password = ''; Form( key: _formKey, child: Column( children: [ TextFormField( onSaved: (value) { email = value!; }, ), TextFormField( onSaved: (value) { password = value!; }, ), ElevatedButton( onPressed: () { _formKey.currentState!.save(); print(email); print(password); }, child: Text("์ €์žฅ"), ) ], ), )
Dart
๋ณต์‚ฌ

ํŠน์ง•

ํ•ญ๋ชฉ
์„ค๋ช…
๊ฐ’ ์ €์žฅ ์‹œ์ 
save() ํ˜ธ์ถœ
validator
์‚ฌ์šฉ ๊ฐ€๋Šฅ
controller ํ•„์š”
์—†์Œ
์ž…๋ ฅ ๋งŽ์„ ๋•Œ
์ข‹์Œ

์–ธ์ œ ์‚ฌ์šฉ?

ํšŒ์›๊ฐ€์ž… ์„ค๋ฌธ์กฐ์‚ฌ ๊ฒŒ์‹œ๊ธ€ ์ž‘์„ฑ ๊ด€๋ฆฌ์ž ์ž…๋ ฅํผ ์ž…๋ ฅ ํ•„๋“œ ๋งŽ์€ ํ™”๋ฉด
Plain Text
๋ณต์‚ฌ

3. Map ๋ฐฉ์‹ (์‹ค๋ฌด์—์„œ ๋งŽ์ด ์‚ฌ์šฉ)

Form + onSaved + Map ์ €์žฅ ๋ฐฉ์‹
API ์ „์†กํ•  ๋•Œ ๊ฐ€์žฅ ํŽธํ•จ

๊ตฌ์กฐ

Map<String, String> formData = {};
Dart
๋ณต์‚ฌ
TextFormField( onSaved: (value) => formData['email'] = value!, )
Dart
๋ณต์‚ฌ
_formKey.currentState!.save(); print(formData);
Dart
๋ณต์‚ฌ

์˜ˆ์ œ

final _formKey = GlobalKey<FormState>(); Map<String, String> formData = {}; Form( key: _formKey, child: Column( children: [ TextFormField( decoration: InputDecoration(labelText: "Email"), onSaved: (value) => formData['email'] = value!, ), TextFormField( decoration: InputDecoration(labelText: "Password"), onSaved: (value) => formData['password'] = value!, ), ElevatedButton( onPressed: () { _formKey.currentState!.save(); print(formData); }, child: Text("์ „์†ก"), ) ], ), )
Dart
๋ณต์‚ฌ

๊ฒฐ๊ณผ

{ email: test.com, password: 1234 }
Dart
๋ณต์‚ฌ
API ๋ณด๋‚ด๊ธฐ ๋งค์šฐ ์ข‹์Œ

4. ์„ธ ๊ฐ€์ง€ ๋ฐฉ๋ฒ• ๋น„๊ต (์ค‘์š”)

๋ฐฉ์‹
ํŠน์ง•
์‚ฌ์šฉ
Controller
์ง์ ‘ ์ œ์–ด
๋กœ๊ทธ์ธ, ๊ฒ€์ƒ‰
Form
save ์‹œ ์ €์žฅ
์ž…๋ ฅํผ
Map
API ์ „์†ก
ํšŒ์›๊ฐ€์ž…
onChanged
์‹ค์‹œ๊ฐ„
๊ฒ€์ƒ‰

5. ์‹ค๋ฌด ๊ธฐ์ค€ ์„ ํƒ ๋ฐฉ๋ฒ• (์ค‘์š”)

์ž…๋ ฅ ํ•„๋“œ ์ ๋‹ค โ†’ Controller ์ž…๋ ฅ ํ•„๋“œ ๋งŽ๋‹ค โ†’ Form ์„œ๋ฒ„ ์ „์†ก โ†’ Map ์‹ค์‹œ๊ฐ„ ๊ฒ€์ƒ‰ โ†’ onChanged
Plain Text
๋ณต์‚ฌ

Flutter ์ž…๋ ฅ ์ฒ˜๋ฆฌ ์ „์ฒด ๊ตฌ์กฐ ์ •๋ฆฌ

์ž…๋ ฅ ์œ„์ ฏ ๊ฐ’ ๊ฐ€์ ธ์˜ค๊ธฐ ๋ฐฉ๋ฒ• 1. Controller ๋ฐฉ์‹ controller.text 2. Form ๋ฐฉ์‹ onSaved โ†’ save() 3. Map ๋ฐฉ์‹ onSaved โ†’ Map ์ €์žฅ โ†’ API ์ „์†ก
Plain Text
๋ณต์‚ฌ

์‹ค๋ฌด์—์„œ ๊ฐ€์žฅ ๋งŽ์ด ์‚ฌ์šฉํ•˜๋Š” ํŒจํ„ด

if (_formKey.currentState!.validate()) { _formKey.currentState!.save(); api.send(formData); }
Dart
๋ณต์‚ฌ
์ด ๊ตฌ์กฐ๋Š”
Flutter ๋กœ๊ทธ์ธ / ํšŒ์›๊ฐ€์ž… / ๊ฒŒ์‹œํŒ / ์‡ผํ•‘๋ชฐ / ๊ด€๋ฆฌ์ž ํŽ˜์ด์ง€ ์ „๋ถ€ ๋™์ผํ•œ ํŒจํ„ด์ž…๋‹ˆ๋‹ค.