-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8b81753
commit d8ea50b
Showing
9 changed files
with
540 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class MyDateUtil { | ||
// for getting formatted time from milliSecondsSinceEpochs String | ||
static String getFormattedTime( | ||
{required BuildContext context, required String time}) { | ||
final date = DateTime.fromMillisecondsSinceEpoch(int.parse(time)); | ||
return TimeOfDay.fromDateTime(date).format(context); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
class Message { | ||
Message({ | ||
required this.toId, | ||
required this.msg, | ||
required this.read, | ||
required this.type, | ||
required this.fromId, | ||
required this.sent, | ||
}); | ||
|
||
late final String toId; | ||
late final String msg; | ||
late final String read; | ||
late final String fromId; | ||
late final String sent; | ||
late final Type type; | ||
|
||
Message.fromJson(Map<String, dynamic> json) { | ||
toId = json['toId'].toString(); | ||
msg = json['msg'].toString(); | ||
read = json['read'].toString(); | ||
type = json['type'].toString() == Type.image.name ? Type.image : Type.text; | ||
fromId = json['fromId'].toString(); | ||
sent = json['sent'].toString(); | ||
} | ||
|
||
Map<String, dynamic> toJson() { | ||
final data = <String, dynamic>{}; | ||
data['toId'] = toId; | ||
data['msg'] = msg; | ||
data['read'] = read; | ||
data['type'] = type.name; | ||
data['fromId'] = fromId; | ||
data['sent'] = sent; | ||
return data; | ||
} | ||
} | ||
|
||
enum Type { text, image } |
Oops, something went wrong.