rigid_datetime 0.0.1
rigid_datetime: ^0.0.1 copied to clipboard
A Flutter plugin to check the system time format (12h/24h) and get platform version.
Rigid Datetime #
A lightweight Flutter plugin for detecting the device's native system time format (12-hour or 24-hour) using platform-specific APIs.
Features #
- Detects the device's preferred time format (12-hour or 24-hour)
- Native Android implementation using Kotlin
- Native iOS implementation using Swift
- Simple and easy-to-use Flutter API
- MethodChannel-based communication
- Lightweight and easy to integrate
Platform Support #
| Platform | Status |
|---|---|
| Android | Supported |
| iOS | Supported |
Installation #
Add the dependency to your pubspec.yaml.
dependencies:
rigid_datetime: ^1.0.0
Then run:
flutter pub get
Usage #
Import the package.
import 'package:rigid_datetime/rigid_datetime.dart';
Detect System Time Format #
final bool is24Hour = await RigidDatetime().getTimeFormat();
if (is24Hour) {
print("24 Hour Format");
} else {
print("12 Hour Format");
}
API #
| Method | Return Type | Description |
|---|---|---|
getTimeFormat() |
Future<bool> |
Returns true when the device uses a 24-hour clock and false when it uses a 12-hour clock. |
How It Works #
The plugin communicates with the native platform using Flutter's MethodChannel to retrieve the device's preferred time format.
On Android, it uses:
DateFormat.is24HourFormat(context)
to determine whether the device is configured to use a 24-hour clock.
Requirements #
- Flutter 3.0.0 or later
- Dart 3.0.0 or later
- Android API 21 or later
- iOS 12.0 or later
Contributing #
Contributions, feature requests, and bug reports are welcome. If you have an idea or find an issue, please open an issue or submit a pull request.
License #
This project is licensed under the MIT License.