good_search_appbar 0.0.5 copy "good_search_appbar: ^0.0.5" to clipboard
good_search_appbar: ^0.0.5 copied to clipboard

A Flutter AppBar widget that smoothly animates between a title and a search text field. Supports multiple animation styles (slide, fade+scale), optional filter button, debounced search, and full themi [...]

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:good_search_appbar/good_search_appbar.dart';

void main() {
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'GoodSearchAppBar Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'GoodSearchAppBar Demo'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            const Text(
              'Pilih style animasi untuk dicoba:',
              style: TextStyle(fontSize: 16),
            ),
            const SizedBox(height: 24),
            // --- Style 1: Slide (default) ---
            ElevatedButton.icon(
              icon: const Icon(Icons.swap_horiz),
              label: const Text('Style 1 — Slide (default)'),
              onPressed: () {
                Navigator.of(context).push(MaterialPageRoute(
                  builder: (context) => const SearchPage(
                    styleLabel: 'Slide Animation',
                    animationStyle: SearchAnimationStyle.slide,
                  ),
                ));
              },
            ),
            const SizedBox(height: 16),
            // --- Style 2: Fade + Scale ---
            ElevatedButton.icon(
              icon: const Icon(Icons.auto_awesome),
              label: const Text('Style 2 — Fade + Scale'),
              style: ElevatedButton.styleFrom(
                backgroundColor: Colors.deepPurple,
                foregroundColor: Colors.white,
              ),
              onPressed: () {
                Navigator.of(context).push(MaterialPageRoute(
                  builder: (context) => const SearchPage(
                    styleLabel: 'Fade + Scale Animation',
                    animationStyle: SearchAnimationStyle.fadeScale,
                  ),
                ));
              },
            ),
          ],
        ),
      ),
    );
  }
}

class SearchPage extends StatelessWidget {
  const SearchPage({
    Key? key,
    required this.styleLabel,
    required this.animationStyle,
  }) : super(key: key);

  final String styleLabel;
  final SearchAnimationStyle animationStyle;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: GoodSearchAppBar(
        title: styleLabel,
        filter: true,
        leading: true,
        labelStyle: const TextStyle(),
        onSearchChanged: (query) {},
        animationStyle: animationStyle,
      ),
      body: Center(
        child: Padding(
          padding: const EdgeInsets.all(24.0),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Icon(
                animationStyle == SearchAnimationStyle.fadeScale
                    ? Icons.auto_awesome
                    : Icons.swap_horiz,
                size: 64,
                color: animationStyle == SearchAnimationStyle.fadeScale
                    ? Colors.deepPurple
                    : Colors.blue,
              ),
              const SizedBox(height: 16),
              Text(
                styleLabel,
                style:
                    const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
                textAlign: TextAlign.center,
              ),
              const SizedBox(height: 8),
              Text(
                animationStyle == SearchAnimationStyle.fadeScale
                    ? 'Tekan ikon search/close di AppBar\nuntuk melihat animasi Fade + Scale'
                    : 'Tekan ikon search/close di AppBar\nuntuk melihat animasi Slide',
                textAlign: TextAlign.center,
                style: TextStyle(color: Colors.grey[600]),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
1
likes
150
points
50
downloads

Documentation

Documentation
API reference

Publisher

verified publisherziandev.site

Weekly Downloads

A Flutter AppBar widget that smoothly animates between a title and a search text field. Supports multiple animation styles (slide, fade+scale), optional filter button, debounced search, and full theming customisation.

Repository (GitHub)
View/report issues

License

BSD-2-Clause (license)

Dependencies

flutter

More

Packages that depend on good_search_appbar