Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- TCPIP
- AlertDialog
- flutter button
- peaks
- Listview filtering
- ubuntu 19 한글 입력
- c
- debugShowCheckedModeBanner
- showDialog
- flutter tcpip client
- debug banner
- flutter
- Properties.Settings.Default
- array
- Server
- flutter tcpip server
- dart:io
- ListView.build
Archives
- Today
- Total
Louie De Janeiru
ListView.builder 본문
ListView.builder
itemCount : item의 항목 개수를 입력
itembuilder : item에 따른 action을 위한 function 구현
SizedBox(
height: 200.0,
child: ListView.builder(
// shrinkWrap: true,
itemCount: 10,
itemBuilder: (BuildContext context, int idx) {
if (_filterController.text.isEmpty) {
_filteredInt = 0;
} else {
_filteredInt = int.parse(_filterController.text);
}
if (idx == _filteredInt) {
return Container();
} else {
return Text("\t\t\t$idx listed");
}
},
),
),
번호를 입력받아 filtering 하여 출력하도록 구성함
TextField(
controller: _filterController,
decoration: const InputDecoration(
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(10)),
),
labelText: "Filter number",
),
onChanged: (_) {
setState(() {
if (_filterController.text.isEmpty) {
_filteredInt = 0;
} else {
_filteredInt = int.parse(_filterController.text);
}
});
},
),
아래는 전체 code block
import 'package:flutter/material.dart';
List<String> nameList = ["Seoul", "Paris", "NewYork"];
final _filterController = TextEditingController();
int _filteredInt = 0;
class ListViewBuilderScreen extends StatefulWidget {
const ListViewBuilderScreen({super.key});
@override
State<ListViewBuilderScreen> createState() => _ListViewBuilderScreenState();
}
class _ListViewBuilderScreenState extends State<ListViewBuilderScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("ListView builder Demo"),
),
body: Column(
children: [
const SizedBox(height: 10),
TextField(
controller: _filterController,
decoration: const InputDecoration(
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(10)),
),
labelText: "Filter number",
),
onChanged: (_) {
setState(() {
if (_filterController.text.isEmpty) {
_filteredInt = 0;
} else {
_filteredInt = int.parse(_filterController.text);
}
});
},
),
const SizedBox(height: 10),
SizedBox(
height: 200.0,
child: ListView.builder(
// shrinkWrap: true,
itemCount: 10,
itemBuilder: (BuildContext context, int idx) {
if (_filterController.text.isEmpty) {
_filteredInt = 0;
} else {
_filteredInt = int.parse(_filterController.text);
}
if (idx == _filteredInt) {
return Container();
} else {
return Text("\t\t\t$idx listed");
}
},
),
),
],
),
);
}
}
https://github.com/louiey-dev/flutter_my_utils/blob/main/lib/screen/listview_builder.dart
'Flutter' 카테고리의 다른 글
TcpIp Socket Server (0) | 2024.04.17 |
---|---|
TcpIp Socket Client (0) | 2024.04.17 |
Button 만들기 (0) | 2024.04.15 |
Debug banner remove in Flutter (0) | 2024.04.15 |
basic analysis_options.yaml setting (0) | 2022.05.25 |