Skip to content

Commit 9ae0f75

Browse files
committed
Add deepCopy option
1 parent 793b979 commit 9ae0f75

File tree

9 files changed

+46
-20
lines changed

9 files changed

+46
-20
lines changed

Flutter/json_to_dart/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.5.2
2+
3+
* Add deepCopy option
4+
15
## 1.5.1
26

37
* Fix copyProperty isEmpty case

Flutter/json_to_dart/lib/l10n/app_en.arb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,6 @@
6161
"equalityMethodType":"Equality Method Type",
6262
"none":"non-generate",
6363
"official":"official",
64-
"equatable":"equatable"
64+
"equatable":"equatable",
65+
"deepCopy":"deepCopy"
6566
}

Flutter/json_to_dart/lib/l10n/app_zh.arb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,6 @@
6161
"equalityMethodType":"对比相等方法类型",
6262
"none":"不生成",
6363
"official":"官方方式",
64-
"equatable":"Equatable 的方式"
64+
"equatable":"Equatable 的方式",
65+
"deepCopy":"深复制"
6566
}

Flutter/json_to_dart/lib/l10n/app_zh_Hant.arb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,6 @@
6161
"equalityMethodType":"對比相等方法類型",
6262
"none":"不生成",
6363
"official":"官方方式",
64-
"equatable":"Equatable 的方式"
64+
"equatable":"Equatable 的方式",
65+
"deepCopy":"深複製"
6566
}

Flutter/json_to_dart/lib/models/config.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ class ConfigSetting extends Setting<ConfigSetting> {
6666
@HiveField(20)
6767
Rx<EqualityMethodType> equalityMethodType = EqualityMethodType.official.obs;
6868

69+
@HiveField(21)
70+
RxBool deepCopy = false.obs;
6971
@override
7072
Future<void> init({
7173
TypeAdapter<ConfigSetting>? adapter,

Flutter/json_to_dart/lib/models/config.g.dart

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Flutter/json_to_dart/lib/models/dart_object.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,8 @@ class DartObject extends DartProperty {
371371
typeString += '?';
372372
}
373373

374-
if (ConfigSetting().addCopyMethod.value) {
374+
if (ConfigSetting().addCopyMethod.value &&
375+
ConfigSetting().deepCopy.value) {
375376
if (!ConfigSetting().nullsafety.value || item.nullable) {
376377
copyProperty += '?';
377378
}
@@ -404,7 +405,8 @@ class DartObject extends DartProperty {
404405
}
405406
}
406407
setString += ',';
407-
if (ConfigSetting().addCopyMethod.value)
408+
if (ConfigSetting().addCopyMethod.value &&
409+
ConfigSetting().deepCopy.value)
408410
copyProperty = item.getListCopy(className: className);
409411
} else {
410412
setString = DartHelper.setProperty(

Flutter/json_to_dart/lib/pages/setting.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,18 @@ class MoreSetting extends StatelessWidget {
281281
},
282282
);
283283
}),
284+
Obx(() {
285+
return StCheckBox(
286+
title: appLocalizations.deepCopy,
287+
value: ConfigSetting().deepCopy.value,
288+
onChanged: (bool value) {
289+
if (ConfigSetting().deepCopy.value != value) {
290+
ConfigSetting().deepCopy.value = value;
291+
ConfigSetting().save();
292+
}
293+
},
294+
);
295+
}),
284296
Obx(() {
285297
return StCheckBox(
286298
title: appLocalizations.automaticCheck,

Flutter/json_to_dart/pubspec.yaml

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@ description: The tool to convert json to dart code.
1111
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
1212
# Read more about iOS versioning at
1313
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
14-
version: 1.5.1
14+
version: 1.5.2
1515

1616
environment:
17-
sdk: '>=3.5.0 <4.0.0'
17+
sdk: ">=3.5.0 <4.0.0"
1818
flutter: ">=3.24.1"
1919
dependencies:
20-
2120
# collection: any
2221
# The following adds the Cupertino Icons font to your application.
2322
# Use with the CupertinoIcons class for iOS style icons.
@@ -28,29 +27,28 @@ dependencies:
2827
flutter:
2928
sdk: flutter
3029
flutter_localizations:
31-
sdk: flutter
32-
flutter_smart_dialog: any
30+
sdk: flutter
31+
flutter_smart_dialog: any
3332
flutter_spinkit: any
3433
get: any
3534
hive: any
36-
hive_flutter: any
35+
hive_flutter: any
3736
intl: any
3837
nested: any
3938

40-
4139
# dependency_overrides:
42-
#dart_style: ^2.0.0
40+
#dart_style: ^2.0.0
4341
dev_dependencies:
4442
build_runner: any
4543
flutter_native_splash: any
4644
flutter_test:
4745
sdk: flutter
48-
# hive_generator: any
49-
# hive_generator:
46+
# hive_generator: any
47+
# hive_generator:
5048
# git:
5149
# url: https://github.com/zmtzawqlp/hive.git
5250
# path: hive_generator
53-
# hive_generator:
51+
# hive_generator:
5452
# git:
5553
# url: https://gitee.com/zmtzawqlp/hive.git
5654
# path: hive_generator
@@ -65,7 +63,7 @@ flutter:
6563
# the material Icons class.
6664
uses-material-design: true
6765
generate: true
68-
66+
6967
# fonts:
7068
# - family: Roboto
7169
# fonts:
@@ -113,4 +111,4 @@ flutter:
113111
# flutter pub run flutter_native_splash:remove
114112
flutter_native_splash:
115113
color: "#42a5f5"
116-
image: web/favicon.png
114+
image: web/favicon.png

0 commit comments

Comments
 (0)