Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search input widget #6691

Closed
vy0592 opened this issue Nov 3, 2016 · 26 comments · Fixed by #6733
Closed

Search input widget #6691

vy0592 opened this issue Nov 3, 2016 · 26 comments · Fixed by #6733
Assignees
Labels
f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Comments

@vy0592
Copy link

vy0592 commented Nov 3, 2016

Is there a search box widget that follows the search pattern in material design?

@eseidelGoogle eseidelGoogle added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Nov 3, 2016
@eseidelGoogle
Copy link
Contributor

Presumably you mean https://material.google.com/patterns/search.html? Or is there a better reference? @HansMuller would know.

@eseidelGoogle
Copy link
Contributor

I also know that https://github.com/flutter/flutter/tree/master/examples/stocks has search functionality. I don't recall if it conforms to that pattern or not however.

@vy0592
Copy link
Author

vy0592 commented Nov 3, 2016

Yes, I mean https://material.google.com/patterns/search.html.

I saw in the example they are using input widget and search icon to achieve this functionality. I also tried using input widget, but there's a problems:

I did not find a way to hide the line in input widget.
Is there anyway to hide the line from the input field so it would look better in the cases like putting it inside a bordered container, above a divider etc.

@mehmetf
Copy link
Contributor

mehmetf commented Nov 3, 2016

An widget that has the capability to hide its line would be sufficient.

We actually have scenarios where a magnifying glass icon is not desirable (such as when search is within the appbar). So a complete "search widget" might be an overkill.

@mehmetf mehmetf added this to the 1: Top Customer Requests milestone Nov 3, 2016
@mehmetf mehmetf changed the title search box widget Search input widget Nov 3, 2016
@HansMuller HansMuller self-assigned this Nov 3, 2016
@Hixie
Copy link
Contributor

Hixie commented Nov 3, 2016

If using RawInput instead of Input is a sufficient solution to this problem, then we should add documentation to Input that points people to RawInput if they don't want the material look of an Input control.

@HansMuller
Copy link
Contributor

Here's an example of using RawInput directly.

import 'package:flutter/material.dart';

class Home extends StatefulWidget {
  @override
  _HomeState createState() => new _HomeState();
}

class _HomeState extends State<Home> {
  GlobalKey<RawInputState> _rawInputKey = new GlobalKey<RawInputState>();
  InputValue _value = new InputValue(text: 'Hello World');

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('Home'),
      ),
      body: new Container(
        key: _rawInputKey,
        padding: const EdgeInsets.all(16.0),
        alignment: FractionalOffset.topLeft,

        // Some simple improvements are warranted:
        // - assert if style isn't specified
        // - cursorColor should default to the text style's color
        // - if key's value is a GlobalKey then use it as the default for focusKey

        child: new RawInput(
          focusKey: _rawInputKey,
          style: Theme.of(context).textTheme.display1,
          cursorColor: const Color(0xFF00FF00),
          value: _value,
          onChanged: (InputValue newValue) {
            setState(() {
              _value = newValue;
            });
          },
          onSubmitted: (InputValue newValue) {
            print("Submitted $newValue");
            Focus.clear(context);
          },
        ),
      ),
    );
  }
}

void main() {
  runApp(new MaterialApp(home: new Home()));
}

@vy0592
Copy link
Author

vy0592 commented Nov 4, 2016

I was able to achieve it using the rawinput but this also requires me to include file 'text_selection.dart' in order to set selection control to materialTextSelectionControls.

I also had to use stack to draw the hint text and a flex to make sure input does not overflow. Full code below:

