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

패키지 상세v2.0.2

flappy_search_bar_ns

비동기 검색의 대부분을 자동화하는 SearchBar 위젯입니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
896
좋아요
29
Pub 점수
120

패키지 설치

flutter pub add flappy_search_bar_ns

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

FlappySearchBarNS는 비동기 검색 구현을 간소화하기 위해 설계된 Flutter 위젯입니다. 사용자 입력 처리, 로딩 상태 관리, 비동기 데이터 소스에서의 결과 표시와 같은 일반적인 검색 워크플로우를 자동화합니다. 다양한 플랫폼에서 원활한 검색 기능을 구현하고자 하는 개발자를 위한 것으로, 기존 검색 API와 원활하게 통합되며 실시간 필터링을 지원합니다. 반복되는 검색 로직 패턴을 추상화함으로써 봐야 할 코드를 줄여주어 동적이고 반응성 있는 검색 경험을 필요로 하는 앱에 이상적입니다.

사용 사례

  • 비동기 데이터를 사용한 실시간 검색
  • 대규모 데이터셋 필터링
  • 모바일 및 웹 앱에서의 검색 UI
  • 동적 콘텐츠 탐색
  • 자동 완성 기능 구현
  • 크로스 플랫폼 검색 컴포넌트

주요 기능

  • 자동 비동기 검색 처리
  • 내장된 로딩 및 오류 상태
  • 실시간 입력 처리 지원
  • 크로스 플랫폼 호환성
  • 필요한 최소한의 보일러플레이트
  • 사용자 지정 결과 표시

적합한 대상

  • 검색 중심 앱을 개발하는 개발자
  • 빠른 UI 개발을 우선시하는 팀
  • 여러 플랫폼을 대상으로 하는 프로젝트
  • 반응형 검색 UX가 필요한 앱
  • Flutter 초보자가 검색 패턴을 배우고 있습니다

고려 사항

  • 비동기 작업에 대한 이해가 필요합니다
  • 복잡한 UI에는 맞춤형 스타일링이 필요할 수 있습니다
  • 기본 텍스트 매칭을 넘어서는 내장 필터가 제한적임
  • 외부 API 통합에 의존
  • 매우 높은 빈도의 검색 쿼리에 최적화되지 않음

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

flappy_search_bar_ns

A SearchBar widget handling most of search cases.

Usage

To use this plugin, add flappy_search_bar_ns as a dependency in your pubspec.yaml file.

Example
@override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: SearchBar<Post>(
          searchBarPadding: EdgeInsets.symmetric(horizontal: 10),
          headerPadding: EdgeInsets.symmetric(horizontal: 10),
          listPadding: EdgeInsets.symmetric(horizontal: 10),
          onSearch: _getALlPosts,
          searchBarController: _searchBarController,
          placeHolder: Text("placeholder"),
          cancellationWidget: Text("Cancel"),
          emptyWidget: Text("empty"),
          indexedScaledTileBuilder: (int index) => ScaledTile.count(1, index.isEven ? 2 : 1),
          header: Row(
            children: <Widget>[
              RaisedButton(
                child: Text("sort"),
                onPressed: () {
                  _searchBarController.sortList((Post a, Post b) {
                    return a.body.compareTo(b.body);
                  });
                },
              ),
              RaisedButton(
                child: Text("Desort"),
                onPressed: () {
                  _searchBarController.removeSort();
                },
              ),
              RaisedButton(
                child: Text("Replay"),
                onPressed: () {
                  isReplay = !isReplay;
                  _searchBarController.replayLastSearch();
                },
              ),
            ],
          ),
          onCancelled: () {
            print("Cancelled triggered");
          },
          mainAxisSpacing: 10,
          crossAxisSpacing: 10,
          crossAxisCount: 2,
          onItemFound: (Post post, int index) {
            return Container(
              color: Colors.lightBlue,
              child: ListTile(
                title: Text(post.title),
                isThreeLine: true,
                subtitle: Text(post.body),
                onTap: () {
                  Navigator.of(context).push(MaterialPageRoute(builder: (context) => Detail()));
                },
              ),
            );
          },
        ),
      ),
    );
  }
Try it

A sample app is available to let you try all the features ! :)

Warning

If you want to use a SearchBarController in order to do some sorts or filters, PLEASE put your instance of SearchBarController in a StateFullWidget.

If not, it will not work properly.

If you don't use an instance of SearchBarController, you can keep everything in a StateLessWidget !

Parameters
Name Type Usage Required Default Value
onSearch Future<List> Function(String text) Callback giving you the text to look for and asking for a Future yes -
onItemFound Widget Function(T item, int index) Callback letting you build the widget corresponding to each item yes -
suggestions List Potential fist list of suggestions (when no request have been made) no []
searchBarController SearchBarController Enable you to sort and filter your list no default controller
searchBarStyle SearchBarStyle Syle to customize SearchBar no default values on bottom tab
buildSuggestions Widget Function(T item, int index) Callback called to let you build Suggestion item (if not provided, the suggestion will have the same layout as the basic item) no null
minimumChars int Minimum number of chars to start querying no 3
onError Function(Error error) Callback called when an error occur runnning Future no null
debounceDuration Duration Debounce's duration no Duration(milliseconds: 500)
loader Widget Widget that appears when Future is running no CircularProgressIndicator()
emptyWidget Widget Widget that appears when Future is returning an empty list no SizedBox.shrink()
icon Widget Widget that appears on left of the SearchBar no Icon(Icons.search)
hintText String Hint Text no ""
hintStyle TextStyle Hint Text style no TextStyle(color: Color.fromRGBO(142, 142, 147, 1))
iconActiveColor Color Color of icon when active no Colors.black
textStyle TextStyle TextStyle of searched text no TextStyle(color: Colors.black)
cancellationWidget Widget Widget shown on right of the SearchBar no Text("Cancel")
onCancelled VoidCallback Callback triggered on cancellation's button click no null
crossAxisCount int Number of tiles on cross axis (Grid) no 2
shrinkWrap bool Wether list should be shrinked or not (take minimum space) no true
scrollDirection Axis Set the scroll direction no Axis.vertical
mainAxisSpacing int Set the spacing between each tiles on main axis no 10
crossAxisSpacing int Set the spacing between each tiles on cross axis no 10
indexedScaledTileBuilder IndexedScaledTileBuilder Builder letting you decide how much space each tile should take no (int index) => ScaledTile.count(1, index.isEven ? 2 : 1)
searchBarPadding EdgeInsetsGeometry Set a padding on the search bar no EdgeInsets.symmetric(horizontal: 10)
headerPadding EdgeInsetsGeometry Set a padding on the header no EdgeInsets.symmetric(horizontal: 10)
listPadding EdgeInsetsGeometry Set a padding on the list no EdgeInsets.symmetric(horizontal: 10)
SearchBar default SearchBarStyle
Name Type default Value
backgroundColor Color Color.fromRGBO(142, 142, 147, .15)
padding EdgeInsetsGeometry EdgeInsets.all(5.0)
borderRadius BorderRadius BorderRadius.all(Radius.circular(5.0))})

카테고리

의존성

의존성 목록 2 개

소스 저장소

이 패키지를 사용하는 프로젝트