Fintasys / emoji_picker_flutter

A Flutter package that provides an Emoji picker widget with 1500+ emojis in 8 categories.
MIT License
155 stars 115 forks source link

[BugFix] Avoid rebuilds on every setState() when custom config is given #28

Closed asnbd closed 2 years ago

asnbd commented 2 years ago

Attempt to fix #27

Check this line: https://github.com/Fintasys/emoji_picker_flutter/blob/master/lib/src/emoji_picker.dart#L113

Here, oldWidget.config != widget.config will always true even they have same values inside as it is not comparing the instance member values of 2 objects. That's why the rebuild happens on every setState() if we provide a Config() object for customization.

So I have Overridden the == operator in the Config class to compare if 2 objects are the same or not according to their values. The hashCode property is also overridden to maintain consistency.

Zverik commented 2 years ago

Great, just debugged this and came to the same conclusion: the Config class needs its equality overloaded.