made captcha json-serializable

This commit is contained in:
shilangyu 2020-08-10 12:22:28 +00:00
parent 3aa92f695d
commit 101c7c4afc
1 changed files with 13 additions and 1 deletions

View File

@ -1,10 +1,22 @@
import 'package:flutter/material.dart';
part 'captcha.g.dart';
/// based on https://dev.lemmy.ml/docs/contributing_websocket_http_api.html#get-captcha
@JsonSerializable(fieldRename: FieldRename.snake, createToJson: false)
class Captcha {
final String png;
/// can be null
final String wav;
final String uuid;
Captcha({@required this.png, this.wav, @required this.uuid});
const Captcha({
this.png,
this.wav,
this.uuid
});
factory Captcha.fromJson(Map<String, dynamic> json) =>
_$CaptchaFromJson(json);
}