flr 3.1.0 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0b4e690c98b54e5cb00ed7136585e7d86d47b14a499fff89b8c607faf750cfb7
4
- data.tar.gz: 5a7335ddb9a37e4d94aee57ce86d291ea971d9ead763663f91c355210b07e0a2
3
+ metadata.gz: 316ebc8040b9907879cfd70d48163feb0804aba01ee376b21a7cb2c3dfa84347
4
+ data.tar.gz: a45282c1106560d8d4b0c7acb35a0f221a2e0e3fe057977aa339d78f80af43f1
5
5
  SHA512:
6
- metadata.gz: 14dd754b4e3277fc773128058f8a167501c519e056aeb18e8e7f4ae0b1eb351d88da61b0482509ef2fbe3bd378d24cbaf09f39b52d8ae8f1412b92deb25e819a
7
- data.tar.gz: 9ba05b656a9ed2c2e1c95004f1f4a0ce2e2fa1b43a0650164c3de5415f886376cb0a8bd3a3cfbda66ec5b7eccb97a960fb0fa958ee0194f06a12d71d4d683c66
6
+ metadata.gz: ff1cd35e4be19a8b82af8c27c996ab67e7d37106fd3fcc2f843ea04cb01d89a6b5a65c437308d16cf79d02c9d9b171e6e6d994393ccd05fbf2fdb735b7b9b2c4
7
+ data.tar.gz: be14c260f62e3421587569ec97f091278e98443474f3e074e7ccb1efcb6ee95d36c6293269c95c593472522859a88b487a43bac23bf77111b29d3f0200189b53
data/.gitignore CHANGED
@@ -37,4 +37,5 @@ build/
37
37
  # Local Pubspec Tests
38
38
  pubspec.yaml
39
39
  pubspec.lock
40
- .packages
40
+ .packages
41
+ .dart_tool/
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
+ ## 3.2.0
2
+
3
+ - Support for nullsafety-feature of Dart 2.12
4
+
1
5
  ## 3.1.0
2
6
 
3
- - Support for processing(init/generate/monitor) multi projects(the main project and its sub projects in one workspace)
7
+ - Support for processing (init/generate/monitor) multi projects (the main project and its sub projects in one workspace)
4
8
 
5
9
  - Support for auto merging old asset specifications when specifying new assets
6
10
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- flr (3.1.0)
4
+ flr (3.2.0)
5
5
  bundler (~> 2.0, >= 2.0.2)
6
6
  listen (~> 3.0, >= 3.2.1)
7
7
  thor (~> 1.0, >= 1.0.1)
data/lib/flr/command.rb CHANGED
@@ -154,11 +154,21 @@ Flr recommends the following flutter resource structure schemes:
154
154
  return r_dart_library_version
155
155
  end
156
156
 
157
- version_with_hotfix_str = flutter_version_result.split(" ")[1]
158
- version_without_hotfix_str = version_with_hotfix_str.split("+")[0]
157
+ flutter_version_with_hotfix_str = flutter_version_result.split(" ")[1]
158
+ flutter_version_without_hotfix_str = flutter_version_with_hotfix_str.split("+")[0]
159
159
 
160
- if Version.new(version_with_hotfix_str) >= Version.new("1.10.15")
160
+ dart_version_str = flutter_version_result.split("Dart")[1]
161
+ dart_version_str.strip!
162
+
163
+ puts("the flutter development environment is:")
164
+ puts(" - Flutter SDK Version: #{flutter_version_with_hotfix_str}")
165
+ puts(" - Dart SDK Version: #{dart_version_str}")
166
+
167
+ if Version.new(flutter_version_with_hotfix_str) >= Version.new("1.10.15")
161
168
  r_dart_library_version = "0.2.1"
169
+ if Version.new(dart_version_str) >= Version.new("2.12.0")
170
+ r_dart_library_version = "0.4.0-nullsafety.0"
171
+ end
162
172
  end
163
173
 
164
174
  return r_dart_library_version
@@ -297,14 +307,10 @@ Flr recommends the following flutter resource structure schemes:
297
307
  #
298
308
  # r_dart_library的依赖声明:
299
309
  # ```yaml
300
- # r_dart_library:
301
- # git:
302
- # url: "https://github.com/YK-Unit/r_dart_library.git"
303
- # ref: 0.1.1
310
+ # r_dart_library: 0.1.1
304
311
  # ```
305
312
  r_dart_library_version = get_r_dart_library_version
306
- r_dart_library_config = Hash["git" => Hash["url" => "https://github.com/YK-Unit/r_dart_library.git", "ref" => r_dart_library_version]]
307
- dependencies_config["r_dart_library"] = r_dart_library_config
313
+ dependencies_config["r_dart_library"] = r_dart_library_version
308
314
  pubspec_config["dependencies"] = dependencies_config
309
315
 
310
316
  puts("add flr configuration into pubspec.yaml done!")
@@ -5,6 +5,36 @@ module Flr
5
5
  # 代码生成相关的工具类方法
6
6
  class CodeUtil
7
7
 
