Skip to content

Commit 1686b6d

Browse files
authored
Remove fixed asset bundles - they're no longer used. (flutter#14729)
1 parent fe00598 commit 1686b6d

File tree

6 files changed

+1
-92
lines changed

6 files changed

+1
-92
lines changed

packages/flutter_tools/lib/src/asset.dart

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ abstract class AssetBundleFactory {
3030
}
3131

3232
abstract class AssetBundle {
33-
factory AssetBundle.fixed(String projectRoot, String projectAssets) =>
34-
new _ManifestAssetBundle.fixed(projectRoot, projectAssets);
35-
3633
Map<String, DevFSContent> get entries;
3734

3835
bool wasBuiltOnce();
@@ -66,38 +63,17 @@ class _ManifestAssetBundle implements AssetBundle {
6663
static const String _kFontSetMaterial = 'material';
6764
static const String _kLICENSE = 'LICENSE';
6865

69-
bool _fixed = false;
7066
DateTime _lastBuildTimestamp;
7167

7268
/// Constructs an [_ManifestAssetBundle] that gathers the set of assets from the
7369
/// pubspec.yaml manifest.
7470
_ManifestAssetBundle();
7571

76-
/// Constructs an [_ManifestAssetBundle] with a fixed set of assets.
77-
/// [projectRoot] The absolute path to the project root.
78-
/// [projectAssets] comma separated list of assets.
79-
_ManifestAssetBundle.fixed(String projectRoot, String projectAssets) {
80-
_fixed = true;
81-
if ((projectRoot == null) || (projectAssets == null))
82-
return;
83-
84-
final List<String> assets = projectAssets.split(',');
85-
for (String asset in assets) {
86-
if (asset == '')
87-
continue;
88-
final String assetPath = fs.path.join(projectRoot, asset);
89-
final String archivePath = asset;
90-
entries[archivePath] = new DevFSFileContent(fs.file(assetPath));
91-
}
92-
}
93-
9472
@override
9573
bool wasBuiltOnce() => _lastBuildTimestamp != null;
9674

9775
@override
9876
bool needsBuild({String manifestPath: defaultManifestPath}) {
99-
if (_fixed)
100-
return false;
10177
if (_lastBuildTimestamp == null)
10278
return true;
10379

packages/flutter_tools/lib/src/commands/daemon.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,6 @@ class AppDomain extends Domain {
350350
bool previewDart2: false,
351351
String projectRootPath,
352352
String packagesFilePath,
353-
String projectAssets,
354353
bool ipv6: false,
355354
}) async {
356355
if (await device.isLocalEmulator && !options.buildInfo.supportsEmulator) {
@@ -375,7 +374,6 @@ class AppDomain extends Domain {
375374
previewDart2: previewDart2,
376375
projectRootPath: projectRootPath,
377376
packagesFilePath: packagesFilePath,
378-
projectAssets: projectAssets,
379377
ipv6: ipv6,
380378
hostIsIde: true,
381379
);

packages/flutter_tools/lib/src/commands/run.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,6 @@ class RunCommand extends RunCommandBase {
116116
argParser.addOption('project-root',
117117
hide: !verboseHelp,
118118
help: 'Specify the project root directory.');
119-
argParser.addOption('project-assets',
120-
hide: !verboseHelp,
121-
help: 'Specify the project assets relative to the root directory.');
122119
argParser.addFlag('machine',
123120
hide: !verboseHelp,
124121
negatable: false,
@@ -260,7 +257,6 @@ class RunCommand extends RunCommandBase {
260257
previewDart2: argResults['preview-dart-2'],
261258
projectRootPath: argResults['project-root'],
262259
packagesFilePath: globalResults['packages'],
263-
projectAssets: argResults['project-assets'],
264260
ipv6: ipv6,
265261
);
266262
} catch (error) {
@@ -314,7 +310,6 @@ class RunCommand extends RunCommandBase {
314310
previewDart2: argResults['preview-dart-2'],
315311
projectRootPath: argResults['project-root'],
316312
packagesFilePath: globalResults['packages'],
317-
projectAssets: argResults['project-assets'],
318313
stayResident: stayResident,
319314
ipv6: ipv6,
320315
);

packages/flutter_tools/lib/src/resident_runner.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -413,18 +413,14 @@ abstract class ResidentRunner {
413413
this.usesTerminalUI: true,
414414
String projectRootPath,
415415
String packagesFilePath,
416-
String projectAssets,
417416
this.stayResident,
418417
this.ipv6,
419418
}) {
420419
_mainPath = findMainDartFile(target);
421420
_projectRootPath = projectRootPath ?? fs.currentDirectory.path;
422421
_packagesFilePath =
423422
packagesFilePath ?? fs.path.absolute(PackageMap.globalPackagesPath);
424-
if (projectAssets != null)
425-
_assetBundle = new AssetBundle.fixed(_projectRootPath, projectAssets);
426-
else
427-
_assetBundle = AssetBundleFactory.instance.createBundle();
423+
_assetBundle = AssetBundleFactory.instance.createBundle();
428424
}
429425

430426
final List<FlutterDevice> flutterDevices;

packages/flutter_tools/lib/src/run_hot.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ class HotRunner extends ResidentRunner {
4343
this.hostIsIde: false,
4444
String projectRootPath,
4545
String packagesFilePath,
46-
String projectAssets,
4746
bool stayResident: true,
4847
bool ipv6: false,
4948
}) : super(devices,
@@ -52,7 +51,6 @@ class HotRunner extends ResidentRunner {
5251
usesTerminalUI: usesTerminalUI,
5352
projectRootPath: projectRootPath,
5453
packagesFilePath: packagesFilePath,
55-
projectAssets: projectAssets,
5654
stayResident: stayResident,
5755
ipv6: ipv6);
5856

packages/flutter_tools/test/asset_bundle_test.dart

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import 'package:file/file.dart';
99
import 'package:flutter_tools/src/asset.dart';
1010
import 'package:flutter_tools/src/base/file_system.dart';
1111
import 'package:flutter_tools/src/cache.dart';
12-
import 'package:flutter_tools/src/devfs.dart';
1312

1413
import 'package:test/test.dart';
1514

@@ -21,59 +20,6 @@ void main() {
2120
Cache.flutterRoot = getFlutterRoot();
2221
});
2322

24-
// Fixed asset bundle tests.
25-
group('AssetBundle.fixed', () {
26-
test('empty strings', () async {
27-
expect(new AssetBundle.fixed(null, null), isNotNull);
28-
expect(new AssetBundle.fixed('', ''), isNotNull);
29-
expect(new AssetBundle.fixed(null, null).entries, isEmpty);
30-
});
31-
test('does not need a rebuild', () async {
32-
expect(new AssetBundle.fixed(null, null).needsBuild(), isFalse);
33-
});
34-
test('empty string', () async {
35-
final AssetBundle ab = new AssetBundle.fixed('', '');
36-
expect(ab.entries, isEmpty);
37-
});
38-
test('single entry', () async {
39-
final AssetBundle ab = new AssetBundle.fixed('', 'apple.txt');
40-
expect(ab.entries, isNotEmpty);
41-
expect(ab.entries.length, 1);
42-
final String archivePath = ab.entries.keys.first;
43-
expect(archivePath, isNotNull);
44-
expect(archivePath, 'apple.txt');
45-
});
46-
test('two entries', () async {
47-
final AssetBundle ab = new AssetBundle.fixed('', 'apple.txt,packages/flutter_gallery_assets/shrine/products/heels.png');
48-
expect(ab.entries, isNotEmpty);
49-
expect(ab.entries.length, 2);
50-
final List<String> archivePaths = ab.entries.keys.toList()..sort();
51-
expect(archivePaths[0], 'apple.txt');
52-
expect(archivePaths[1], 'packages/flutter_gallery_assets/shrine/products/heels.png');
53-
});
54-
55-
testUsingContext('file contents', () async {
56-
// Create a temporary directory and write a single file into it.
57-
final Directory tempDir = fs.systemTempDirectory.createTempSync();
58-
final String projectRoot = tempDir.path;
59-
const String assetPath = 'banana.txt';
60-
const String assetContents = 'banana';
61-
final File tempFile = fs.file(fs.path.join(projectRoot, assetPath));
62-
tempFile.parent.createSync(recursive: true);
63-
tempFile.writeAsBytesSync(UTF8.encode(assetContents));
64-
65-
final AssetBundle ab = new AssetBundle.fixed(projectRoot, assetPath);
66-
expect(ab.entries, isNotEmpty);
67-
expect(ab.entries.length, 1);
68-
final String archivePath = ab.entries.keys.first;
69-
final DevFSContent content = ab.entries[archivePath];
70-
expect(archivePath, assetPath);
71-
expect(assetContents, UTF8.decode(await content.contentsAsBytes()));
72-
}, overrides: <Type, Generator>{
73-
FileSystem: () => const LocalFileSystem(),
74-
});
75-
});
76-
7723
group('AssetBundle.build', () {
7824
// These tests do not use a memory file system because we want to ensure that
7925
// asset bundles work correctly on Windows and Posix systems.

0 commit comments

Comments
 (0)