omni_datetime_picker 2.3.1 copy "omni_datetime_picker: ^2.3.1" to clipboard
omni_datetime_picker: ^2.3.1 copied to clipboard

A datetime picker package with option to use a single datetime picker or a datetime range picker.

example/main.dart

import 'package:flutter/material.dart';
import 'package:omni_datetime_picker/omni_datetime_picker.dart';

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Omni DateTime Picker',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(
          seedColor: Colors.cyan,
          brightness: Brightness.light,
        ),
      ),
      home: const OmniExample(),
    );
  }
}

class OmniExample extends StatelessWidget {
  const OmniExample({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          children: [
            ElevatedButton(
              onPressed: () async {
                final DateTime? dateTime =
                    await showOmniDateTimePicker(context: context);

                // Use dateTime here
                debugPrint('dateTime: $dateTime');
              },
              child: const Text('Show DateTime Picker'),
            ),
            ElevatedButton(
              onPressed: () async {
                final DateTime? result = await showOmniDateTimePicker(
                  context: context,
                  is24HourMode: true,
                );

                if (result != null) {
                  // This should show the second and millisecond fields set to zero after the fix
                  debugPrint(
                      'Selected DateTime: ${result.toUtc().toIso8601String()}');
                  debugPrint(
                      'Seconds: ${result.second}, Milliseconds: ${result.millisecond}');
                }
              },
              child: const Text('Test 24-Hour Mode (check seconds)'),
            ),
            ElevatedButton(
              onPressed: () async {
                final DateTime? result = await showOmniDateTimePicker(
                  context: context,
                  is24HourMode: true,
                  isShowSeconds: true,
                );

                if (result != null) {
                  // This should show microseconds as 0 even when seconds are enabled
                  debugPrint(
                      'Selected DateTime with seconds: ${result.toUtc().toIso8601String()}');
                  debugPrint(
                      'Seconds: ${result.second}, Microseconds: ${result.microsecond}');
                }
              },
              child: const Text('Test with Seconds (check microseconds)'),
            ),
            ElevatedButton(
              onPressed: () async {
                final List<DateTime>? dateTime =
                    await showOmniDateTimeRangePicker(context: context);

                // Use dateTime here
                debugPrint('dateTime: $dateTime');
              },
              child: const Text('Show DateTime Picker'),
            ),
          ],
        ),
      ),
    );
  }
}
250
likes
160
points
17.5k
downloads

Publisher

verified publisheralanchan.dev

Weekly Downloads

A datetime picker package with option to use a single datetime picker or a datetime range picker.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

equatable, flutter, flutter_bloc, rxdart

More

Packages that depend on omni_datetime_picker