VeryGoodOpenSource / formz

A unified form representation in Dart used at Very Good Ventures 🦄

Home Page:https://pub.dev/packages/formz

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pure for DateTime not working

uouo690 opened this issue · comments

Hello ,

`class DateInput extends FormzInput<DateTime, DateValidationError> {
const DateInput.pure() : super.pure(null);
const DateInput.dirty(DateTime value) : super.dirty(value);

@OverRide
DateValidationError? validator(DateTime value) {
return null;
}
}`

this code get me an error indicating that The argument type 'Null' can't be assigned to the parameter type 'DateTime'

How can I pure DateTime currently.

You should change the

DateTime

to

DateTime?

Sorry but which DateTime I should change ??

I edited DateValidationError? validator(DateTime value) to be DateValidationError? validator(DateTime? value) , but it still not accepting null .

The error still the same , The argument type 'Null' can't be assigned to the parameter type 'DateTime'

If there is any other way to pure DateTime please let me know

class DateInput extends FormzInput<DateTime?, DateValidationError> {
  const DateInput.pure() : super.pure(null);
  const DateInput.dirty(DateTime value) : super.dirty(value);

  @override
  DateValidationError? validator(DateTime? value) {
    return null;
  }
}

Yes , I tried that ,but it gave me this error.

`Error: The value 'null' can't be assigned to the parameter type 'DateTime' because 'DateTime' is not nullable.

  • 'DateTime' is from 'dart:core'.
    const PaymentDateInput.pure() : super.pure(null);
    `

This is part of pubspec.yaml

`version: 1.0.0+1

environment:
sdk: ">=2.12.0 <3.0.0"

dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
cupertino_icons: ^1.0.2
dart_json_mapper: ^2.0.7
dart_json_mapper_flutter: ^2.0.0
datetime_picker_formfield: ^2.0.0
equatable: ^2.0.0
flutter_bloc: ^7.0.0
flutter_secure_storage: ^4.1.0
formz: ^0.4.0
graphs: ^1.0.0
http: ^0.13.1
url_launcher: ^6.0.3

dependency_overrides:
glob: ^2.0.1
reflectable: ^3.0.1
intl: ^0.17.0

dev_dependencies:
flutter_test:
sdk: flutter
build_runner: ^1.11.5`

image

Are you serious?
You haven't copied my entire code.
I changed it on two places.

Sorry , forgive me I didn't notice the first change.
It works thanks