condition_builder 2.1.0
condition_builder: ^2.1.0 copied to clipboard
A tiny Flutter utility that helps you write clean, readable multi-way conditional logic directly inside widget attributes
2.1.0 #
-
✅ Added:
ConditionBuilder.on(...)named constructor- Allows creating a builder with the first condition inline.
- Example:
ConditionBuilder.on(() => isActive, () => Colors.green) .on(() => isDisabled, () => Colors.grey) .build(orElse: () => Colors.black);
-
❌ Removed:
ConditionBuilder()default constructor- You must now use
ConditionBuilder.on(...)to create an instance. - This ensures that at least one condition is always present at build time.
- You must now use
2.0.0 #
- Asynchronous support removed: This package is intended primarily for simplifying complex conditional logic within Flutter widget attributes. For asynchronous calls, using
if/else if/elseconstructs is more appropriate. - Simpler usage:
- The fallback (
orElse) is no longer set on the builder itself. - Instead, you can optionally provide a fallback directly when calling
build(), for example:.build(orElse: () => defaultValue);
- The fallback (
- No fallback? No match?:
Thebuild()method will never returnnull. If no conditions match and no fallback is provided, it throws an error to alert you. onIfmethod removed:
To add conditions conditionally, combine your checks inside theon()condition function yourself.
These changes make the builder easier and more predictable to use!
1.0.0 #
- First release.