패키지, 저장소 및 앱 카테고리 검색

GitHub 저장소alexrindone/flutter_textfield_search

flutter_textfield_search

FTFS는 리스트에서 값을 검색하고 선택하는 데 TextField 위젯을 사용하는 Flutter 패키지입니다. 다른 '자동 완성' 또는 텍스트 필드 검색 패키지와 달리 간단하고 가볍고 완전히 테스트된 패키지이며, 100% 코드 커버리지를 갖추고 있습니다.

flutter_textfield_search 프로젝트 이미지
스타
28
포크
36
최근 푸시(UTC)
2026. 9. 9.
프로젝트 상태
활성

원본 README

아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.

flutter_textfield_search

Build and Test

FTFS is a Flutter package which uses a TextField Widget to search and select a value from a list. It's a simple, lightweight, and fully tested package unlike other "autocomplete" or textfield search packages. View complete code coverage results in JSON format here.

Usage

To use this package, add flutter_textfield_search as a dependency in your pubsec.yaml file.

Example

Import the package.

`import 'package:flutter_textfield_search/textfield_search.dart'`;

Then include the widget anywhere you would normally use a TextField widget with a String for label, a List for initialList, and a TextEditingController for controller.
Example MaterialApp using TextFieldSearch Widget

    const label = "Some Label";
    const dummyList = ['Item 1', 'Item 2', 'Item 3', 'Item 4', 'Item 5'];
    TextEditingController myController = TextEditingController();
    MaterialApp(
      home: Scaffold(
      body: TextFieldSearch(initialList: dummyList, label: label, controller: myController)
      ),
    )

To get the value of the selected option, use addListener on the controller to listen for changes:

    @override
    void dispose() {
      // Clean up the controller when the widget is removed from the
      // widget tree.
      myController.dispose();
      super.dispose();
    }

    @override
    void initState() {
      super.initState();
      // Start listening to changes.
      myController.addListener(_printLatestValue);
    }
    
    _printLatestValue() {
      print("Textfield value: ${myController.text}");
    }

Selecting a List item from a Future List:

    TextEditingController myController = TextEditingController();

    // create a Future that returns List
    Future<List> fetchData() async {
      await Future.delayed(Duration(milliseconds: 5000));
      List list = [];
      String _inputText = myController.text;
      // create a list from the text input of three items
      // to mock a list of items from an http call
      list.add(_inputText + ' Item 1');
      list.add(_inputText + ' Item 2');
      list.add(_inputText + ' Item 3');
      return list;
    }

    @override
    void dispose() {
      // Clean up the controller when the widget is removed from the
      // widget tree.
      myController.dispose();
      super.dispose();
    }

    // used within a MaterialApp (code shortened)
    MaterialApp(
      home: Scaffold(
      body: TextFieldSearch(
          label: 'My Label', 
          controller: myController
          future: () {
            return fetchData();
          }
        )
      ),
    )

Selecting an object from a Future List:

    TextEditingController myController = TextEditingController();

    // create a Future that returns List
    // IMPORTANT: The list that gets returned from fetchData must have objects that have a label property.
    // The label property is what is used to populate the TextField while getSelectedValue returns the actual object selected
    Future<List> fetchData() async {
      await Future.delayed(Duration(milliseconds: 3000));
      List list = [];
      String _inputText = myController.text;
      List jsonList = [
        {
          'label': _inputText + ' Item 1',
          'value': 30
        },
        {
          'label': _inputText + ' Item 2',
          'value': 31
        },
        {
          'label': _inputText + ' Item 3',
          'value': 32
        },
      ];
      // create a list of 3 objects from a fake json response
      list.add(TestItem.fromJson(jsonList[0]));
      list.add(TestItem.fromJson(jsonList[1]));
      list.add(TestItem.fromJson(jsonList[2]));
      return list;
    }

    @override
    void dispose() {
      // Clean up the controller when the widget is removed from the
      // widget tree.
      myController.dispose();
      super.dispose();
    }

    // used within a MaterialApp (code shortened)
    MaterialApp(
      home: Scaffold(
      body: TextFieldSearch(
          label: 'My Label', 
          controller: myController
          future: () {
            return fetchData();
          },
          getSelectedValue: (value) {
            print(value); // this prints the selected option which could be an object
          }
        )
      ),
    )

    // Mock Test Item Class
    class TestItem {
      final String label;
      dynamic value;
      TestItem({ required this.label, this.value });

      factory TestItem.fromJson(Map<String, dynamic> json) {
        return TestItem(
          label: json['label'],
          value: json['value']
        );
      }
    }

Issues

Please email any issues, bugs, or additional features you would like to see built to arindone@nubeer.io.

Contributing

If you wish to contribute to this package you may fork the repository and make a pull request to this repository.

Note: Testing by running flutter test --coverage will generate coverage/lcov.info. Running bash test-coverage.sh will parse the lcov.info file into JSON format. This happens automatically within the CI/CD pipeline on a pull request to main but it is always good to test locally.

Alex Rindone GitHub avatar
GitHub 작성자

Alex Rindone ↗

Artistry FairBoston, MA
언어DartC++CMakeSwiftShellCHTMLKotlinObjective-C

이 저장소가 배포한 패키지

사용 중인 의존성

의존성 목록 4 개

프로젝트에 맞는 저장소를 선택하려면?

사용 목적에 따라 검색하고 개발 활동을 비교한 뒤 원본 저장소에서 요구 사항을 확인하세요.

  1. 이름, 작성자 또는 설명으로 검색하고 기술 주제로 범위를 좁힙니다.
  2. 스타, 포크, 최근 푸시를 함께 비교하세요. 스타는 관심의 지표이며 품질을 보장하지 않습니다.
  3. 사용하기 전에 GitHub에서 README, 라이선스, Issues를 확인하세요.

출처 및 관리

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