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

SearchDelegate with custom maxLines in TextField #84103

Closed
fh32000 opened this issue Jun 7, 2021 · 7 comments
Closed

SearchDelegate with custom maxLines in TextField #84103

fh32000 opened this issue Jun 7, 2021 · 7 comments
Labels
r: timeout Issue is closed due to author not providing the requested details in time

Comments

@fh32000
Copy link

fh32000 commented Jun 7, 2021

I need to use SearchDelegate as lang to translate so i need to enter multi line text

Proposal

I think it will be good if i can @OverRide as TextStyle

@fh32000
Copy link
Author

fh32000 commented Jun 7, 2021

i try

 @override
  TextStyle get searchFieldStyle => TextStyle(
    color: Colors.red,
    fontSize: 9.0,
    // maxLines: null,

  );
  @override
  InputDecorationTheme get searchFieldDecorationTheme => InputDecorationTheme(
     helperMaxLines: null,
  );

not working

@darshankawar darshankawar added the in triage Presently being triaged by the triage team label Jun 7, 2021
@darshankawar darshankawar changed the title SearchDelegate with custme maxLines in TextField SearchDelegate with custom maxLines in TextField Jun 7, 2021
@darshankawar
Copy link
Member

@fh32000
I am not too clear on your request. Can you please elaborate on your use case / example in detail and a detailed proposal so that we can properly address this ?

Thanks.

@darshankawar darshankawar added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jun 7, 2021
@fh32000
Copy link
Author

fh32000 commented Jun 7, 2021

import 'package:flutter/material.dart';

class WordSearch extends SearchDelegate<String> {
  WordSearch(this._wordsHistory, this.searchFieldLabel);

  final List<String> _wordsHistory;
  String? _result;
  @override
  String? searchFieldLabel;

  @override
  List<Widget> buildActions(BuildContext context) {
    return <Widget>[
      IconButton(
        icon: const Icon(Icons.clear),
        onPressed: () {
          /// Close the words input screen if the user
          /// clicks on [x] and [query] is empty
          /// else clear query
          if (query.isEmpty) {
            close(context, _result ?? query);
          } else {
            query = '';
          }
        },
      )
    ];
  }

  @override
  Widget buildLeading(BuildContext context) {
    return IconButton(
      icon: const Icon(Icons.arrow_back),
      onPressed: () {
        ///Close the words screen and return the input
        close(context, _result ?? query);
      },
    );
  }

  @override
  Widget buildResults(BuildContext context) {
    final suggestions = _wordsHistory.where((String name) {
      return name.toLowerCase().contains(query.toLowerCase());
    });

    return ListView.builder(
      itemCount: suggestions.length,
      itemBuilder: (BuildContext context, int index) {
        return ListTile(
          title: Text(
            suggestions.elementAt(index),
          ),
          onTap: () {
            _result = suggestions.elementAt(index);
            close(context, _result ?? query);
          },
        );
      },
    );
  }

  @override
  TextStyle get searchFieldStyle => TextStyle(
    color: Colors.red,
    fontSize: 9.0,
-// maxLines: null,

  );
  

  @override
  Widget buildSuggestions(BuildContext context) {
    final suggestions = _wordsHistory.where((String name) {
      return name.toLowerCase().contains(query.toLowerCase());
    });
    return ListView.separated(
      separatorBuilder: (_, __) {
        return Divider(
          thickness: 1.5,
          endIndent: 10,
          indent: 10,
        );
      },
      itemCount: suggestions.length,
      itemBuilder: (BuildContext context, int index) {
        return ListTile(
          title: Padding(
            padding: const EdgeInsets.all(8.0),
            child: ListTile(
              title: Text(
                suggestions.elementAt(index),
                maxLines: 2,
                overflow: TextOverflow.ellipsis,
              ),
              trailing: Icon(Icons.history),
            ),
          ),
          onTap: () {
            query = suggestions.elementAt(index);
            close(context, _result ?? query);
          },
        );
      },
    );
  }
}

