Skip to content

Commit

Permalink
Merge pull request #13 from woodwen/master
Browse files Browse the repository at this point in the history
支持 BoxBorder 解析(但不支持 序列化成json)
  • Loading branch information
woodwen authored Nov 3, 2021
2 parents f32844f + 6a0a0b6 commit d3a0620
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
8 changes: 4 additions & 4 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
name: async
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.6.1"
version: "2.8.1"
boolean_selector:
dependency: transitive
description:
Expand Down Expand Up @@ -49,7 +49,7 @@ packages:
name: charcode
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.0"
version: "1.3.1"
clock:
dependency: transitive
description:
Expand Down Expand Up @@ -157,7 +157,7 @@ packages:
name: meta
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.3.0"
version: "1.7.0"
octo_image:
dependency: transitive
description:
Expand Down Expand Up @@ -309,7 +309,7 @@ packages:
name: test_api
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.3.0"
version: "0.4.2"
typed_data:
dependency: transitive
description:
Expand Down
15 changes: 14 additions & 1 deletion lib/dynamic_widgets/basic/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ class DynamicWidgetUtils {
return borderSideAdapter(origin as Map?) as T?;
case BorderStyle:
return borderStyleAdapter(origin as String?) as T?;
case BoxBorder:
return boxBorderAdapter(origin as Map?) as T?;
case FontWeight:
return fontWeightAdapter(origin as String?) as T?;
case FontStyle:
Expand Down Expand Up @@ -246,6 +248,7 @@ class DynamicWidgetUtils {
return {
'color': transform(boxDecoration.color),
'borderRadius': transform(boxDecoration.borderRadius as BorderRadius?),
// 'border': transform(boxDecoration.border as BoxBorder?),
};
}

Expand All @@ -254,7 +257,8 @@ class DynamicWidgetUtils {

return BoxDecoration(
color: adapt<Color>(decorationMap['color']),
borderRadius: adapt<BorderRadius>(decorationMap['borderRadius'])
borderRadius: adapt<BorderRadius>(decorationMap['borderRadius']),
border: adapt<BoxBorder>(decorationMap['border']),
);
}

Expand Down Expand Up @@ -677,6 +681,15 @@ class DynamicWidgetUtils {
};
}

static BoxBorder? boxBorderAdapter(Map? boxBorder) {
if (boxBorder == null) return null;

return Border.all(
color: adapt(boxBorder['color']) ?? const Color(0xFF000000),
width: boxBorder['width']?.toDouble() ?? 1.0,
style: adapt(boxBorder['style']) ?? BorderStyle.solid);
}

static Radius? radiusAdapter(double? radius) {
if (radius == null) return null;

Expand Down
8 changes: 4 additions & 4 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
name: async
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.6.1"
version: "2.8.1"
boolean_selector:
dependency: transitive
description:
Expand Down Expand Up @@ -49,7 +49,7 @@ packages:
name: charcode
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.0"
version: "1.3.1"
clock:
dependency: transitive
description:
Expand Down Expand Up @@ -143,7 +143,7 @@ packages:
name: meta
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.3.0"
version: "1.7.0"
octo_image:
dependency: transitive
description:
Expand Down Expand Up @@ -295,7 +295,7 @@ packages:
name: test_api
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.3.0"
version: "0.4.2"
typed_data:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_dynamic_widgets
description: A new Flutter package project.
version: 0.0.1
version: 0.0.2
homepage:

environment:
Expand Down

0 comments on commit d3a0620

Please sign in to comment.