Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OnSubmit in Timerpicker not working with flutter 3.16 #79

Open
janlueders opened this issue Nov 22, 2023 · 1 comment
Open

OnSubmit in Timerpicker not working with flutter 3.16 #79

janlueders opened this issue Nov 22, 2023 · 1 comment
Assignees

Comments

@janlueders
Copy link

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<AddBloodPresure> createState() => _AddBloodPresureState();
}
​
class _AddBloodPresureState extends ConsumerState<AddBloodPresure> {
  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<void>(
                              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 koukibadr added the bug Something isn't working label Nov 25, 2023
@koukibadr koukibadr self-assigned this Dec 10, 2023
@koukibadr
Copy link
Owner

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 #80
if the new version works well on your side feel free to close this issue

@koukibadr koukibadr assigned janlueders and unassigned koukibadr Dec 10, 2023
@koukibadr koukibadr removed the bug Something isn't working label Dec 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants