Skip to content

Commit

Permalink
Merge pull request #276 from superiorsd10/customize-mirai-edge-insets
Browse files Browse the repository at this point in the history
feat: Added a new way to redefine how we declare EdgeInsets
  • Loading branch information
divyanshub024 authored Feb 29, 2024
2 parents 0e013f1 + 7f03e94 commit a403f12
Show file tree
Hide file tree
Showing 24 changed files with 63 additions and 53 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions packages/mirai/lib/src/parsers/mirai_chip/mirai_chip.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,37 @@ class MiraiEdgeInsets with _$MiraiEdgeInsets {
double? bottom,
}) = _MiraiEdgeInsets;

factory MiraiEdgeInsets.fromJson(Map<String, dynamic> json) =>
_$MiraiEdgeInsetsFromJson(json);
factory MiraiEdgeInsets.fromJson(dynamic json) => _fromJson(json);

static MiraiEdgeInsets _fromJson(dynamic json) {
Map<String, dynamic> resultantJson;

if (json is num) {
resultantJson = {
"left": json,
"top": json,
"right": json,
"bottom": json
};
} else if (json is List<dynamic> && json.length == 4) {
bool allElementsNum = json.every((element) => element is num);
if (!allElementsNum) {
throw ArgumentError('Invalid input format for MiraiEdgeInsets');
}
resultantJson = {
"left": json[0],
"top": json[1],
"right": json[2],
"bottom": json[3]
};
} else if (json is Map<String, dynamic>) {
resultantJson = json;
} else {
throw ArgumentError('Invalid input format for MiraiEdgeInsets');
}

return _$MiraiEdgeInsetsFromJson(resultantJson);
}
}

extension MiraiEdgeInsetsParser on MiraiEdgeInsets? {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions packages/mirai/lib/src/parsers/mirai_tab/mirai_tab.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a403f12

Please sign in to comment.