File tree 16 files changed +69
-28
lines changed
example/link/package_with_assets 16 files changed +69
-28
lines changed Original file line number Diff line number Diff line change 2
2
3
3
- Fix some more cases of: ` BuildConfig.dependencies ` and
4
4
` LinkConfig.dependencies ` no longer have to specify Dart sources.
5
- - ` DataAsset ` test projects report all assets from ` assets/ ` dir.
5
+ - ` DataAsset ` test projects report all assets from ` assets/ ` dir and default the
6
+ asset names to the path inside the package.
6
7
7
8
## 0.8.1
8
9
Original file line number Diff line number Diff line change @@ -50,11 +50,20 @@ void main() async {
50
50
timeout: longTimeout,
51
51
() async {
52
52
await inTempDir ((tempUri) async {
53
- // From package:complex_link_helper
54
- const builtHelperAssets = ['data_helper_0' , 'data_helper_1' ];
55
- const helperAssetsForLinking = ['data_helper_2' , 'data_helper_3' ];
56
- // From package:complex_link
57
- const mainAssetsForLinking = ['data_0' , 'data_1' ];
53
+ // From package:complex_link_helper.
54
+ const builtHelperAssets = [
55
+ 'assets/data_helper_0.json' ,
56
+ 'assets/data_helper_1.json' ,
57
+ ];
58
+ const helperAssetsForLinking = [
59
+ 'assets/data_helper_2.json' ,
60
+ 'assets/data_helper_3.json' ,
61
+ ];
62
+ // From package:complex_link.
63
+ const mainAssetsForLinking = [
64
+ 'assets/data_0.json' ,
65
+ 'assets/data_1.json' ,
66
+ ];
58
67
final assetsForLinking = [
59
68
...helperAssetsForLinking,
60
69
...mainAssetsForLinking,
Original file line number Diff line number Diff line change @@ -58,11 +58,20 @@ void main() async {
58
58
timeout: longTimeout,
59
59
() async {
60
60
await inTempDir ((tempUri) async {
61
- // From package:complex_link_helper
62
- const builtHelperAssets = ['data_helper_0' , 'data_helper_1' ];
63
- const helperAssetsForLinking = ['data_helper_2' , 'data_helper_3' ];
64
- // From package:complex_link
65
- const mainAssetsForLinking = ['data_0' , 'data_1' ];
61
+ // From package:complex_link_helper.
62
+ const builtHelperAssets = [
63
+ 'assets/data_helper_0.json' ,
64
+ 'assets/data_helper_1.json' ,
65
+ ];
66
+ const helperAssetsForLinking = [
67
+ 'assets/data_helper_2.json' ,
68
+ 'assets/data_helper_3.json' ,
69
+ ];
70
+ // From package:complex_link.
71
+ const mainAssetsForLinking = [
72
+ 'assets/data_0.json' ,
73
+ 'assets/data_1.json' ,
74
+ ];
66
75
final assetsForLinking = [
67
76
...helperAssetsForLinking,
68
77
...mainAssetsForLinking,
Original file line number Diff line number Diff line change @@ -18,8 +18,12 @@ void main(List<String> args) async {
18
18
if (dataAsset is ! File ) {
19
19
continue ;
20
20
}
21
- final fileName = dataAsset.uri.pathSegments.last;
22
- final name = fileName.split ('.' ).first;
21
+
22
+ // The file path relative to the package root, with forward slashes.
23
+ final name = dataAsset.uri
24
+ .toFilePath (windows: false )
25
+ .substring (config.packageRoot.toFilePath (windows: false ).length);
26
+
23
27
output.addAsset (
24
28
DataAsset (
25
29
package: packageName,
Original file line number Diff line number Diff line change @@ -12,4 +12,4 @@ void main(List<String> args) async {
12
12
}
13
13
14
14
Iterable <Asset > treeshake (Iterable <Asset > assets) =>
15
- assets.where ((asset) => ! asset.id.endsWith ('data_helper_2' ));
15
+ assets.where ((asset) => ! asset.id.endsWith ('assets/ data_helper_2.json ' ));
Original file line number Diff line number Diff line change @@ -18,8 +18,12 @@ void main(List<String> args) async {
18
18
if (dataAsset is ! File ) {
19
19
continue ;
20
20
}
21
- final fileName = dataAsset.uri.pathSegments.last;
22
- final name = fileName.split ('.' ).first;
21
+
22
+ // The file path relative to the package root, with forward slashes.
23
+ final name = dataAsset.uri
24
+ .toFilePath (windows: false )
25
+ .substring (config.packageRoot.toFilePath (windows: false ).length);
26
+
23
27
final forLinking = name.contains ('2' ) || name.contains ('3' );
24
28
output.addAsset (
25
29
DataAsset (
Original file line number Diff line number Diff line change 85
85
- simple_link/hook/link.dart
86
86
- simple_link/pubspec.yaml
87
87
- simple_data_asset/pubspec.yaml
88
- - simple_data_asset/asset /test_asset.txt
88
+ - simple_data_asset/assets /test_asset.txt
89
89
- simple_data_asset/README.md
90
90
- simple_data_asset/hook/build.dart
91
91
- simple_data_asset/bin/simple_data_asset.dart.debug
File renamed without changes.
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ Future<void> main(List<String> args) async {
10
10
11
11
// Expect this to throw
12
12
Future<String> getWorld() async {
13
- const asset = ByteAsset('package:simple_data_asset/test_asset.txt');
13
+ const asset = ByteAsset('package:simple_data_asset/assets/ test_asset.txt');
14
14
final byteBuffer = await asset.load();
15
15
byteBuffer.buffer.asFloat32List()[0] = 1.0;
16
16
return String.fromCharCodes(byteBuffer);
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ Future<void> main(List<String> args) async {
10
10
11
11
// Expect this to throw
12
12
Future<String> getWorld() async {
13
- const asset = ByteAsset('package:simple_data_asset/test_asset.txt');
13
+ const asset = ByteAsset('package:simple_data_asset/assets/ test_asset.txt');
14
14
final byteBuffer = await asset.load();
15
15
byteBuffer[0] = 42;
16
16
return String.fromCharCodes(byteBuffer);
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ Future<void> main(List<String> args) async {
8
8
}
9
9
10
10
Future<String> getWorld() async {
11
- const asset = ByteAsset('package:simple_data_asset/test_asset.txt');
11
+ const asset = ByteAsset('package:simple_data_asset/assets/ test_asset.txt');
12
12
final byteBuffer = await asset.load();
13
13
return String.fromCharCodes(byteBuffer);
14
14
}
Original file line number Diff line number Diff line change @@ -18,7 +18,12 @@ void main(List<String> args) async {
18
18
if (dataAsset is ! File ) {
19
19
continue ;
20
20
}
21
- final name = dataAsset.uri.pathSegments.last;
21
+
22
+ // The file path relative to the package root, with forward slashes.
23
+ final name = dataAsset.uri
24
+ .toFilePath (windows: false )
25
+ .substring (config.packageRoot.toFilePath (windows: false ).length);
26
+
22
27
output.addAsset (
23
28
DataAsset (
24
29
package: config.packageName,
Original file line number Diff line number Diff line change @@ -18,8 +18,12 @@ void main(List<String> args) async {
18
18
if (dataAsset is ! File ) {
19
19
continue ;
20
20
}
21
- final fileName = dataAsset.uri.pathSegments.last;
22
- final name = fileName.split ('.' ).first;
21
+
22
+ // The file path relative to the package root, with forward slashes.
23
+ final name = dataAsset.uri
24
+ .toFilePath (windows: false )
25
+ .substring (config.packageRoot.toFilePath (windows: false ).length);
26
+
23
27
output.addAsset (
24
28
DataAsset (
25
29
package: packageName,
Original file line number Diff line number Diff line change 2
2
3
3
- Fix some more cases of: ` BuildConfig.dependencies ` and
4
4
` LinkConfig.dependencies ` no longer have to specify Dart sources.
5
- - ` DataAsset ` examples report all assets from ` assets/ ` dir.
5
+ - ` DataAsset ` examples report all assets from ` assets/ ` dir and default the
6
+ asset names to the path inside the package.
6
7
7
8
## 0.7.2
8
9
Original file line number Diff line number Diff line change @@ -18,8 +18,12 @@ void main(List<String> args) async {
18
18
if (dataAsset is ! File ) {
19
19
continue ;
20
20
}
21
- final fileName = dataAsset.uri.pathSegments.last;
22
- final name = fileName.split ('.' ).first;
21
+
22
+ // The file path relative to the package root, with forward slashes.
23
+ final name = dataAsset.uri
24
+ .toFilePath (windows: false )
25
+ .substring (config.packageRoot.toFilePath (windows: false ).length);
26
+
23
27
output.addAsset (
24
28
DataAsset (
25
29
package: packageName,
Original file line number Diff line number Diff line change @@ -6,8 +6,8 @@ import 'package:meta/meta.dart';
6
6
7
7
//TODO: Actually use the assets, needs the AssetBundle interface for Dart. See
8
8
//also https://github.com/dart-lang/sdk/issues/54003.
9
- @ResourceIdentifier ('used_asset' )
9
+ @ResourceIdentifier ('assets/ used_asset.json ' )
10
10
String someMethod () => 'Using used_asset' ;
11
11
12
- @ResourceIdentifier ('unused_asset' )
12
+ @ResourceIdentifier ('assets/ unused_asset.json ' )
13
13
String someOtherMethod () => 'Using unused_asset' ;
You can’t perform that action at this time.
0 commit comments