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

ERROR when space used in searchbar #1

Open
ManaanAnsari opened this issue Jan 11, 2020 · 2 comments
Open

ERROR when space used in searchbar #1

ManaanAnsari opened this issue Jan 11, 2020 · 2 comments

Comments

@ManaanAnsari
Copy link

m getting this error when I use spaces in search
it works fine for single word

E/flutter (13594): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: type '_Exception' is not a subtype of type 'Error' E/flutter (13594): #0 SearchBarController._search (package:flappy_search_bar/flappy_search_bar.dart:55:36) E/flutter (13594): <asynchronous suspension> E/flutter (13594): #1 _SearchBarState._onTextChanged.<anonymous closure> (package:flappy_search_bar/flappy_search_bar.dart:271:29) E/flutter (13594): #2 _rootRun (dart:async/zone.dart:1122:38) E/flutter (13594): #3 _CustomZone.run (dart:async/zone.dart:1023:19) E/flutter (13594): #4 _CustomZone.runGuarded (dart:async/zone.dart:925:7) E/flutter (13594): #5 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:965:23) E/flutter (13594): #6 _rootRun (dart:async/zone.dart:1126:13) E/flutter (13594): #7 _CustomZone.run (dart:async/zone.dart:1023:19) E/flutter (13594): #8 _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:949:23) E/flutter (13594): #9 Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:23:15) E/flutter (13594): #10 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:384:19) E/flutter (13594): #11 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:418:5) E/flutter (13594): #12 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12) E/flutter (13594):

can you please help me fix it?

@ThomasEcalle
Copy link
Contributor

Hi,

Could you give me more information about the search you did ?
Spaces normally do not throw errors.

If you run the example from the package and try to search for A good example, it should not crash.

But may be the String you have searched has something else than spaces ?

Any details may be usefull :)

@LutfiGarzon
Copy link

Hope this help you solve your problem

Future<List<Account>> search(String search) async {

    // replace space by "+" plus sign
    final query = search.replaceAll(new RegExp(r"\s\b|\b\s"), "+");

    // fetch your data using your http call pass the query to the method
    final listAccount = await http.fetchAccount(query);

    // then return your search result
    return listAccount;
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants