Closed tamle66 closed 1 year ago
I copied and paste the example code in Pub.dev, but the output is always the current time, not the selected time. What can be wrong this case?
flutter: Hello: 2023-05-09 22:18:14.873810
This is the code I used.
import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:omni_datetime_picker/omni_datetime_picker.dart'; class AddEditScreen extends ConsumerWidget { const AddEditScreen({super.key}); @override Widget build(BuildContext context, WidgetRef ref) { return Scaffold( body: Center( child: Column( children: [ ElevatedButton( onPressed: () async { DateTime? dateTime = await showOmniDateTimePicker( context: context, initialDate: DateTime.now(), firstDate: DateTime(1600).subtract(const Duration(days: 3652)), lastDate: DateTime.now().add( const Duration(days: 3652), ), is24HourMode: false, isShowSeconds: false, minutesInterval: 1, secondsInterval: 1, isForce2Digits: true, borderRadius: const BorderRadius.all(Radius.circular(16)), constraints: const BoxConstraints( maxWidth: 350, maxHeight: 650, ), transitionBuilder: (context, anim1, anim2, child) { return FadeTransition( opacity: anim1.drive( Tween( begin: 0, end: 1, ), ), child: child, ); }, transitionDuration: const Duration(milliseconds: 200), barrierDismissible: true, selectableDayPredicate: (dateTime) { // Disable 25th Feb 2023 if (dateTime == DateTime(2023, 2, 25)) { return false; } else { return true; } }, ); print("Hello: $dateTime"); }, child: const Text("Show DateTime Picker"), ), ], ), ), ); } }
@tamle66 I've copied your code exactly and it's working fine.
I tested with a completely new project and it's actually working :( So there's something wrong with my current project. I appreciate your help!
I copied and paste the example code in Pub.dev, but the output is always the current time, not the selected time. What can be wrong this case?
This is the code I used.