홈>
키보드가
TextField
에서 제대로 작동하지 않습니다
.
아래 코드는 14 개의
TextField
를 넣었습니다.
, 그러나 예를 들어 필드 14에서 클릭하면 키보드가 나타나지 않고
TextField
아래에 있지 않습니다
탭했습니다.
이 키보드 문제가 표시되지 않고 선택한 필드에 표시되지 않도록 도와 주실 수 있습니까?
import 'package:flutter/material.dart';
void main() {
runApp(new MaterialApp(home: new HomePage()));
}
class HomePage extends StatefulWidget {
@override
HomePageState createState() => new HomePageState();
}
class HomePageState extends State<HomePage> {
final TextEditingController _controller = new TextEditingController();
@override
Widget build(BuildContext context) {
return new Scaffold(
body: new Stack(
children: <Widget>[
new ListView(
shrinkWrap: true,
children: <Widget>[
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 1',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 2',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 3',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 4',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 5',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 6',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 7',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 8',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 9',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 10',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 11',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 12',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 13',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 14',
),
),
],
)
]
)
);
}
}
-
답변 # 1
-
답변 # 2
같은 문제가 있었지만 제 경우에는 Key 객체에있었습니다
await showDialog( context: context, barrierDismissible: false, builder: (context) { final _textKey = GlobalKey<FormState>(); TextEditingController controller = TextEditingController(); return AlertDialog( title: Text('Load conference'), content: Form( key: _textKey, child: TextFormField( controller: controller, validator: (str) { if (str.isEmpty) { return 'Empty url'; } else if (str.length >= 4 && str.substring(0, 4).toLowerCase() != 'http') { return 'Url has to start from \'http\''; } }, ), onChanged: () { if (controller.text.isNotEmpty) { _textKey.currentState.validate(); } }, ),
키 정적 클래스 필드를 만들어서 문제를 해결했습니다
static final _textKey = GlobalKey<FormState>();
-
답변 # 3
compileSdkVersion및targetSdkVersion을로 업데이트하는 Android앱 수준 gradle파일을 수정 한 후이 문제가 발생했습니다. 기본값에서 28(27) 기본 버전으로 유지하십시오. Google Play 스토어에서 Android 9 에뮬레이터에서 테스트하고있었습니다.
-
답변 # 4
오류를 재현 할 수 없었습니다. 모든 것이 제대로 작동하는 것 같습니다.Flutter SDK가 업데이트되었는지 확인 (
flutter doctor
실행) ). 오류가 지속되는지 확인하기 위해 대상 플랫폼을 IOS로 변경하려고 했습니까?
관련 자료
- networking - Wi-Fi와 LAN에 동시에 연결하면 PC가 두 개의 IP 주소 아래에 나타나는 것이 정상입니까?
- Android 사용자 정의 대화 상자에 키보드가 나타나지 않습니다
- android - 실룩 거리다 - textformfield를 선택할 때 키보드가 표시되지 않음
- android - 키보드가 플러터로 열리면 UI 오버플로
- dart - Flutter 앱의 ListView 스크롤에서 키보드 숨기기/해제
- controller - Flutter 키보드 완료 버튼으로 인해 텍스트 필드 내용이 파기 됨
- forms - 실룩 거리다 - 키보드가 나타날 때 텍스트가 어떻게 쌓이지 않습니까?
- dart - HTML 콘텐츠 내부의 비디오가 플러터에 나타나지 않습니다
- floating action button - 닫는 태그 아래 빨간색 선
- dart - 키보드를 열 때 Flutter의 오버플로 오류
- 키보드 팝업시 Flutter Google Maps 크기 조정
- dart - Flutter Text Color 테마가 ListTile 제목에서 작동하지 않습니다
- ios - 키보드 모양에서 Flutter 레이아웃에 애니메이션을 적용하는 방법
관련 질문
- flutter - GetX 상태 관리
- dart - Flutter를 사용한 열의 TextOverflow
- algorithm - 다트에서 월별로 변경하는 방법은 무엇입니까?
- dart - 플러터 텍스트 필드 값을 datepicker로 가져 오는 방법
- dart - 메모리 이미지 (예 - uint8list)를 flutter의 이미지 파일로 저장
- dart - Flutter 플러그인을 사용하여 버튼의 셰이더가 잘립니다
- asynchronous - 플러터, 저장소에서 사진 업데이트 시도
- dart - Flutter Search 대문자로 첫 번째 문자를 사용하여 필터 데이터 위임
- dart - flutter - 하나의 텍스트 필드에서 hinttext의 색상을 변경할 수있는 방법이 있습니까?
- flutter - 문자열 날짜를 날짜 시간으로 변환하는 방법?
모든 텍스트 필드가 동일한
TextEditingController
를 공유하지 않아야합니다 . 각각에 대해 별도의 컨트롤러를 사용하십시오.