jama5262 / jiffy

Jiffy is a Flutter (Android, IOS and Web) date time package for parsing, manipulating, querying and formatting dates
https://pub.dev/packages/jiffy
MIT License
588 stars 126 forks source link

The method 'copyWith' isn't defined for the class 'DateTime'. #225

Closed cc13com closed 1 year ago

cc13com commented 1 year ago

Describe the bug

I added jiffy: ^6.1.0 to the pubspec.yaml and import 'package:jiffy/jiffy.dart'; in one of my dart-files. When I compile my android application I run in this issue. At the moment it's just the import I did not changed my code to use jiffy so far.

: Error: The method 'copyWith' isn't defined for the class 'DateTime'.
getter.dart:7
 - 'DateTime' is from 'dart:core'.
Try correcting the name to the name of an existing method, or defining a method named 'copyWith'.
  DateTime dateTime(DateTime dateTime) => dateTime.copyWith();
                                                   ^^^^^^^^

: Error: The method 'copyWith' isn't defined for the class 'DateTime'.
manipulator.dart:73
 - 'DateTime' is from 'dart:core'.
Try correcting the name to the name of an existing method, or defining a method named 'copyWith'.
        newDateTime = dateTime.copyWith(
                               ^^^^^^^^
: Error: The method 'copyWith' isn't defined for the class 'DateTime'.
manipulator.dart:84
 - 'DateTime' is from 'dart:core'.
Try correcting the name to the name of an existing method, or defining a method named 'copyWith'.
        newDateTime = dateTime.copyWith(
                               ^^^^^^^^
.
.
.

Additional information

Flutter (Channel beta, 3.4.0-34.1.pre, on macOS 13.2.1 22D68 darwin-x64, locale de-DE)

ibrahimbroachwala commented 1 year ago

Did you find a solution for this ?

jama5262 commented 1 year ago

@ibrahimbroachwala and @cc13com Have you tried updating flutter with flutter pub upgrade and also make sure that your dart-sdk in version 2.19 and above. This is because the copyWith was introduced in version 2.19 for DateTime in the dart-sdk. You can read more about it here https://github.com/dart-lang/sdk/issues/24644#issuecomment-1285331932

cc13com commented 1 year ago

Hi @jama5262

I used Dart SDK version: 2.19.0-255.2.beta (beta) (Tue Oct 4 13:45:53 2022 +0200) on "macos_x64" until this morning and upgraded now to Dart SDK version: 3.0.0-417.2.beta (beta) (Wed Apr 19 09:44:49 2023 +0000) on "macos_x64".

Now it works. Thanks!