new Container(
  padding: const EdgeInsets.all(16.0),
  child: new Row(children: [
    new Icon(Icons.search, color: Colors.grey[600], size: 32.0),
    new Padding(padding: const EdgeInsets.only(left: 16.0)),
    new Flexible(child: new Stack(children: [
      new Positioned(
        left: 0.0,
        top: 0.0,
        child: new Text(config.placeHolderText, style: hintStyle)),
      ),
      new RawInput(
        key: _rawInputKey,
        focusKey: _rawInputKey,
        selectionControls: materialTextSelectionControls,
        cursorColor: const Color(0xFF00FF00),
        value: _value,
        onChanged: (InputValue newValue) {
          setState(() {
            _value = newValue;
          });
        },
      ),
   ])),
 ])
)

It looks too complex for a search box. Could you please take a look?

@Hixie
Copy link
Contributor

Hixie commented Nov 4, 2016

The underlining of the word is part of IME. It's the word currently being typed that you can replace with autocomplete. That's not a bug.

@TitikshaDaga
Copy link

Is there a Search widget because i can't find anything about it except this link: https://material.io/guidelines/patterns/search.html#search-in-app-search ?

@mehmetf
Copy link
Contributor

mehmetf commented Aug 15, 2017

We have an internally developed auto-complete/search widget that will be pushed to external within a month's time frame. Stay tuned.

@mehmetf
Copy link
Contributor

mehmetf commented Aug 15, 2017

@DaveShuckerow FYI

@ericmand
Copy link

If this is available, I'd love a pointer. Otherwise, I'll wait patiently.

@eseidelGoogle
Copy link
Contributor

I'm not sure of the status. The bug looks like its closed. Is there more work to do here @HansMuller?

@xster
Copy link
Member

xster commented Nov 14, 2017

I think the original request isn't done yet as far as I can tell. We have a universal input field but I don't think we have an out of the box search bar with all the material UI treatment and auto-complete attachments.

@xster xster reopened this Nov 14, 2017
@xster xster modified the milestones: 1: Top Customer Requests, 4: Next milestone Nov 14, 2017
@xster
Copy link
Member

xster commented Nov 14, 2017

@mehmetf, was the internal version released publicly already?

@mehmetf
Copy link
Contributor

mehmetf commented Nov 14, 2017

Not yet. We are developing in the third_party branch however the mechanism to sync this to Github is not in place yet. I am assigning this to Dave who can provide more context.

@DaveShuckerow
Copy link
Contributor

Hi all,

Work is going on internal to Google on this widget; I've been resolving the approvals that we need to get to roll code written inside Google out into GitHub.

Stay tuned.

@dragonfax
Copy link

Just happen to be looking for this, and glad to see theres been an update recently.

@hundeva
Copy link

hundeva commented Jan 9, 2018

Any news? I could make use of something like this.

@ianldgs
Copy link

ianldgs commented Jan 18, 2018

Just created a plugin that might help: https://pub.dartlang.org/packages/material_search

@armehta
Copy link

armehta commented Jan 30, 2018

Any update on this ?

@BasedMusa
Copy link

Is the widget finally out?!

@MaskyS
Copy link

MaskyS commented Apr 28, 2018

@DaveShuckerow

@HansMuller HansMuller self-assigned this Apr 30, 2018
@HansMuller
Copy link
Contributor

My apologies for letting this issue grow stale for SO long. Support for a search bar, per the Material Design spec, is among the goals for Flutter development this summer: #17119

@goderbauer
Copy link
Member

Material's Expandable Search is now available in Flutter as of #17629.
For Material's Persistent Search follow #17119.

GaryQian added a commit that referenced this issue Oct 30, 2018
…#23596)

