Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- modelChatType ctype = modelChatType.fromJson(json.decode(data));
- String j ="join";
- print(ctype.message); //OK
- if(ctype.command is String) { //Ok goes in
- print("Thsi is a string");
- }
- if(ctype.command.toString() == "join"){ //Ok goes in
- print("dssd");
- }
- if(ctype.command == j){ ///Fails : Exception
- onJoin(data);
- }
- @JsonSerializable()
- class modelChatType extends Object with _$modelChatTypeSerializerMixin {
- String command;
- String source;
- modelChatType.fromEmpty()
- {
- this.command = null;
- this.source= null;
- }
- modelChatType(
- this.command,
- this.source,
- );
- factory modelChatType.fromJson(Map<String, dynamic> json) =>
- _$modelChatTypeFromJson(json);
- }
- if(ctype.command == j){ ///Fails : Exception
- onJoin(data);
- }
- Exception :
- Type 'String' is not a subtype of type 'modelChatType'
- #0 ChatManager.onMessage (package:insta_gig/Managers/chatManager.dart:60:20)
- #1 _RootZone.runUnaryGuarded (dart:async/zone.dart:1316:10)
- #2 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:330:11)
- #3 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:257:7)
Add Comment
Please, Sign In to add comment