-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: How are we going to use statuses in Dart
/Flutter
?
#10
Comments
@LuchoTurtle the reason I assigned this to you is that you can help us understand the best way of using the |
In Flutter, parsing local final String response = await rootBundle.loadString('assets/sample.json');
final data = await json.decode(response); and declaring its location in the flutter:
assets:
- assets/sample.json However, I have a question regarding the Does it make sense to have a |
The My question stems from the fact that we did have In What I would like to have is a compile-time check that a given status |
I think you can have simple type definitions that check if a given status This type of feature was actually requested before at dart-lang/language#1294. There are some ways to do this, apparently:
However, I fail how this would be helpful to the end user. If we're doing this similarly to https://github.com/dwyl/quotes, they will just use the parsed struct. There's no chance there's a Am I missing something? Is this object value compile-time validation only useful for us? How is it needed? |
Ok. If we aren't able to do compile-time checking of the status |
To have the same set of statuses is to follow the same methodology you previously mentioned with https://github.com/dwyl/quotes - parse the JSON file and export it as objects. You use the same I wager we could do the same thing with dart: serialize the JSON and just provide the class object from the package. People will use the objects and you will still have the benefits of static types. class Quote {
String? author;
String? text;
Quote({this.author, this.text});
Quote.fromJson(Map<String, dynamic> json) {
author = json['author'];
text = json['text'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['author'] = this.author;
data['text'] = this.text;
return data;
}
}
You could try using |
@LuchoTurtle this looks good. 👌 |
@LuchoTurtle now that dwyl/quotes#97 is merged, how confident do you feel in doing something similar for this project so that we can use |
As noted in #4 (comment) I feel that
JSON
is a more versatile format for storing thestatuses
list than aList
ofElixir
Map
orStruct
...As per dwyl/product-roadmap#40 we are building a
Flutter
(Native
Mobile App) version of theMVP
that will be offline first. We needstatuses
inDart
-land so that it can be included in the compiledNative
App.We could either create a
Struct
inDart
and duplicate thestatuses
and thus have to maintain them in multiple places ...
!DRY
or
use
JSON
.The text was updated successfully, but these errors were encountered: