Skip to content

Commit 9d821f1

Browse files
authored
Add data asset test project (#1243)
* Add data asset test project * Change description * Fix gitignore * Add readme * Rename to .txt * Use .debug instead * update manifest
1 parent 739f12c commit 9d821f1

File tree

8 files changed

+62
-0
lines changed

8 files changed

+62
-0
lines changed

pkgs/native_assets_builder/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
- Use `HookConfig.targetIosSdk` and `HookConfig.targetMacosSdk` optional
44
values, and add examples to fail builds based on this.
5+
- Add data asset test project.
56

67
## 0.7.0
78

pkgs/native_assets_builder/test_data/manifest.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@
8484
- simple_link/hook/build.dart
8585
- simple_link/hook/link.dart
8686
- simple_link/pubspec.yaml
87+
- simple_data_asset/pubspec.yaml
88+
- simple_data_asset/asset/test_asset.txt
89+
- simple_data_asset/README.md
90+
- simple_data_asset/hook/build.dart
91+
- simple_data_asset/bin/simple_data_asset.dart.debug
8792
- some_dev_dep/bin/some_dev_dep.dart
8893
- some_dev_dep/pubspec.yaml
8994
- wrong_build_output_2/hook/build.dart
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# https://dart.dev/guides/libraries/private-files
2+
# Created by `dart pub`
3+
.dart_tool/
4+
bin/simple_data_asset/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This sample adds and retrieves a data asset.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
World!
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
import 'dart:asset';
5+
6+
Future<void> main(List<String> args) async {
7+
print('Hello ${await getWorld()}');
8+
}
9+
10+
Future<String> getWorld() async {
11+
const asset = ByteAsset('package:simple_data_asset/assetId');
12+
final byteBuffer = await asset.load();
13+
return String.fromCharCodes(byteBuffer.asUint8List());
14+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
import 'package:native_assets_cli/native_assets_cli.dart';
5+
6+
void main(List<String> args) => build(
7+
args,
8+
(config, output) async {
9+
output.addAsset(
10+
DataAsset(
11+
package: config.packageName,
12+
name: 'assetId',
13+
file: config.packageRoot.resolve('asset/test_asset.txt'),
14+
),
15+
);
16+
output.addDependency(config.packageRoot.resolve('hook/build.dart'));
17+
},
18+
);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: simple_data_asset
2+
description: Add and retrieve a data asset.
3+
version: 1.0.0
4+
5+
publish_to: none
6+
7+
environment:
8+
sdk: ^3.0.0
9+
10+
dependencies:
11+
logging: ^1.1.1
12+
# native_assets_cli: ^0.6.0
13+
native_assets_cli:
14+
path: ../../../native_assets_cli/
15+
16+
dev_dependencies:
17+
lints: ^3.0.0
18+
test: ^1.24.0

0 commit comments

Comments
 (0)