BoolExtensions extension
Swift-like extension methods for common Dart types.
This file provides convenient extension methods inspired by Swift's API, making Dart code more expressive and concise.
Example usage:
import 'package:swift_flutter/swift_flutter.dart';
// Bool toggle
bool flag = true;
flag = flag.toggle(); // false
// Number operations
int count = 10;
count = count.add(5); // 15
count = count.sub(3); // 12
count = count.clamped(min: 0, max: 100); // 12
// String operations
String name = 'hello';
name = name.capitalized; // 'Hello'
name = name.add(' world'); // 'Hello world'
name = name.dropFirst(); // 'ello world'
name = name.dropLast(); // 'ello worl'
// List operations
List<int> numbers = [1, 2, 3, 4, 5];
numbers = numbers.dropFirst(); // [2, 3, 4, 5]
numbers = numbers.dropLast(); // [2, 3, 4]
numbers.containsWhere((n) => n > 3); // true (Swift-like contains(where:))
// Reactive operations
final counter = swift(10);
counter.add(5); // counter.value is now 15
counter.sub(3); // counter.value is now 12
final name = swift('hello');
name.add(' world'); // name.value is now 'hello world'
final flag = swift(true);
flag.toggle(); // flag.value is now false
Extension methods for bool type.
- on
Methods
-
toggle(
) → bool -
Available on bool, provided by the BoolExtensions extension
Toggles the boolean value.