Reference Wrapper is a Dart package which simulates pass by reference feature using Wrapper class which holds the value.
Use this package if you are calling a function that needs to modify its arguments
var x =Ref<num?>(null);
var read1 = x.ref; // first way to readvar read2 =x(); // second way to read
x.ref =10; // first way to writex(10); // second way to writevoidtwice(Ref<num> x, Ref<num> y) {
x.ref *=2;
y.ref *=2;
}
voidtest() {
var x =Ref<num>(5);
var y =Ref<num>(7);
twice(x, y);
print(x.ref); // 10print(y.ref); // 14
}voidtwice(Ref<num> x, Ref<num> y) {
x(x() *2);
y(y() *2);
}
voidtest() {
var x =Ref<num>(5);
var y =Ref<num>(7);
twice(x, y);
print(x()); // 10print(y()); // 14
}