Search

μž…λ ₯ μœ„μ ―

μž…λ ₯ μœ„μ ―

β€’
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
볡사