An easy way to add Baha’í dates (Badi Calendar) into a Flutter app is with the open source dart library Badi date.

To install add the following to the “dependencies” section of pubspec.yaml file:

dependencies:
  badi_date: ^1.0.1

and run flutter pub get or dart pub get.

The following shows the library in use:

1
2
3
4
5
6
7
8
9
10
11
import 'package:badi_date/badi_date.dart';

final date1 = BadiDate(day: 1, month: 1, year: 178);
final date2 = BadiDate.fromDate(DateTime.now());

final DateTime start = date1.startDateTime;
final DateTime end = date1.endDateTime;
final BahaiHolyDayEnum? holyDay = date1.holyDay;
final bool = date2.isPeriodOfFast;
final bool = date2.isAyyamIHa;
final BadiDate nextHolyDay = date2.nextHolyDate;

In 3 a BadiDate object is created with Badi day, month, and year. In 4 creation with a Dart DateTime is demonstrated. If the optional parameter longitude and latitude are set, the library will consider the exact sunset time. If not set, 6pm will be assumed for sunset. 6pm will also be used for the polar regions. 6 and 7 return the begin and the end of the Badi date. If the date is a holyday, 8 will return a non null result.

The library is used in the open source Baha’i Calendar app.