clean(packages): apply dart fix (close #106)
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
This commit was merged in pull request #107.
This commit is contained in:
@@ -115,7 +115,7 @@ Future<void> server() async {
|
||||
final server = await HttpServer.bind(InternetAddress.anyIPv6, 8080);
|
||||
var error = 0;
|
||||
var token = 0;
|
||||
await server.forEach((HttpRequest request) {
|
||||
await server.forEach((request) {
|
||||
print('[${request.method}] ${request.uri}');
|
||||
switch (request.uri.path) {
|
||||
case '/test/basic-test':
|
||||
@@ -196,7 +196,7 @@ Future<void> server() async {
|
||||
|
||||
Future<void> main() async {
|
||||
unawaited(server());
|
||||
final base = 'localhost:8080';
|
||||
const base = 'localhost:8080';
|
||||
final uriPrefix = UriPrefixMiddleware(
|
||||
protocol: Protocols.http,
|
||||
authority: base,
|
||||
|
||||
@@ -31,19 +31,15 @@ enum EmailVerificationAction {
|
||||
resetPassword,
|
||||
changeEmail;
|
||||
|
||||
String toSnakeCase() {
|
||||
return name.splitMapJoin(
|
||||
String toSnakeCase() => name.splitMapJoin(
|
||||
RegExp('[A-Z]'),
|
||||
onMatch: (m) => '_${m[0]?.toLowerCase()}',
|
||||
onNonMatch: (n) => n,
|
||||
);
|
||||
}
|
||||
|
||||
factory EmailVerificationAction.fromString(String str) {
|
||||
return EmailVerificationAction.values.firstWhere(
|
||||
(EmailVerificationAction element) => element.toSnakeCase() == str,
|
||||
factory EmailVerificationAction.fromString(String str) => EmailVerificationAction.values.firstWhere(
|
||||
(element) => element.toSnakeCase() == str,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class VerifyCode {
|
||||
@@ -60,29 +56,23 @@ class VerifyCode {
|
||||
String? email,
|
||||
String? verificationCode,
|
||||
EmailVerificationAction? action,
|
||||
}) {
|
||||
return VerifyCode(
|
||||
}) => VerifyCode(
|
||||
email: email ?? this.email,
|
||||
verificationCode: verificationCode ?? this.verificationCode,
|
||||
action: action ?? this.action,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return <String, dynamic>{
|
||||
Map<String, dynamic> toMap() => <String, dynamic>{
|
||||
'email': email,
|
||||
'verification_code': verificationCode,
|
||||
'action': action.toSnakeCase(),
|
||||
};
|
||||
}
|
||||
|
||||
factory VerifyCode.fromMap(Map<String, dynamic> map) {
|
||||
return VerifyCode(
|
||||
factory VerifyCode.fromMap(Map<String, dynamic> map) => VerifyCode(
|
||||
email: map['email'] as String,
|
||||
verificationCode: map['verification_code'] as String,
|
||||
action: EmailVerificationAction.fromString(map['action'] as String),
|
||||
);
|
||||
}
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
@@ -105,26 +95,20 @@ class Account {
|
||||
Account copyWith({
|
||||
String? email,
|
||||
String? sessionId,
|
||||
}) {
|
||||
return Account(
|
||||
}) => Account(
|
||||
email: email ?? this.email,
|
||||
sessionId: sessionId ?? this.sessionId,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return <String, dynamic>{
|
||||
Map<String, dynamic> toMap() => <String, dynamic>{
|
||||
'email': email,
|
||||
'session_id': sessionId,
|
||||
};
|
||||
}
|
||||
|
||||
factory Account.fromMap(Map<String, dynamic> map) {
|
||||
return Account(
|
||||
factory Account.fromMap(Map<String, dynamic> map) => Account(
|
||||
email: map['email'] as String,
|
||||
sessionId: map['session_id'] != null ? map['session_id'] as String : null,
|
||||
);
|
||||
}
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
@@ -146,26 +130,20 @@ class SignUp {
|
||||
SignUp copyWith({
|
||||
String? sessionId,
|
||||
String? password,
|
||||
}) {
|
||||
return SignUp(
|
||||
}) => SignUp(
|
||||
sessionId: sessionId ?? this.sessionId,
|
||||
password: password ?? this.password,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return <String, dynamic>{
|
||||
Map<String, dynamic> toMap() => <String, dynamic>{
|
||||
'session_id': sessionId,
|
||||
'password': password,
|
||||
};
|
||||
}
|
||||
|
||||
factory SignUp.fromMap(Map<String, dynamic> map) {
|
||||
return SignUp(
|
||||
factory SignUp.fromMap(Map<String, dynamic> map) => SignUp(
|
||||
sessionId: map['session_id'] as String,
|
||||
password: map['password'] as String,
|
||||
);
|
||||
}
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
@@ -190,29 +168,23 @@ class TokenSuccess {
|
||||
String? accessToken,
|
||||
String? refreshToken,
|
||||
Account? account,
|
||||
}) {
|
||||
return TokenSuccess(
|
||||
}) => TokenSuccess(
|
||||
accessToken: accessToken ?? this.accessToken,
|
||||
refreshToken: refreshToken ?? this.refreshToken,
|
||||
account: account ?? this.account,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return <String, dynamic>{
|
||||
Map<String, dynamic> toMap() => <String, dynamic>{
|
||||
'access_token': accessToken,
|
||||
'refresh_token': refreshToken,
|
||||
'account': account.toMap(),
|
||||
};
|
||||
}
|
||||
|
||||
factory TokenSuccess.fromMap(Map<String, dynamic> map) {
|
||||
return TokenSuccess(
|
||||
factory TokenSuccess.fromMap(Map<String, dynamic> map) => TokenSuccess(
|
||||
accessToken: map['access_token'] as String,
|
||||
refreshToken: map['refresh_token'] as String,
|
||||
account: Account.fromMap(map['account'] as Map<String, dynamic>),
|
||||
);
|
||||
}
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
@@ -235,26 +207,20 @@ class Login {
|
||||
Login copyWith({
|
||||
String? email,
|
||||
String? password,
|
||||
}) {
|
||||
return Login(
|
||||
}) => Login(
|
||||
email: email ?? this.email,
|
||||
password: password ?? this.password,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() {
|
||||
return <String, dynamic>{
|
||||
Map<String, dynamic> toMap() => <String, dynamic>{
|
||||
'email': email,
|
||||
'password': password,
|
||||
};
|
||||
}
|
||||
|
||||
factory Login.fromMap(Map<String, dynamic> map) {
|
||||
return Login(
|
||||
factory Login.fromMap(Map<String, dynamic> map) => Login(
|
||||
email: map['email'] as String,
|
||||
password: map['password'] as String,
|
||||
);
|
||||
}
|
||||
|
||||
String toJson() => json.encode(toMap());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user