Guest User

Untitled

a guest
Jun 18th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. modelChatType ctype = modelChatType.fromJson(json.decode(data));
  2. String j ="join";
  3.  
  4. print(ctype.message); //OK
  5.  
  6. if(ctype.command is String) { //Ok goes in
  7. print("Thsi is a string");
  8. }
  9. if(ctype.command.toString() == "join"){ //Ok goes in
  10. print("dssd");
  11. }
  12.  
  13. if(ctype.command == j){ ///Fails : Exception
  14. onJoin(data);
  15. }
  16.  
  17. @JsonSerializable()
  18. class modelChatType extends Object with _$modelChatTypeSerializerMixin {
  19. String command;
  20. String source;
  21.  
  22. modelChatType.fromEmpty()
  23. {
  24. this.command = null;
  25. this.source= null;
  26. }
  27.  
  28. modelChatType(
  29. this.command,
  30. this.source,
  31. );
  32.  
  33. factory modelChatType.fromJson(Map<String, dynamic> json) =>
  34. _$modelChatTypeFromJson(json);
  35. }
  36.  
  37. if(ctype.command == j){ ///Fails : Exception
  38. onJoin(data);
  39. }
  40.  
  41. Exception :
  42. Type 'String' is not a subtype of type 'modelChatType'
  43. #0 ChatManager.onMessage (package:insta_gig/Managers/chatManager.dart:60:20)
  44. #1 _RootZone.runUnaryGuarded (dart:async/zone.dart:1316:10)
  45. #2 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:330:11)
  46. #3 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:257:7)
Add Comment
Please, Sign In to add comment