search_app_bar는 다양한 데이터 목록에서 검색 기능을 구현하는 것을 단순화하는 애니메이션 검색 바 위젯을 제공하는 Flutter 패키지입니다. 부드러운 전환과 직관적인 사용자 상호작용을 가능하게 하여 결과를 동적으로 필터링하고 표시하는 것을 쉽게 만듭니다. 이 라이브러리는 검색 작업 중 시각적 피드백을 통해 UX를 향상시키는 데 중점을 두고 있습니다. 복잡한 설정 없이 앱에 검색 기능을 통합하고 싶은 개발자를 위한 가볍고 사용자 정의 가능한 솔루션을 제공합니다.
사용 사례
실시간으로 동적 목록 필터링
애니메이션 검색 UI로 사용자 경험 향상
양식 또는 대시보드에서 검색 구현
리스트 뷰에 검색 통합하기
반응형 검색 인터페이스 만들기
모바일 앱에서 텍스트 기반 필터링 지원
주요 기능
애니메이션 검색 바 전환
모든 목록 데이터와의 간편한 통합
사용자 정의 가능한 외관 및 동작
실시간 검색 결과 업데이트
경량이며 최소한의 종속성
텍스트 입력과 명확한 작업을 모두 지원합니다
적합한 대상
검색 중심 앱을 개발하는 개발자
UI 중심의 Flutter 프로젝트
부드러운 검색 애니메이션을 필요로 하는 앱
대규모 데이터셋을 갖춘 모바일 애플리케이션
사용자 경험을 우선시하는 프론트엔드 팀
검색 기능의 빠른 프로토타이핑
고려 사항
기본 텍스트 검색에 제한됨(고급 필터 없음)
원격 API에 대한 내장 지원 없음
데이터 소스 로직을 수동으로 처리해야 합니다
매우 큰 데이터 세트에 최적화되지 않음
기본적으로 로컬라이제이션 지원 없음
정렬 또는 그룹화에 대한 사용자 정의 구현에 따라 다릅니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
search_app_bar
An animated SearchAppBar Widget, to be used with Flutter.
Usage
Simply use the SearchAppBar widget as a regular AppBar.
The only required attribute in the widget is called searcher.
You must implement the Searcher<T> interface in a class of yours (a Bloc, for example), to
control a list of data (of type T) and react to the list filtering provided by SearchAppBar.
Here's a simple example of SearchAppBar's usage with bloc:
When you implement the Searcher interface in your class, you must provide an implementation for both overrides:
class BlocExample implements Searcher<String> {
...
@override
List<String> get data => ...
@override
get onDataFiltered => ...
}
data should simply return your full data list (in this case, a list of Strings), in which you will search for elements.
onDataFiltered expects a function that receives a List<T>. This is the filtered data list, based on what was typed on the SearchAppBar. Use that list as you will.
For example, if you are using Bloc, add this filtered list to your data's StreamController.
Complete Example
Here's a complete example of a view using SearchAppBar:
Below is an example of a HomeBloc class that implements Searcher:
(This example also uses the bloc_pattern library to implement a bloc class)
import 'package:bloc_pattern/bloc_pattern.dart';
import 'package:rxdart/subjects.dart';
import 'package:search_app_bar/searcher.dart';
class HomeBloc extends BlocBase implements Searcher<String> {
final _filteredData = BehaviorSubject<List<String>>();
final dataList = [
'Thaís Fernandes',
'Vinicius Santos',
'Gabrielly Costa',
'Olívia Sousa',
'Diogo Lima',
'Lucas Assunção',
'Conceição Cardoso'
];
Stream<List<String>> get filteredData => _filteredData.stream;
HomeBloc() {
_filteredData.add(dataList);
}
@override
get onDataFiltered => _filteredData.add;
@override
get data => dataList;
@override
void dispose() {
_filteredData.close();
super.dispose();
}
}
Filters
Note how, in our example, we used a data list of type List<String>.
In this specific case, we can omit the filter parameter if we want. It will be implied that we will search for strings in our data list that start with whatever we type on the SearchAppBar.
However, let's say that we need to search for a person's name inside a list of Person:
class Person {
final String name;
final String occupation;
final int age;
...
}
In this case, we will need to implement a Searcher<Person> and provide a way for SearchAppBar to filter Person data as we want.
Here we are instructing our SearchAppBar to filter only the Person objects whose names start with the typed query on the search bar.
The Filters class is provided with this library and contain the following pre-made String filters: startsWith, equalsand contains.
These filters compare strings unregarding upper/lower case and diacritics.
You can also create your own Filter if you need.
Parameters
Here's a list of all SearchAppBar parameters and what they do:
searcher: You must provide an object that implements Searcher<T> here.
filter: You can provide a customized filter here if needed.
title: The title widget on the app bar.
centerTitle: If true, this centralizes the title widget.
iconTheme: Used to define the colors of IconButtons on the app bar.
backgroundColor: AppBar's Background color.
searchBackgroundColor: The color used as the AppBar's background when the search is active.
searchElementsColor: Mainly used for icons, such as the back arrow button, when the search is active.
hintText: The text shown as a hint when the search is active.
flattenOnSearch: If true, removes the AppBar's elevation when the search is active.
capitalization: The capitalization rule for the search text on the AppBar.
actions: You can provide other IconButton within this array. They will appear besides the search button.
searchButtonPosition: The index that the search button should occupy in the actions array. It defaults to the last position.
Disclaimer
This small library was developed (and later, improved)
based on the excellent tutorial provided by Nishant Desai at:
https://blog.usejournal.com/change-app-bar-in-flutter-with-animation-cfffb3413e8a