'What is the point of a basic Riverpod Provider in Flutter?

I'm fairly new to Flutter and am now implementing Riverpod. I've studied a number of guides and tutorials, and they all seem to start with the same simple example - either a basic provider which provides "Hello World", or an integer, as follows:

final countProvider = Provider<Int>((ref) => 0);

final hellowWorldProvider = Provider<String>((ref) => "Hello world");

There is then a Consumer object within a StatelessWidget which calls watch() this provider to get the value.

My question is, what is the point of this? Not a single one of the tutorials that I've found show a way of modifying the value returned by the provider, so it will always be the same. What advantage is there in using the provider here? Why call watch() on a value that doesn't change? You could just hard code the value in the Widget, or if that's frowned upon, use a constants file or equivalent.

Please tell me what I'm missing here, thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source