Files
Hacki/lib/models/user.dart
Jiaqi Feng 9312c56dd0 v0.2.17 (#47)
* improved story screen scrolling.

* bumped version.

* shrink instead of return on tapping back button. #42

* allowed users to view other user's profile. #45

* bumped version.

* added back underline to links.

* fixed overlow of popup menu,
2022-06-10 02:10:23 -07:00

47 lines
1.1 KiB
Dart

import 'dart:convert';
import 'package:intl/intl.dart';
class User {
User({
required this.about,
required this.created,
required this.delay,
required this.id,
required this.karma,
});
User.empty()
: about = '',
created = 0,
delay = 0,
id = '',
karma = 0;
User.fromJson(Map<String, dynamic> json)
: about = json['about'] as String? ?? '',
created = json['created'] as int? ?? 0,
delay = json['delay'] as int? ?? 0,
id = json['id'] as String? ?? '',
karma = json['karma'] as int? ?? 0;
final String about;
final int created;
final int delay;
final String id;
final int karma;
static final DateFormat _dateTimeFormatter = DateFormat.yMMMd();
String get description {
return '''$karma karma, created on ${_dateTimeFormatter.format(DateTime.fromMillisecondsSinceEpoch(created * 1000))}''';
}
@override
String toString() {
final String prettyString =
const JsonEncoder.withIndent(' ').convert(this);
return 'User $prettyString';
}
}