I try to add multiline text field in SearchDelegate but not work
@darshankawar

1 similar comment
@fh32000
Copy link
Author

fh32000 commented Jun 7, 2021

import 'package:flutter/material.dart';

class WordSearch extends SearchDelegate<String> {
  WordSearch(this._wordsHistory, this.searchFieldLabel);

  final List<String> _wordsHistory;
  String? _result;
  @override
  String? searchFieldLabel;

  @override
  List<Widget> buildActions(BuildContext context) {
    return <Widget>[
      IconButton(
        icon: const Icon(Icons.clear),
        onPressed: () {
          /// Close the words input screen if the user
          /// clicks on [x] and [query] is empty
          /// else clear query
          if (query.isEmpty) {
            close(context, _result ?? query);
          } else {
            query = '';
          }
        },
      )
    ];
  }

  @override
  Widget buildLeading(BuildContext context) {
    return IconButton(
      icon: const Icon(Icons.arrow_back),
      onPressed: () {
        ///Close the words screen and return the input
        close(context, _result ?? query);
      },
    );
  }

  @override
  Widget buildResults(BuildContext context) {
    final suggestions = _wordsHistory.where((String name) {
      return name.toLowerCase().contains(query.toLowerCase());
    });

    return ListView.builder(
      itemCount: suggestions.length,
      itemBuilder: (BuildContext context, int index) {
        return ListTile(
          title: Text(
            suggestions.elementAt(index),
          ),
          onTap: () {
            _result = suggestions.elementAt(index);
            close(context, _result ?? query);
          },
        );
      },
    );
  }

  @override
  TextStyle get searchFieldStyle => TextStyle(
    color: Colors.red,
    fontSize: 9.0,
-// maxLines: null,

  );
  

  @override
  Widget buildSuggestions(BuildContext context) {
    final suggestions = _wordsHistory.where((String name) {
      return name.toLowerCase().contains(query.toLowerCase());
    });
    return ListView.separated(
      separatorBuilder: (_, __) {
        return Divider(
          thickness: 1.5,
          endIndent: 10,
          indent: 10,
        );
      },
      itemCount: suggestions.length,
      itemBuilder: (BuildContext context, int index) {
        return ListTile(
          title: Padding(
            padding: const EdgeInsets.all(8.0),
            child: ListTile(
              title: Text(
                suggestions.elementAt(index),
                maxLines: 2,
                overflow: TextOverflow.ellipsis,
              ),
              trailing: Icon(Icons.history),
            ),
          ),
          onTap: () {
            query = suggestions.elementAt(index);
            close(context, _result ?? query);
          },
        );
      },
    );
  }
}

I try to add multiline text field in SearchDelegate but not work
@darshankawar

@no-response no-response bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jun 7, 2021
@darshankawar
Copy link
Member

@fh32000
Can you check if this issue sounds similar to yours ? #11416

If not, please provide a complete minimal reproducible code sample that we can directly copy paste and run to verify this.

Thanks.

@darshankawar darshankawar added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jun 8, 2021
@darshankawar
Copy link
Member

Without additional information, we are unfortunately not sure how to resolve this issue.
We are therefore reluctantly going to close this bug for now.
Please don't hesitate to comment on the bug if you have any more information for us; we will reopen it right away!
Thanks for your contribution.

Could everyone who still has this problem please file a new issue with the exact description of what happens, logs, and the output of flutter doctor -v.
All system setups can be slightly different, so it's always better to open new issues and reference related issues.

@darshankawar darshankawar added r: timeout Issue is closed due to author not providing the requested details in time and removed in triage Presently being triaged by the triage team waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds labels Jul 9, 2021
@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 Jul 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
r: timeout Issue is closed due to author not providing the requested details in time
Projects
None yet
Development

No branches or pull requests

2 participants