162b2e9..7be0217
7be0217 Roll back _countryCode assert - breaking change (#6693)
91a019c Fix popSystemNavigator (#6691)
2b2fbf0 Add Locale.fromSubtags and support for scriptCode. (#6518)
58c8e30 Roll src/third_party/skia ab18c8e6cc20..d48b7a881b24 (5 commits) (#6690)
3b17cfb Flutter tester default locales (#6689)
96bbd2b Roll buildroot to 11a934e99eaa4aa8e278cd2772aff4f51f1f3c41 (#6687)
0e9defb Roll src/third_party/skia 68825776f4b4..ab18c8e6cc20 (11 commits) (#6688)
cc686d7 Don't populate the external view embedder in PaintContext. (#6686)
ab782fa Roll src/third_party/skia 1de48d8040aa..68825776f4b4 (1 commits) (#6685)
c4aa8d3 Roll src/third_party/skia 797197a772b8..1de48d8040aa (2 commits) (#6684)
7352251 Roll src/third_party/skia 79c96811863f..797197a772b8 (1 commits) (#6683)
3dac47e Roll src/third_party/skia 38e4fd0c5654..79c96811863f (1 commits) (#6682)
2f06a53 Roll src/third_party/skia b53f1f46982d..38e4fd0c5654 (1 commits) (#6681)
a1d7cad Fix inconsistent include syntax (#6680)
236661c Roll src/third_party/skia 3b79aa3a5ad0..b53f1f46982d (13 commits) (#6679)
c4f5061 Roll buildroot to pick up Mac toolchain updates. (#6678)
ba8f6aa Handle Windows headers defining ERROR to 0 in log levels. (#6677)
505d2a9 Roll buildroot to pick up updates to custom toolchains. (#6674)
6c2a0b3 Undefine ERROR in platform_view_layer.cc (#6675)
55e1299 Update FlutterPlugin.h docs, suppress warning for older API (#6672)
f797004 Attach and position embedded UIVIews (#6614)
df85722 Plumb the iOS PlatformViewsController into flow. (#6603)
2bfb893 iOS Embedding Refactor (#6447)
Xavjer pushed a commit to Xavjer/flutter that referenced this issue Nov 1, 2018
…flutter#23596)

162b2e9..7be0217
7be0217 Roll back _countryCode assert - breaking change (flutter#6693)
91a019c Fix popSystemNavigator (flutter#6691)
2b2fbf0 Add Locale.fromSubtags and support for scriptCode. (flutter#6518)
58c8e30 Roll src/third_party/skia ab18c8e6cc20..d48b7a881b24 (5 commits) (flutter#6690)
3b17cfb Flutter tester default locales (flutter#6689)
96bbd2b Roll buildroot to 11a934e99eaa4aa8e278cd2772aff4f51f1f3c41 (flutter#6687)
0e9defb Roll src/third_party/skia 68825776f4b4..ab18c8e6cc20 (11 commits) (flutter#6688)
cc686d7 Don't populate the external view embedder in PaintContext. (flutter#6686)
ab782fa Roll src/third_party/skia 1de48d8040aa..68825776f4b4 (1 commits) (flutter#6685)
c4aa8d3 Roll src/third_party/skia 797197a772b8..1de48d8040aa (2 commits) (flutter#6684)
7352251 Roll src/third_party/skia 79c96811863f..797197a772b8 (1 commits) (flutter#6683)
3dac47e Roll src/third_party/skia 38e4fd0c5654..79c96811863f (1 commits) (flutter#6682)
2f06a53 Roll src/third_party/skia b53f1f46982d..38e4fd0c5654 (1 commits) (flutter#6681)
a1d7cad Fix inconsistent include syntax (flutter#6680)
236661c Roll src/third_party/skia 3b79aa3a5ad0..b53f1f46982d (13 commits) (flutter#6679)
c4f5061 Roll buildroot to pick up Mac toolchain updates. (flutter#6678)
ba8f6aa Handle Windows headers defining ERROR to 0 in log levels. (flutter#6677)
505d2a9 Roll buildroot to pick up updates to custom toolchains. (flutter#6674)
6c2a0b3 Undefine ERROR in platform_view_layer.cc (flutter#6675)
55e1299 Update FlutterPlugin.h docs, suppress warning for older API (flutter#6672)
f797004 Attach and position embedded UIVIews (flutter#6614)
df85722 Plumb the iOS PlatformViewsController into flow. (flutter#6603)
2bfb893 iOS Embedding Refactor (flutter#6447)
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet