-
Type: Bug
-
Resolution: Fixed
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
-
Labels:
What happened?
Using constant classes or negative numbers used to work for initialization. When upgrading from 1.6 to 2.0, this no longer works:
Field initializers must be constant in: package:sustain/model/data/picture.dart:19:14 ╷ 16 │ @RealmModel() 17 │ class _Example { │ ━━━━━━━━ in realm model for 'Example' ... │ 19 │ double y = -1; │ ^^ Must be const ╵ Ensure the default value for field "y" is const
Repro steps
Create a class with integer or float field and try to initialize it to a constant negative value.
Presumably this would work (or rather fail to work) with any other class that provides a const constructor.
Version
2.0.0
What Atlas Services are you using?
Local Database only
What type of application is this?
Flutter Application
Client OS and version
Linux
Code snippets
Unable to find source-code formatter for language: dart. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
@RealmModel() class _Example { double x = 0; double y = -1; int z = -1; }
Stacktrace of the exception/crash you're getting
No response
Relevant log output
Unable to find source-code formatter for language: shell. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
[SEVERE] realm:realm_generator on lib/model/data/picture.dart: Field initializers must be constant in: package:sustain/model/data/picture.dart:19:14 ╷ 16 │ @RealmModel() 17 │ class _Example { │ ━━━━━━━━ in realm model for 'Example' ... │ 19 │ double y = -1; │ ^^ Must be const ╵ Ensure the default value for field "y" is const