How to debounce Textfield onChange in Dart?

后端 未结 9 1212
攒了一身酷
攒了一身酷 2020-12-03 04:49

I\'m trying to develop a TextField that update the data on a Firestore database when they change. It seems to work but I need to prevent the onChange event to fire multiple

9条回答
  •  孤城傲影
    2020-12-03 05:08

    Here is my solution

     subject = new PublishSubject();
          subject.stream
              .debounceTime(Duration(milliseconds: 300))
              .where((value) => value.isNotEmpty && value.toString().length > 1)
              .distinct()
              .listen(_search);
    

提交回复
热议问题