koukibadr / Bottom-Picker

https://pub.dev/packages/bottom_picker
MIT License
34 stars 22 forks source link

OnSubmit in Timerpicker not working with flutter 3.16 #79

Open janlueders opened 12 months ago

janlueders commented 12 months ago

i tried to use the default timepicker as shown in the example code, with the newest Version. After upgrading to flutter 3.16 the onSubmit only in the Timepicker isn't working anymore.

Flutter doctor -v [✓] Flutter (Channel stable, 3.16.0, on Ubuntu 22.04.3 LTS 6.5.11-4-liquorix-amd64, locale de_DE.UTF-8) • Flutter version 3.16.0 on channel stable at /home/jl/snap/flutter/common/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision db7ef5bf9f (vor 7 Tagen), 2023-11-15 11:25:44 -0800 • Engine revision 74d16627b9 • Dart version 3.2.0 • DevTools version 2.28.2
Code example ``` class AddBloodPresure extends ConsumerStatefulWidget { const AddBloodPresure({super.key}); ​ @override ConsumerState createState() => _AddBloodPresureState(); } ​ class _AddBloodPresureState extends ConsumerState { Utils niuUtils = Utils(); final _dateC = TextEditingController(); final _timeC = TextEditingController(); final _sys = TextEditingController(); final _dias = TextEditingController(); var dateSelected = DateTime.now().toString(); ​ Duration initialtimer = Duration(); void _openTimePicker(BuildContext context) { BottomPicker.time( title: 'Set your next meeting time', titleStyle: TextStyle( fontWeight: FontWeight.bold, fontSize: 15, color: Colors.orange, ), onSubmit: (index) { print(index); }, onClose: () { print('Picker closed'); }, bottomPickerTheme: BottomPickerTheme.orange, use24hFormat: true, initialTime: Time( minutes: 23, ), maxTime: Time( hours: 17, ), ).show(context); } @override Widget build(BuildContext context) { double baseWidth = 390; double fem = MediaQuery.of(context).size.width / baseWidth; double ffem = fem * 0.97; var now = DateTime.now(); var formatter = DateFormat('yyyy-MM-dd'); String formattedDate = formatter.format(now); _dateC.text = formattedDate; ​ _timeC.text = DateTime.now().toString().split(" ")[1].split(".")[0].substring(0, 5); return Scaffold( resizeToAvoidBottomInset: false, body: SafeArea( child: Container( margin: const EdgeInsets.all(25), child: Column( children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( AppLocalizations.of(context).vitalAddData, style: TextStyle( fontFamily: 'Nunito', fontSize: 24 * ffem, fontWeight: FontWeight.w700, height: 1.3625 * ffem / fem, color: const Color(0xff000000), ), ), Text( AppLocalizations.of(context).vitalBloodPressure, style: TextStyle( fontFamily: 'Nunito', fontSize: 16 * ffem, fontWeight: FontWeight.w600, height: 2.1875 * ffem / fem, letterSpacing: -0.3039999962 * fem, color: const Color(0xff000000), ), ), const SizedBox(height: 20), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( AppLocalizations.of(context).vitalDateTime, style: TextStyle( fontFamily: 'Nunito', fontSize: 15.9101114273 * ffem, fontWeight: FontWeight.w600, height: 1.3625 * ffem / fem, color: const Color(0xff000000), ), ), SizedBox( height: 10 * fem, ), Container( padding: EdgeInsets.fromLTRB( 0 * fem, 0 * fem, 0 * fem, 0 * fem), width: MediaQuery.sizeOf(context).width * 0.4, decoration: BoxDecoration( color: const Color(0xffffffff), borderRadius: BorderRadius.circular(10 * fem), boxShadow: [ BoxShadow( color: const Color(0x3f014428), offset: Offset(0 * fem, 0 * fem), blurRadius: 2 * fem, ), ], ), child: SizedBox( height: 45, width: double.infinity, child: TextButton( onPressed: () { print("DatePicker"); }, style: TextButton.styleFrom( textStyle: const TextStyle( fontFamily: 'Nunito', fontSize: 14, fontWeight: FontWeight.w700, height: 1.3625, color: Color(0xff3c3b43), ), ), child: Align( alignment: Alignment.centerLeft, child: Text( _dateC.text, style: TextStyle( fontFamily: 'Nunito', fontSize: 14 * ffem, fontWeight: FontWeight.w700, height: 1.3625 * ffem / fem, color: const Color(0xff3c3b43), ), textAlign: TextAlign.left, ), ), ), )), SizedBox( height: 10 * fem, ), Container( padding: EdgeInsets.fromLTRB( 0 * fem, 0 * fem, 0 * fem, 0 * fem), width: MediaQuery.sizeOf(context).width * 0.4, decoration: BoxDecoration( color: const Color(0xffffffff), borderRadius: BorderRadius.circular(10 * fem), boxShadow: [ BoxShadow( color: const Color(0x3f014428), offset: Offset(0 * fem, 0 * fem), blurRadius: 2 * fem, ), ], ), child: SizedBox( height: 45, width: MediaQuery.sizeOf(context).width * 0.4, child: TextButton( onPressed: () { _openTimePicker(context); }, child: Align( alignment: Alignment.centerLeft, child: Text( _timeC.text, style: TextStyle( fontFamily: 'Nunito', fontSize: 14 * ffem, fontWeight: FontWeight.w700, height: 1.3625 * ffem / fem, color: const Color(0xff3c3b43), ), ), ), ), )), ], ), const SizedBox(height: 20), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( '${AppLocalizations.of(context).vitalSystole}:', style: TextStyle( fontFamily: 'Nunito', fontSize: 15.9101114273 * ffem, fontWeight: FontWeight.w600, height: 1.3625 * ffem / fem, color: const Color(0xff000000), ), ), const SizedBox(height: 10), CustomTextFormField( hintText: 'E.g. 120', customController: _sys, ), ], ), const SizedBox(height: 20), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( '${AppLocalizations.of(context).vitalDiastole}:', style: TextStyle( fontFamily: 'Nunito', fontSize: 15.9101114273 * ffem, fontWeight: FontWeight.w600, height: 1.3625 * ffem / fem, color: const Color(0xff000000), ), ), const SizedBox(height: 10), CustomTextFormField( hintText: 'E.g. 80', customController: _dias, ), // Show digestion wellbeing value -abc123 ], ), ], ), Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.end, children: [ ReusableButton1( title: AppLocalizations.of(context).vitalsDetailAddNewEntry, onPressed: () async { if (_dateC.text.isEmpty || _dias.text.isEmpty || _sys.text.isEmpty) { showDialog( context: context, barrierDismissible: false, // user must tap button! builder: (BuildContext context) { return BlurryDialog( title: AppLocalizations.of(context) .vitalErrorTitleAddData, message: AppLocalizations.of(context) .vitalErrorMessageAddData, positiveBtnText: 'Okay', onPostivePressed: () { context.pop(); }, ); }); } else { ref .read( vitalComplexBloodPressureDataNotifierProvider .notifier) .addEntry('${_dateC.text} ${_timeC.text}', int.parse(_sys.text), int.parse(_dias.text)); Navigator.pop(context); } }, ), const SizedBox(height: 16), ReusableButton2( title: AppLocalizations.of(context).cancel, onPressed: () { Navigator.pop(context); }, ), ], ), ) ], ), ), ), ); } } ```

The Week before it worked perfectly. But now i cant find a reason why it's not working anymore. code in the product in mostly the same.

koukibadr commented 11 months ago

A new version has been published with the fix of this bug the new version 2.3.3 is available on pub.dev this issue is related to https://github.com/koukibadr/Bottom-Picker/issues/80 if the new version works well on your side feel free to close this issue