8
+ @@should_support_nullsafety = nil
9
+
10
+ def self.should_support_nullsafety
11
+ if @@should_support_nullsafety != nil
12
+ return @@should_support_nullsafety
13
+ end
14
+
15
+ # $ flutter --version
16
+ # Flutter 1.12.13+hotfix.5 • channel stable • https://github.com/flutter/flutter.git
17
+ # Framework • revision 27321ebbad (5 weeks ago) • 2019-12-10 18:15:01 -0800
18
+ # Engine • revision 2994f7e1e6
19
+ # Tools • Dart 2.7.0
20
+ flutter_version_result = `flutter --version`
21
+ if (flutter_version_result.nil? == true || flutter_version_result.empty? == true)
22
+ @@should_support_nullsafety = false
23
+ return @@should_support_nullsafety
24
+ end
25
+
26
+ dart_version_str = flutter_version_result.split("Dart")[1]
27
+ dart_version_str.strip!
28
+
29
+ if Version.new(dart_version_str) >= Version.new("2.12.0")
30
+ @@should_support_nullsafety = true
31
+ return @@should_support_nullsafety
32
+ end
33
+
34
+ @@should_support_nullsafety = false
35
+ return @@should_support_nullsafety
36
+ end
37
+
8
38
  # generate_R_class(package_name) -> string
9
39
  #
10
40
  # 根据模板生成 R class 的代码
@@ -66,6 +96,58 @@ class R {
66
96
  /// - fileBasename:example.png
67
97
  /// - fileBasenameNoExtension:example
68
98
  /// - fileExtname:.png
99
+ CODE
100
+
101
+ if should_support_nullsafety
102
+ code += <<-CODE
103
+ class AssetResource {
104
+ /// Creates an object to hold the asset resource’s metadata.
105
+ const AssetResource(this.assetName, {this.packageName});
106
+
107
+ /// The name of the main asset from the set of asset resources to choose from.
108
+ final String assetName;
109
+
110
+ /// The name of the package from which the asset resource is included.
111
+ final String? packageName;
112
+
113
+ /// The name used to generate the key to obtain the asset resource. For local assets
114
+ /// this is [assetName], and for assets from packages the [assetName] is
115
+ /// prefixed 'packages/<package_name>/'.
116
+ String get keyName => packageName == null ? assetName : "packages/$packageName/$assetName";
117
+
118
+ /// The file basename of the asset resource.
119
+ String get fileBasename {
120
+ final basename = path.basename(assetName);
121
+ return basename;
122
+ }
123
+
124
+ /// The no extension file basename of the asset resource.
125
+ String get fileBasenameNoExtension {
126
+ final basenameWithoutExtension = path.basenameWithoutExtension(assetName);
127
+ return basenameWithoutExtension;
128
+ }
129
+
130
+ /// The file extension name of the asset resource.
131
+ String get fileExtname {
132
+ final extension = path.extension(assetName);
133
+ return extension;
134
+ }
135
+
136
+ /// The directory path name of the asset resource.
137
+ String get fileDirname {
138
+ var dirname = assetName;
139
+ if (packageName != null) {
140
+ final packageStr = "packages/$packageName/";
141
+ dirname = dirname.replaceAll(packageStr, "");
142
+ }
143
+ final filenameStr = "$fileBasename/";
144
+ dirname = dirname.replaceAll(filenameStr, "");
145
+ return dirname;
146
+ }
147
+ }
148
+ CODE
149
+ else
150
+ code += <<-CODE
69
151
  class AssetResource {
70
152
  /// Creates an object to hold the asset resource’s metadata.
71
153
  const AssetResource(this.assetName, {this.packageName}) : assert(assetName != null);
@@ -111,7 +193,8 @@ class AssetResource {
111
193
  return dirname;
112
194
  }
113
195
  }
114
- CODE
196
+ CODE
197
+ end
115
198
 
116
199
  return code
117
200
  end
@@ -426,14 +509,25 @@ class _R_Image {
426
509
  asset_id = svg_image_asset_id_dict[image_asset]
427
510
  asset_comment = generate_asset_comment(image_asset, package_name)
428
511
 
429
- g_Asset_method_code = <<-CODE
512
+ if should_support_nullsafety
513
+ g_Asset_method_code = <<-CODE
514
+ /// #{asset_comment}
515
+ // ignore: non_constant_identifier_names
516
+ AssetSvg #{asset_id}({required double width, required double height}) {
517
+ final imageProvider = AssetSvg(asset.#{asset_id}.keyName, width: width, height: height);
518
+ return imageProvider;
519
+ }
520
+ CODE
521
+ else
522
+ g_Asset_method_code = <<-CODE
430
523
  /// #{asset_comment}
431
524
  // ignore: non_constant_identifier_names
432
525
  AssetSvg #{asset_id}({@required double width, @required double height}) {
433
526
  final imageProvider = AssetSvg(asset.#{asset_id}.keyName, width: width, height: height);
434
527
  return imageProvider;
435
528
  }
436
- CODE
529
+ CODE
530
+ end
437
531
 
438
532
  all_g_Asset_method_code += g_Asset_method_code
439
533
  end
data/lib/flr/version.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  module Flr
2
2
  # 工具版本号
3
- VERSION = "3.1.0"
3
+ VERSION = "3.2.0"
4
4
 
5
5
  # 核心逻辑版本号
6
- CORE_VERSION = "3.1.0"
6
+ CORE_VERSION = "3.2.0"
7
7
 
8
8
  class Version < Array
9
9
  def initialize str
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flr
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - York
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-27 00:00:00.000000000 Z
11
+ date: 2021-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
126
  requirements: []
127
- rubygems_version: 3.0.3
127
+ rubygems_version: 3.2.13
128
128
  signing_key:
129
129
  specification_version: 4
130
130
  summary: 'Flr(Flutter-R): A Flutter Resource Manager CLI TooL.'