swift<T> function

SwiftValue<T> swift<T>(
  1. T value, {
  2. String? name,
})

Creates a SwiftValue with optional type inference.

Usage with automatic inference: swift(0) creates SwiftValue<int>. Usage with explicit type: swift<int>(0) creates SwiftValue<int>. Usage for models: swift<MyModel>(myModel) creates SwiftValue<MyModel>.

Example:

final counter = swift(0);        // Automatically SwiftValue<int>
final name = swift('Hello');     // Automatically SwiftValue<String>
final user = swift<User>(user);  // Explicit type for models

Implementation

SwiftValue<T> swift<T>(T value, {String? name}) => SwiftValue<T>(value, name: name);