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

NoSuchMethodError was thrown building DatePickerWidget(dirty, state: _DatePickerWidgetState#3ec38): #102

Closed
JSBmanD opened this issue May 21, 2020 · 1 comment

Comments

@JSBmanD
Copy link

JSBmanD commented May 21, 2020

By some strange circumstances your code in examples not working in my project.

[✓] Flutter (Channel stable, v1.17.1, on Mac OS X 10.14.6 18G103, locale en-RU)

Future<void> _selectDate(BuildContext context) async {
    DatePicker.showDatePicker(
      context,
      locale: DateTimePickerLocale.en_us,
      initialDateTime: DateTime.now(),
      dateFormat: 'dd-mm-yyyy',
      onMonthChangeStartWithFirstDate: true,
      pickerTheme: DateTimePickerTheme(
        showTitle: true,
        confirm: Text('Done', style: TextStyle(color: Colors.black)),
      ),
      minDateTime: DateTime.parse(MIN_DATETIME),
      maxDateTime: DateTime.parse(MAX_DATETIME),
      onConfirm: (dateTime, List<int> index) {
        if (mounted)
          setState(() {
            selectedDate = dateTime;
            widget.controller.text = formatter.format(selectedDate);
          });
      },
    );
  }
flutter: 2010, 2021

════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
The following NoSuchMethodError was thrown building DatePickerWidget(dirty, state: _DatePickerWidgetState#3ec38):
The getter 'last' was called on null.
Receiver: null
Tried calling: last

The relevant error-causing widget was: 
  MaterialApp file:///Users/sss/Documents/Projects/sss/lib/main.dart:43:12
When the exception was thrown, this was the stack: 
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
#1      _DatePickerWidgetState._renderDatePickerColumnComponent (package:flutter_cupertino_date_picker/src/widget/date_picker_widget.dart:220:34)
#2      _DatePickerWidgetState._renderDatePickerWidget.<anonymous closure> (package:flutter_cupertino_date_picker/src/widget/date_picker_widget.dart:183:29)
#3      List.forEach (dart:core-patch/growable_array.dart:282:8)
#4      _DatePickerWidgetState._renderDatePickerWidget (package:flutter_cupertino_date_picker/src/widget/date_picker_widget.dart:180:15)
...
════════════════════════════════════════════════════════════════════════════════════════════════════
@JSBmanD
Copy link
Author

JSBmanD commented May 21, 2020

I found out that it was legacy format, changing to 'yyyy-MMMM-dd' helped.

@JSBmanD JSBmanD closed this as completed May 21, 2020
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

1 participant