FlutterFlow / flutterflow-issues

A community issue tracker for FlutterFlow.
115 stars 19 forks source link

Date Time Format gets error when datetime was null #3659

Open ryutosh opened 3 weeks ago

ryutosh commented 3 weeks ago

Can we access your project?

Current Behavior

When trying to "Date Time Format" Option on datetime field and it was null, gets runtime error.

However FlutterFlow Util's code accepts null as in bellow(1), but generated code(2) forces null.

  1. FlutterFlow Utils String dateTimeFormat(String format, DateTime? dateTime, {String? locale}) { if (dateTime == null) { return ''; } ... }
  2. Generated Code Text(dateTimeFormat("yMMMd",equipmentEquipmentsRecord.firstUseDate!, locale: FFLocalizations.of(context).languageCode,)

Expected Behavior

Returns "" when it was null as in FlutterFlow utils.

Steps to Reproduce

  1. Create firestore document that has datetime field
  2. Set widget using 1 and set option "Date Time Format"

Reproducible from Blank

Bug Report Code (Required)

ITEehfKB35ZJpbwG1c7qcsJWiQMxJ1gjbJ0vhMIaUUoYB5TyPLMXbuvTP1JbQu2ZTG5cC078+T0JwvDMieLqG/YFNS2EQ5RO1s19Ez3LXn6gRLa3BZG0Z0ZDL+dTGnLD0Ka7iCUlFMZuWk0tig/GSw==

Visual documentation

Widget image

Error image

Environment

- FlutterFlow version: 4.1.83
- Platform: Mac
- Browser name and version: Chrome
- Operating system and version affected: Mac OS Sonoma

Additional Information

No response

Alezanello commented 3 weeks ago

Hi there!

To prevent this issue, you can use conditional visibility to hide the widget, ensuring it doesn't get built when unnecessary. Additionally, setting a default value in the section you shared can help with null safety, which is crucial to avoid red screen errors.

image.png
ryutosh commented 3 weeks ago

@Alezanello Thanks for your response.

To prevent this issue, you can use conditional visibility to hide the widget, ensuring it doesn't get built when unnecessary.

Yes, I know. But it is so unproductive and I am avoiding it with my custom function, not FF's.

Additionally, setting a default value in the section you shared can help with null safety, which is crucial to avoid red screen errors.

No, this default value affects when the response of DateTimeFormat was null, not filed was null. And I already set empty string (invisible in capture).

github-actions[bot] commented 2 weeks ago

This issue is stale because it has been open for 7 days with no activity. If there are no further updates, a team member will close the issue.

Alezanello commented 1 week ago

Hello,

I apologize for the late response. Does this issue still persist, or was it fixed in the latest FlutterFlow updates?