search_bar 1.0.0 copy "search_bar: ^1.0.0" to clipboard
search_bar: ^1.0.0 copied to clipboard

outdatedDart 1 only

A (mostly) automatic search bar inside an AppBar for flutter

example/search_bar_example.dart

// Copyright (c) 2017, Spencer. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.

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

void main() {
  runApp(new SearchBarDemoApp());
}

class SearchBarDemoApp extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
        title: 'Search Bar Demo',
        theme: new ThemeData(
            primarySwatch: Colors.blue
        ),
        home: new SearchBarDemoHome()
    );
  }
}

class SearchBarDemoHome extends StatefulWidget {
  @override
  _SearchBarDemoHomeState createState()=> new _SearchBarDemoHomeState();
}

class _SearchBarDemoHomeState extends State<SearchBarDemoHome> {
  SearchBar searchBar;

  AppBar buildAppBar(BuildContext context) {
    return new AppBar(
        title: new Text('Search Bar Demo')
    );
  }

  void onSubmitted(String value) {
    Scaffold.of(context).showSnackBar(
      new SnackBar(
          content: new Text('You wrote $value!')
      )
    );
  }

  _SearchBarDemoHomeState() {
    searchBar = new SearchBar(
      inBar: false,
      buildDefaultAppBar: buildAppBar,
      setState: setState,
      onSubmitted: onSubmitted
    );
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: searchBar.build(context),
      body: new Center(
        child: new Text("Don't look at me! Press the search button!")
      ),
    );
  }
}
0
likes
40
pub points
42%
popularity

Publisher

unverified uploader

A (mostly) automatic search bar inside an AppBar for flutter

Homepage

License

BSD-3-Clause (LICENSE)

Dependencies

flutter, meta

More

Packages that depend on search_bar