Comments (8)
➤ PM Bot commented:
Jira ticket: RDART-992
from realm-dart.
Hi,
Same issue here, any workaround?
from realm-dart.
We're aware of this and will address it with a future release. Currently, the only known mitigation is to downgrade to 1.6. I'm sorry for the regression.
from realm-dart.
Apparently -1
is not a literal to the Dart analyzer
from realm-dart.
from realm-dart.
That looks like a great improvement. Unfortunately there are still some cases that cause false errors. Here is an example:
import 'package:dart_numerics/dart_numerics.dart' as numerics;
const int myconst = 1;
@RealmModel(ObjectType.embeddedObject)
class $Test {
ObjectId id = ObjectId();
int value1 = myconst;
int value2 = numerics.int64MinValue;
}
If I comment out the new const test, this generates legal dart.
from realm-dart.
@derrickgw Thank you for your observation. I have created #1612 to handle value1
and value2
.
But this const check was added explicitly to disallow ObjectId id = ObjectId()
, so that is still not allowed.
Consider:
@RealmModel()
class _Stuff {
ObjectId id = ObjectId();
}
Which is legal with realm_generator
1.9.0. If you look at the generated class, you will find that is illegal because it lifts the initializer expression and uses it as the default value of the optional parameter id
on the generated constructor.
Stuff({
ObjectId id = ObjectId(), // <-- this is not valid Dart, as default values must be const
}) {
from realm-dart.
Wow. That was super fast. Thanks.
I see now that ObjectId has a constructor body, and calls DateTime.now(), so it can't really become a const class.
The previous database code generator I migrated from had a different paradigm that generated a Schema class instead of a child class, which allowed non-const default values, but had other limitations.
from realm-dart.
Related Issues (20)
- fromEjson() throws "Missing decoder for type Set" HOT 1
- Expose sync client timeout options HOT 1
- _openRealmLib fails for dart compile to exe HOT 1
- realm >=3.3.0 depends on realm_dart ^3.3.0 which depends on http ^1.0.0, HOT 7
- Add Swift Package Manager support HOT 1
- Re-work mono-repo structure to use pub workspaces HOT 1
- Running testing with realm work on local machine but not in CI/CD HOT 2
- Flutter 3.24 android:attr/lStar not found HOT 3
- Schemas cannot be created automatically in development mode HOT 2
- realm_dart-3.4.0/lib/src/handles/native/init.dart:155:12: Error: Method not found: 'DBRef'. HOT 7
- Realm is closed but deleteRealm() errors out HOT 5
- Problems with DeviceSync - does not load complete data from the database HOT 2
- Realm.open hangs HOT 3
- I/flutter ( 7604): Failed to initialize SharedPreferences: PlatformException(channel-error, Unable to establish connection on channel: "dev.flutter.pigeon.shared_preferences_android.SharedPreferencesApi.getAll"., null, null) HOT 3
- Realm error : Realm SDK package version does not match the native library version (3.4.1 != 3.3.0). HOT 3
- :realm:verifyReleaseResources HOT 6
- OAuth2.0 Google not working HOT 2
- Add JSON encoding support for ObjectId HOT 2
- Atlas Services HOT 4
- RealmException: Unsupported instruction. Error code: 1000 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from realm-dart.