args property
Creator with the same args are considered the same. args need to be unique within the graph.
When a creator is defined as a local variable like this:
final text = Creator((ref) {
final double = Creator((ref) => ref.watch(number) * 2);
return 'double: ${ref.watch(double)}';
})
Here double is a local variable, it has different instances whenever text is recreated. The internal graph could change from number -> double_A -> text to number -> double_B -> text as the number changes. text still generates correct data, but there is extra cost to swap the node in the graph. Because the change is localized to only one node, the cost can be ignored as long as the create function is simple.
Or we can set args to ask the framework to find an existing creator with the same args in the graph, to avoid the extra cost.
Internally, args powers these features:
- Creator group.
profileCreator('userA') is a creator with args
profileCreator, 'userA'
. - Async data.
userCreator.asyncData is a creator with args
userCreator, 'asyncData'
. - Change.
number.change is a creator with args
number, 'change'
.
Implementation
final List<Object?>? args;