call method Null safety

T call(
  1. [T? v]
)

updates the value to null and adds it to the Stream. Even with null-safety coming, is still an important feature to support, as call() doesn't accept null values. For instance, InputDecoration.errorText has to be null to not show the "error state".

Sample:

final inputError = ''.obs..nil();
print('${inputError.runtimeType}: $inputError'); // outputs > RxString: null

Makes this Rx looks like a function so you can update a new value using rx(someOtherValue). Practical to assign the Rx directly to some Widget that has a signature ::onChange( value )

Example:

final myText = 'GetX rocks!'.obs;

// in your Constructor, just to check it works :P
ever( myText, print ) ;

// in your build(BuildContext) {
TextField(
  onChanged: myText,
),

Implementation

// void nil() {
//   subject.add(_value = null);
// }

/// Makes this Rx looks like a function so you can update a new
/// value using `rx(someOtherValue)`. Practical to assign the Rx directly
/// to some Widget that has a signature ::onChange( value )
///
/// Example:
/// ```
/// final myText = 'GetX rocks!'.obs;
///
/// // in your Constructor, just to check it works :P
/// ever( myText, print ) ;
///
/// // in your build(BuildContext) {
/// TextField(
///   onChanged: myText,
/// ),
///```
T call([T? v]) {
  if (v != null) {
    value = v;
  }
  return value;
}