Issue
Background
- A
ValueNotifier
has aValueListenableBuilder
widget. - A
Stream
has aStreamBuilder
widget. - A
Future
has aFutureBuilder
widget.
Question
- What is the builder for
ChangeNotifier
?
What I tried
I tried using a ValueListenableBuilder
with ChangeNotifier
but ChangeNotifier
doesn’t implement ValueListenable
.
I know I could use ChangeNotifierProvider
from the Provider
package, but I’d like to know if there is a solution that doesn’t require a third-party package.
Solution
ChangeNotifier is a direct implementation of the Listenable Widget and for the Listenable, you can use AnimatedBuilder, which triggers rebuilds from a Listenable without passing back a specific value
Also, your class could extend from ChangeNotifier and add new capability to it and you can create a custom Builder widget base on these new functionalities
Answered By – Amir Hossein Mirzaei
Answer Checked By – Mary Flores (FlutterFixes Volunteer)