Notice
Recent Posts
Recent Comments
Link
250x250
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- CustomScrollView
- drift
- binding
- 앱
- 앱바
- tabbar
- activity
- intent
- TEST
- Button
- textview
- appbar
- textfield
- ScrollView
- data
- Compose
- 계측
- 안드로이드
- android
- 테스트
- viewmodel
- Kotlin
- Dialog
- DART
- LifeCycle
- scroll
- Coroutines
- livedata
- Flutter
- Navigation
Archives
- Today
- Total
Study Record
[Flutter] 입력 받기 (TextField) 본문
728x90
✍ TextField Widget
하드웨어 키보드 또는 화면 키보드를 사용하여 텍스트를 입력할 수 있다.
TextField({
Key? key,
TextEditingController? controller,
FocusNode? focusNode,
InputDecoration? decoration = const InputDecoration(),
TextInputType? keyboardType,
TextInputAction? textInputAction,
TextCapitalization textCapitalization = TextCapitalization.none,
TextStyle? style,
StrutStyle? strutStyle,
TextAlign textAlign = TextAlign.start,
TextAlignVertical? textAlignVertical,
TextDirection? textDirection,
bool readOnly = false,
ToolbarOptions? toolbarOptions,
bool? showCursor,
bool autofocus = false,
String obscuringCharacter = '•',
bool obscureText = false,
bool autocorrect = true,
SmartDashesType? smartDashesType,
SmartQuotesType? smartQuotesType,
bool enableSuggestions = true,
int? maxLines = 1,
int? minLines,
bool expands = false,
int? maxLength,
MaxLengthEnforcement? maxLengthEnforcement,
void Function(String)? onChanged,
void Function()? onEditingComplete,
void Function(String)? onSubmitted,
void Function(String, Map )? onAppPrivateCommand,
List ? inputFormatters,
bool? enabled,
double cursorWidth = 2.0,
double? cursorHeight,
Radius? cursorRadius,
Color? cursorColor,
BoxHeightStyle selectionHeightStyle = ui.BoxHeightStyle.tight,
BoxWidthStyle selectionWidthStyle = ui.BoxWidthStyle.tight,
Brightness? keyboardAppearance,
EdgeInsets scrollPadding = const EdgeInsets.all(20.0),
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
bool? enableInteractiveSelection,
TextSelectionControls? selectionControls,
void Function()? onTap,
MouseCursor? mouseCursor,
Widget? Function(BuildContext, {required int currentLength, required bool isFocused, required int? maxLength})? buildCounter,
ScrollController? scrollController,
ScrollPhysics? scrollPhysics,
Iterable ? autofillHints = const [],
Clip clipBehavior = Clip.hardEdge,
String? restorationId,
bool scribbleEnabled = true,
bool enableIMEPersonalizedLearning = true,
})
예시) 기본 TextField()
import 'package:flutter/material.dart';
void main() =>
runApp(MaterialApp(home: Scaffold(body: SafeArea(child: _HomeScreen()))));
class _HomeScreen extends StatelessWidget {
const _HomeScreen({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const Center(
child: TextField(),
);
}
}
😶 onChanged, onSubmitted 이벤트
onChanged 는 사용자가 키보드를 입력할 때마다 호출되고 onSubmitted 는 엔터키를 눌렀을 때 호출된다.
TextField(
onChanged: (value){
print("onChanged $value");
},
onSubmitted: (value){
print("onSubmitted : $value");
},
)
나어지 TextField 와 관련된 설정은 다음 글에서 확인해볼 수 있다.
728x90
'Flutter > widget_TextField' 카테고리의 다른 글
[Flutter/TextField] 입력 폼 border (0) | 2023.03.31 |
---|---|
[Flutter] Form + TextFormField - 한번에 입력 값 관리하기, errorText, border (0) | 2023.03.03 |
[Flutter/TextField] 키보드 액션 버튼 값 바꾸기 (textInputAction) (0) | 2023.02.25 |
[Flutter/TextField] decoration, text, hint (0) | 2023.02.24 |
[Flutter/TextField] keyboardType, 입력값 필터(inputFormatters) (0) | 2023.02.24 |