libadwaita_searchbar_ac 0.5.8 copy "libadwaita_searchbar_ac: ^0.5.8" to clipboard
libadwaita_searchbar_ac: ^0.5.8 copied to clipboard

A libadwaita package to get a search bar with autocomplete, based on easy_autocomplete

example/lib/main.dart

import 'package:adwaita/adwaita.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:libadwaita/libadwaita.dart';
import 'package:libadwaita_searchbar_ac/libadwaita_searchbar_ac.dart';

void main() => runApp(const MyApp());

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: AdwaitaThemeData.light(),
      darkTheme: AdwaitaThemeData.dark(),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends HookWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final _searchController = TextEditingController();
    final toggleSearch = useState<bool>(false);
    final searchedTerm = useState<String>('');

    void toggleSearchBar({bool? value}) {
      searchedTerm.value = '';
      toggleSearch.value = value ?? !toggleSearch.value;
    }

    return AdwScaffold(
      headerbar: (_) => AdwHeaderBar(
        start: [
          AdwHeaderButton(
            isActive: toggleSearch.value,
            onPressed: toggleSearchBar,
            icon: const Icon(Icons.search, size: 20),
          ),
        ],
        title: toggleSearch.value
            ? AdwSearchBarAc(
                toggleSearchBar: toggleSearchBar,
                suggestions: const ['Hi', 'Hello'],
                onSubmitted: (str) => searchedTerm.value = str,
                controller: _searchController,
              )
            : const Text('Autocomplete demo'),
      ),
      body: Center(
        child: Text(
          searchedTerm.value.isNotEmpty
              ? searchedTerm.value
              : 'Libadwaita + Easy autocomplete search bar demo',
        ),
      ),
    );
  }
}
2
likes
150
pub points
65%
popularity

Publisher

unverified uploader

A libadwaita package to get a search bar with autocomplete, based on easy_autocomplete

Repository (GitHub)
View/report issues

Documentation

API reference

License

MPL-2.0 (license)

Dependencies

easy_autocomplete, flutter, libadwaita_searchbar

More

Packages that depend on libadwaita_searchbar_ac