5
5
import 'dart:async' ;
6
6
7
7
import 'package:json_schema/json_schema.dart' ;
8
+ import 'package:meta/meta.dart' ;
8
9
import 'package:yaml/yaml.dart' ;
9
10
10
11
import 'base/file_system.dart' ;
@@ -15,11 +16,16 @@ import 'globals.dart';
15
16
class FlutterManifest {
16
17
FlutterManifest ._();
17
18
18
- /// Returns null on missing or invalid manifest
19
+ /// Returns null on invalid manifest. Returns empty manifest on missing file.
19
20
static Future <FlutterManifest > createFromPath (String path) async {
20
- return _createFromYaml (await _loadFlutterManifest (path));
21
+ if (path == null || ! fs.isFileSync (path))
22
+ return _createFromYaml (null );
23
+ final String manifest = await fs.file (path).readAsString ();
24
+ return createFromString (manifest);
21
25
}
26
+
22
27
/// Returns null on missing or invalid manifest
28
+ @visibleForTesting
23
29
static Future <FlutterManifest > createFromString (String manifest) async {
24
30
return _createFromYaml (loadYaml (manifest));
25
31
}
@@ -145,13 +151,6 @@ class FontAsset {
145
151
String toString () => '$runtimeType (asset: ${assetUri .path }, weight; $weight , style: $style )' ;
146
152
}
147
153
148
- Future <dynamic > _loadFlutterManifest (String manifestPath) async {
149
- if (manifestPath == null || ! fs.isFileSync (manifestPath))
150
- return null ;
151
- final String manifestDescriptor = await fs.file (manifestPath).readAsString ();
152
- return loadYaml (manifestDescriptor);
153
- }
154
-
155
154
Future <bool > _validate (Object manifest) async {
156
155
final String schemaPath = fs.path.join (
157
156
fs.path.absolute (Cache .flutterRoot), 'packages' , 'flutter_tools' , 'schema' ,
0 commit comments