Skip to content

Commit

Permalink
Upgrade to Dart v3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasWanke committed Jan 24, 2024
1 parent 37b0e10 commit ce0678e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 71 deletions.
19 changes: 0 additions & 19 deletions lib/src/codecs/string/decoder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ class RecurrenceRuleFromStringDecoder
oldValue: frequency,
parse: () => frequencyFromString(value),
);
break;
case recurRulePartUntil:
untilOrCount = _parseSimplePart(
name,
Expand All @@ -111,23 +110,20 @@ class RecurrenceRuleFromStringDecoder
);
},
);
break;
case recurRulePartCount:
untilOrCount = _parseSimplePart(
name,
value,
oldValue: untilOrCount,
parse: () => _UntilOrCount(count: int.parse(value)),
);
break;
case recurRulePartInterval:
interval = _parseSimplePart(
name,
value,
oldValue: interval,
parse: () => int.parse(value),
);
break;
case recurRulePartBySecond:
bySeconds = _parseIntListPart(
name,
Expand All @@ -138,7 +134,6 @@ class RecurrenceRuleFromStringDecoder
max: Duration.secondsPerMinute - 1,
allowNegative: false,
);
break;
case recurRulePartByMinute:
byMinutes = _parseIntListPart(
name,
Expand All @@ -148,7 +143,6 @@ class RecurrenceRuleFromStringDecoder
max: Duration.minutesPerHour - 1,
allowNegative: false,
);
break;
case recurRulePartByHour:
byHours = _parseIntListPart(
name,
Expand All @@ -158,15 +152,13 @@ class RecurrenceRuleFromStringDecoder
max: Duration.hoursPerDay - 1,
allowNegative: false,
);
break;
case recurRulePartByDay:
byWeekDays = _parseListPart(
name,
value,
oldValue: byWeekDays,
parse: _byWeekDayEntryDecoder.convert,
);
break;
case recurRulePartByMonthDay:
byMonthDays = _parseIntListPart(
name,
Expand All @@ -175,7 +167,6 @@ class RecurrenceRuleFromStringDecoder
min: 1,
max: 31,
);
break;
case recurRulePartByYearDay:
byYearDays = _parseIntListPart(
name,
Expand All @@ -184,7 +175,6 @@ class RecurrenceRuleFromStringDecoder
min: 1,
max: 366,
);
break;
case recurRulePartByWeekNo:
byWeeks = _parseIntListPart(
name,
Expand All @@ -193,7 +183,6 @@ class RecurrenceRuleFromStringDecoder
min: 1,
max: 53,
);
break;
case recurRulePartByMonth:
byMonths = _parseIntListPart(
name,
Expand All @@ -203,7 +192,6 @@ class RecurrenceRuleFromStringDecoder
max: 12,
allowNegative: false,
);
break;
case recurRulePartBySetPos:
bySetPositions = _parseIntListPart(
name,
Expand All @@ -212,7 +200,6 @@ class RecurrenceRuleFromStringDecoder
min: 1,
max: 366,
);
break;
case recurRulePartWkSt:
weekStart = _parseSimplePart(
name,
Expand All @@ -226,7 +213,6 @@ class RecurrenceRuleFromStringDecoder
'supported.)',
);
}
break;
}
}

Expand Down Expand Up @@ -272,10 +258,8 @@ class RecurrenceRuleFromStringDecoder
switch (options.duplicatePartBehavior) {
case RecurrenceRuleDuplicatePartBehavior.exception:
assert(false, 'This case is already handled above.');
break;
case RecurrenceRuleDuplicatePartBehavior.takeFirst:
newValue = oldValue;
break;
case RecurrenceRuleDuplicatePartBehavior.takeLast:
// We already prefer the new value.
break;
Expand Down Expand Up @@ -335,16 +319,13 @@ class RecurrenceRuleFromStringDecoder
switch (options.duplicatePartBehavior) {
case RecurrenceRuleDuplicatePartBehavior.exception:
assert(false, 'This case is already handled above.');
break;
case RecurrenceRuleDuplicatePartBehavior.takeFirst:
newValue = oldValue;
break;
case RecurrenceRuleDuplicatePartBehavior.takeLast:
// We already prefer the new value.
break;
case RecurrenceRuleDuplicatePartBehavior.mergePreferLast:
newValue.addAll(oldValue);
break;
}
}
return newValue;
Expand Down
3 changes: 0 additions & 3 deletions lib/src/codecs/text/encoder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -569,14 +569,11 @@ extension on List<String> {
switch (endIndex - startIndex) {
case 0:
add(map(source[startIndex]));
return;
case 1:
add(map(source[startIndex]));
add(map(source[endIndex]));
return;
default:
add(l10n.range(map(source[startIndex]), map(source[endIndex])));
return;
}
}
}
73 changes: 25 additions & 48 deletions lib/src/codecs/text/l10n/en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@ class RruleL10nEn extends RruleL10n {
@override
String frequencyInterval(Frequency frequency, int interval) {
String plurals({required String one, required String singular}) {
switch (interval) {
case 1:
return one;
case 2:
return 'Every other $singular';
default:
return 'Every $interval ${singular}s';
}
return switch (interval) {
1 => one,
2 => 'Every other $singular',
_ => 'Every $interval ${singular}s',
};
}

return {
Expand All @@ -50,14 +47,11 @@ class RruleL10nEn extends RruleL10n {

@override
String count(int count) {
switch (count) {
case 1:
return ', once';
case 2:
return ', twice';
default:
return ', $count times';
}
return switch (count) {
1 => ', once',
2 => ', twice',
_ => ', $count times',
};
}

@override
Expand All @@ -72,14 +66,11 @@ class RruleL10nEn extends RruleL10n {
'${_inVariant(variant)} the $weeks week of the year';

String _inVariant(InOnVariant variant) {
switch (variant) {
case InOnVariant.simple:
return 'in';
case InOnVariant.also:
return 'that are also in';
case InOnVariant.instanceOf:
return 'of';
}
return switch (variant) {
InOnVariant.simple => 'in',
InOnVariant.also => 'that are also in',
InOnVariant.instanceOf => 'of',
};
}

@override
Expand Down Expand Up @@ -134,34 +125,20 @@ class RruleL10nEn extends RruleL10n {
'${_onVariant(variant)} the $days day of the year';

String _onVariant(InOnVariant variant) {
switch (variant) {
case InOnVariant.simple:
return 'on';
case InOnVariant.also:
return 'that are also';
case InOnVariant.instanceOf:
return 'of';
}
return switch (variant) {
InOnVariant.simple => 'on',
InOnVariant.also => 'that are also',
InOnVariant.instanceOf => 'of',
};
}

@override
String list(List<String> items, ListCombination combination) {
String two;
String end;
switch (combination) {
case ListCombination.conjunctiveShort:
two = ' & ';
end = ' & ';
break;
case ListCombination.conjunctiveLong:
two = ' and ';
end = ', and ';
break;
case ListCombination.disjunctive:
two = ' or ';
end = ', or ';
break;
}
final (two, end) = switch (combination) {
ListCombination.conjunctiveShort => (' & ', ' & '),
ListCombination.conjunctiveLong => (' and ', ', and '),
ListCombination.disjunctive => (' or ', ', or '),
};
return RruleL10n.defaultList(items, two: two, end: end);
}

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: 0.2.14
repository: https://github.com/JonasWanke/rrule

environment:
sdk: '>=2.18.0 <4.0.0'
sdk: '>=3.0.0 <4.0.0'

dependencies:
collection: ^1.15.0
Expand Down

0 comments on commit ce0678e

Please sign in to comment.