Installation
nepali_utils is a pure Dart package with no platform code. It works anywhere Dart runs: Flutter (mobile, desktop and web), the Dart VM, servers and command-line tools.
Requirements
Section titled “Requirements”- Dart SDK 3.13 or later. The package’s
pubspec.yamlrequiressdk: ^3.13.0. The library uses newer language features such as primary constructors and dot shorthands. - With Flutter, use a Flutter release that ships Dart 3.13 or later. Run
flutter --versionto see which Dart SDK you have.
Add the dependency
Section titled “Add the dependency”For a Dart project:
dart pub add nepali_utilsFor a Flutter project:
flutter pub add nepali_utilsEither command adds a line like this to your pubspec.yaml:
dependencies: nepali_utils: ^4.0.0Import it
Section titled “Import it”Everything is exported from one library:
import 'package:nepali_utils/nepali_utils.dart';Check that it works
Section titled “Check that it works”import 'package:nepali_utils/nepali_utils.dart';
void main() { final date = NepaliDateTime.parse('2072-06-03T17:00:00'); print(NepaliDateFormat.yMMMMEEEEd().format(date)); // Sunday, Ashwin 3, 2072 print(date.toDateTime()); // 2015-09-20 17:00:00.000}Flutter notes
Section titled “Flutter notes”- There’s nothing extra to set up. No plugins, assets or platform channels are involved.
- To show text in the app’s language, set
NepaliUtils.defaultLanguagefrom the app’sLocale, or pass aLanguageto each formatter. - Devanagari text needs a font with Devanagari glyphs. Android, iOS, macOS and Windows include one. On Linux and the web, you may need to add a font such as Noto Sans Devanagari to your app.
NepaliDateTime.now()returns local time, likeDateTime.now(). To show the time in Nepal whatever the device’s time zone, useNepaliDateTime.nepalNow(). See Time zones.
Next steps
Section titled “Next steps”- Choose a language for formatted output.
- Work with Nepali dates.
- Coming from 3.x? Read Upgrading to 4.0.
