neursh / open-meteo-dart

A simple, fast, asynchronous Dart/Flutter client package for Open-Meteo weather APIs.
https://pub.dev/packages/open_meteo
MIT License
5 stars 3 forks source link

Unsupported operation: Int64 accessor not supported by dart2js #16

Open kirkcharlesniv opened 1 day ago

kirkcharlesniv commented 1 day ago

This error occurs when using the weather.request function

Environment: Flutter Web, using Flutter 3.24.4 package version 2.0.2

Exception:

DartError: Unsupported operation: Int64 accessor not supported by dart2js.
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 296:3  throw_
dart-sdk/lib/_internal/js_dev_runtime/private/native_typed_data.dart 483:5   getInt64]
packages/flat_buffers/flat_buffers.dart 52:40                                [_getInt64]
packages/flat_buffers/flat_buffers.dart 940:47                               read
packages/flat_buffers/flat_buffers.dart 1027:46                              vTableGet
packages/open_meteo/src/weather_api_openmeteo_sdk_generated.dart 876:42      get time
packages/open_meteo/src/response.dart 130:64                                 _deserializeMultiple
packages/open_meteo/src/response.dart 61:18                                  fromFlatBuffer
packages/open_meteo/src/apis/weather.dart 131:31                             <fn>
dart-sdk/lib/async/zone.dart 1661:54                                         runUnary
dart-sdk/lib/async/future_impl.dart 163:18                                   handleValue
dart-sdk/lib/async/future_impl.dart 861:44                                   handleValueCallback
dart-sdk/lib/async/future_impl.dart 890:13                                   _propagateToListeners
dart-sdk/lib/async/future_impl.dart 666:5                                    [_completeWithValue]
dart-sdk/lib/async/future_impl.dart 736:7                                    callback
dart-sdk/lib/async/schedule_microtask.dart 40:11                             _microtaskLoop
dart-sdk/lib/async/schedule_microtask.dart 49:5                              _startMicrotaskLoop
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 181:7           <fn>

It is failing on the weather_api_openmeteo_sdk_generated.dart VariablesWithTime.time

kirkcharlesniv commented 1 day ago

I tried a workaround by changing the time and time_end data types in VariablesWithTime to int32.

table VariablesWithTime {
  time: int32;
  time_end: int32;
  interval: int32;
  variables: [VariableWithValues];
}

then rebuild the generated file with flatc --dart -o lib/src/ weather_api.fbs

It works now and doesn’t seem to have any issues.

neursh commented 20 hours ago

Int64 is not supported in the web environment. Directly changes the behavior of the generated code to read it in Int32 would work for now.

https://github.com/dart-lang/sdk/issues/10275 https://github.com/google/flatbuffers/issues/6978