search_bar_bloc 1.0.1 copy "search_bar_bloc: ^1.0.1" to clipboard
search_bar_bloc: ^1.0.1 copied to clipboard

A Flutter package for creating a SearchBar that uses bloc package to handle the state.

example/README.md

Bloc Provider Example #

Here is a quick example of how to implement the search bar with a BlocProvider.

  @override
  Widget build(BuildContext context) {
    return BlocProvider(
      create: (_) => SearchBarCubit(),
      child: Column(
        children: [
          const SearchBar(hintText: "Search something..."),
          BlocBuilder<SearchBarCubit, SearchBarState>(
              buildWhen: (previous, current) => previous.content != current.content,
              builder: (context, state) {
                return Text("You are searching : ${state.content}");
              }),
        ],
      ),
    );
  }

Bloc Provider Example #

Here is a quick example of how to implement the search bar with a BlocListener.

class BlockBuilderExampleWidget extends StatelessWidget {
  const BlockBuilderExampleWidget({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return BlocListener<SearchBarCubit, SearchBarState>(
      listenWhen: (previous, current) => previous.content != current.content,
      listener: (context, state) {
        print("You are searching : ${state.content}");
      },
      child: Container(),
    );
  }

}
0
likes
130
pub points
0%
popularity

Publisher

unverified uploader

A Flutter package for creating a SearchBar that uses bloc package to handle the state.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

bloc, equatable, flutter, flutter_bloc

More

Packages that depend on search_bar_bloc