search_bar_ns 0.0.2 copy "search_bar_ns: ^0.0.2" to clipboard
search_bar_ns: ^0.0.2 copied to clipboard

A new Flutter project.

Features #

A simple and mostly automatic material search bar for flutter (dart).

Usage #

A simple usage example:

// 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_ns/search_bar_ns.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!")
      ),
    );
  }
}

This will create an AppBar with a search button as its only action, and on press the AppBar will turn white and have a TextField inside, allowing user input. Once the user has input something and pressed the "enter" button on their keyboard, it will close and the value will be printed to the debugger.

1
likes
60
pub points
0%
popularity

Publisher

unverified uploader

A new Flutter project.

Repository (GitHub)
View/report issues

Documentation

API reference

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on search_bar_ns