satisfied_version 0.0.1+3 copy "satisfied_version: ^0.0.1+3" to clipboard
satisfied_version: ^0.0.1+3 copied to clipboard

outdated

Check whether the version is satisfied with provided String, List, or Map of versions or not.

Satisfied Version #

Check whether the version is satisfied with provided String, List, or Map of versions or not.

Usage #

Compare 2 version with conditions:

SatisfiedVersion.isSatisfied('1.0.0', '>=1.0.0') // => true
SatisfiedVersion.isSatisfied('1.0.0', '<=1.0.0') // => true

SatisfiedVersion.isSatisfied('1.0.0', '>1.0.0') // => false
SatisfiedVersion.isSatisfied('1.0.1', '>1.0.0') // => true
SatisfiedVersion.isSatisfied('1.0.0', '<1.0.0') // => false

SatisfiedVersion.isSatisfied('1.0.0', '=1.0.0') // => true
SatisfiedVersion.isSatisfied('1.0.0', '==1.0.0') // => true
// Default is return `appVersion == version`

Return true if there is any satisfied version in sources:

const versions = ['<1.0.0', '>=1.0.2'];
print(SatisfiedVersion.list('1.0.0', versions)); // => false
print(SatisfiedVersion.list('1.0.3', versions)); // => true
print(SatisfiedVersion.list('0.0.9', versions)); // => true

Return value of the satisfied key. Default is false

  • preferTrue = true: Return true if it has at least 1 true condition.
  • preferTrue = false: Return false if it has at least 1 false condition. Default.
const versions = {'<1.0.0' : true, '>=1.0.2' : false};
print(SatisfiedVersion.map('1.0.0', versions)); // => false
print(SatisfiedVersion.map('1.0.3', versions)); // => false
print(SatisfiedVersion.map('0.0.9', versions)); // => true

There is also a extension for String that help you easier to use this plugin:

final result = '1.0.0'.isSatisfiedVersion('<=1.0.0'); // => true
final result = '1.0.0'.isSatisfiedVersion(['<=1.0.0']); // => true
final result = '1.0.0'.isSatisfiedVersion(['<=1.0.0' : false]); // => false

Additional Parameters #

  • For all:

    • defaultCondition is the default condition if the compared version is provided without condition. Default value is SatisfiedCondition.equal.
  • For specific Map:

    • defaultValue is the default result for Map when appVersion is not in any range.
    • preferTrue is the preferred value when there are multiple results in Map.
3
likes
0
pub points
68%
popularity

Publisher

verified publisherlamnhan.dev

Check whether the version is satisfied with provided String, List, or Map of versions or not.

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on satisfied_version