simolus3 / drift

Drift is an easy to use, reactive, typesafe persistence library for Dart & Flutter.
https://drift.simonbinder.eu/
MIT License
2.67k stars 372 forks source link

Format Error: `FormatException: Invalid radix-10 number` when running on Wear OS #3235

Closed Musta-Pollo closed 2 months ago

Musta-Pollo commented 2 months ago

Bug

When I run the app on Android or iPhone, it worked fine. But when I ran the same code on a wear os emulator it showed this error: FormatException: Invalid radix-10 number.

Solution

The problem was with datetime parsing. Somehow, it chose different settings for datetime parsing.

DateTimeColumn get updatedAt => dateTime().nullable()();

It was using dateTime stored in ISO format but was parsing it as a Unix timestamp.

The solution is to add this to build.yaml:

https://drift.simonbinder.eu/docs/advanced-features/builder_options/

# build.yaml. This file is quite powerful, see https://pub.dev/packages/build_config

targets:
  $default:
    builders:
      drift_dev:
        options:
          store_date_time_values_as_text: true

-- I am sharing it so that other people in the future have it easier. Enjoy this awesome package!