This guide helps you migrate from myanmar_calendar_dart v1.x to v2.x.
- Update dependency version to
^2.0.0 - Replace removed custom-holiday legacy APIs
- Move from map-style year metadata to typed
MyanmarYearInfo - Replace removed translation-service legacy APIs with explicit-language calls
- Optionally adopt
MyanmarCalendarClientfor isolated runtime state
CustomHoliday.legacy(...)- Un-typed legacy
predicate-style usage MyanmarCalendar.addCustomHoliday(...)MyanmarCalendar.addCustomHolidays(...)MyanmarCalendar.removeCustomHoliday(...)MyanmarCalendar.clearCustomHolidays(...)MyanmarCalendar.configure(customHolidays: ...)parameter alias
- Typed matcher with
CustomHolidayContext customHolidayRuleseverywhere- Rule-oriented methods:
MyanmarCalendar.addCustomHolidayRule(...)MyanmarCalendar.addCustomHolidayRules(...)MyanmarCalendar.removeCustomHolidayRuleById(...)MyanmarCalendar.clearCustomHolidayRules()
final holiday = CustomHoliday.legacy(
id: 'team_day',
name: 'Team Day',
type: HolidayType.cultural,
predicate: (myanmarDate, westernDate) => westernDate.month == 7 && westernDate.day == 27,
);
MyanmarCalendar.configure(customHolidays: [holiday]);
MyanmarCalendar.addCustomHoliday(holiday);final holiday = CustomHoliday(
id: 'team_day',
name: 'Team Day',
type: HolidayType.cultural,
matcher: (context) =>
context.westernDate.month == 7 && context.westernDate.day == 27,
);
MyanmarCalendar.configure(customHolidayRules: [holiday]);
MyanmarCalendar.addCustomHolidayRule(holiday);DateConverter.getYearInfo(...)(map-based)
DateConverter.getMyanmarYearInfo(...)returningMyanmarYearInfoMyanmarCalendarClient.getMyanmarYearInfo(...)
final info = converter.getYearInfo(1385);
final yearType = info['yearType'] as int;final info = converter.getMyanmarYearInfo(1385);
final yearType = info.yearType;TranslationService.currentLanguageTranslationService.setLanguage(...)TranslationService.translate(...)MyanmarCalendarService.setLanguage(...)MyanmarCalendarService.currentLanguage
- Explicit language calls:
TranslationService.translateTo(key, language)
- Request-scoped language arguments in APIs that support
language: - Default language via configuration:
MyanmarCalendar.configure(language: ...)CalendarConfig(defaultLanguage: ...)
TranslationService.setLanguage(Language.myanmar);
final text = TranslationService.translate('Independence');final text = TranslationService.translateTo('Independence', Language.myanmar);v2 introduces MyanmarCalendarClient for isolated runtime behavior
(config/cache/service) and safer multi-tenant/server usage.
final client = MyanmarCalendar.createClient(
config: const CalendarConfig(
defaultLanguage: 'en',
timezoneOffset: 6.5,
),
cacheConfig: const CacheConfig.memoryEfficient(),
);
final complete = client.getCompleteDate(DateTime(2024, 1, 4));
final yearInfo = client.getMyanmarYearInfo(1385);If custom-holiday matcher logic changes while id stays the same, increment
cacheVersion to invalidate fingerprints deterministically.
final holiday = CustomHoliday(
id: 'team_day',
name: 'Team Day',
type: HolidayType.cultural,
cacheVersion: 2, // bump when matcher logic changes
matcher: (context) => context.westernDate.month == 7,
);If you share your v1 usage snippets, migration can be mapped line-by-line to v2.