Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: numbers casting to be compatible with wasm #395

Merged
merged 2 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class CrosswordRepository {
);

final document = snapshot.first;
final solvedWordsCount = document.data['value'] as int;
final solvedWordsCount = (document.data['value'] as num).toInt();
final newValue = solvedWordsCount + 1;

await _dbClient.update(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class PointConverter extends JsonConverter<Point<int>, Map<String, dynamic>> {
@override
Point<int> fromJson(Map<String, dynamic> json) {
return Point<int>(
json['x'] as int,
json['y'] as int,
(json['x'] as num).toInt(),
(json['y'] as num).toInt(),
);
}

Expand Down
6 changes: 3 additions & 3 deletions api/packages/jwt_middleware/lib/src/jwt.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ class JWT {
return false;
}
final nowSeconds = clock.now().millisecondsSinceEpoch ~/ 1000;
final exp = _payload['exp'] as int?;
final iat = _payload['iat'] as int?;
final exp = (_payload['exp'] as num?)?.toInt();
final iat = (_payload['iat'] as num?)?.toInt();
final aud = _payload['aud'] as String?;
final iss = _payload['iss'] as String?;
final sub = _payload['sub'] as String?;
final authTime = _payload['auth_time'] as int?;
final authTime = (_payload['auth_time'] as num?)?.toInt();
final userId = _payload['user_id'] as String?;

if (exp == null ||
Expand Down
2 changes: 1 addition & 1 deletion api/routes/board/sections/[sectionId]/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Future<Response> _onGroupPost(RequestContext request) async {
final sections = body['sections'] as List;
positions = sections
.cast<Map<String, dynamic>>()
.map((e) => (e['x'] as int, e['y'] as int))
.map((e) => ((e['x'] as num).toInt(), (e['y'] as num).toInt()))
.toList();
} catch (e) {
return Response(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class CrosswordResource {

try {
final body = jsonDecode(response.body) as Map<String, dynamic>;
final points = body['points'] as int;
final points = (body['points'] as num).toInt();
return points;
} catch (error, stackTrace) {
throw ApiClientError(
Expand Down
4 changes: 2 additions & 2 deletions packages/api_client/lib/src/resources/hint_resource.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class HintResource {
try {
final body = jsonDecode(response.body) as Map<String, dynamic>;
final hint = Hint.fromJson(body['hint'] as Map<String, dynamic>);
final maxHints = body['maxHints'] as int;
final maxHints = (body['maxHints'] as num).toInt();
return (hint, maxHints);
} catch (error, stackTrace) {
throw ApiClientError(
Expand Down Expand Up @@ -79,7 +79,7 @@ class HintResource {
final hints = (body['hints'] as List)
.map((hint) => Hint.fromJson(hint as Map<String, dynamic>))
.toList();
final maxHints = body['maxHints'] as int;
final maxHints = (body['maxHints'] as num).toInt();
return (hints, maxHints);
} catch (error, stackTrace) {
throw ApiClientError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class BoardInfoRepository {
return boardInfoCollection
.where('type', isEqualTo: 'total_words_count')
.snapshots()
.map((event) => event.docs.first.data()['value'] as int);
.map((event) => (event.docs.first.data()['value'] as num).toInt());
} catch (error, stackStrace) {
throw BoardInfoException(error, stackStrace);
}
Expand All @@ -55,7 +55,7 @@ class BoardInfoRepository {
return boardInfoCollection
.where('type', isEqualTo: 'solved_words_count')
.snapshots()
.map((event) => event.docs.first.data()['value'] as int);
.map((event) => (event.docs.first.data()['value'] as num).toInt());
} catch (error, stackStrace) {
throw BoardInfoException(error, stackStrace);
}
Expand All @@ -69,7 +69,7 @@ class BoardInfoRepository {
.get();

final data = results.docs.first.data();
return data['value'] as int;
return (data['value'] as num).toInt();
} catch (error, stackStrace) {
throw BoardInfoException(error, stackStrace);
}
Expand All @@ -83,7 +83,7 @@ class BoardInfoRepository {
.get();

final data = results.docs.first.data();
return data['value'] as double;
return (data['value'] as num).toDouble();
} catch (error, stackStrace) {
throw BoardInfoException(error, stackStrace);
}
Expand Down
Loading