@@ -94,12 +94,9 @@ abstract class PackageMeta {
9494
9595 /// Use this instead of fromDir where possible.
9696 factory PackageMeta .fromElement (
97- LibraryElement libraryElement, DartdocOptionContext config) {
98- // [config] is only here for sdkDir, and it's OK that it is the wrong
99- // context since sdkDir is argOnly and this is supposed to be a temporary
100- // workaround.
97+ LibraryElement libraryElement, String sdkDir) {
10198 if (libraryElement.isInSdk) {
102- return PackageMeta .fromDir (Directory (config. sdkDir));
99+ return PackageMeta .fromDir (Directory (sdkDir));
103100 }
104101 return PackageMeta .fromDir (
105102 File (path.canonicalize (libraryElement.source.fullName)).parent);
@@ -173,7 +170,7 @@ abstract class PackageMeta {
173170
174171 bool get requiresFlutter;
175172
176- void runPubGet ();
173+ void runPubGet (String flutterRoot );
177174
178175 String get name;
179176
@@ -279,16 +276,24 @@ class _FilePackageMeta extends PackageMeta {
279276
280277 @override
281278 bool get needsPubGet =>
282- ! (File (path.join (dir.path, '.packages' )).existsSync ());
279+ ! (File (path.join (dir.path, '.dart_tool' , 'package_config.json' ))
280+ .existsSync ());
283281
284282 @override
285- void runPubGet () {
286- String pubPath =
287- path.join (path.dirname (Platform .resolvedExecutable), 'pub' );
288- if (Platform .isWindows) pubPath += '.bat' ;
283+ void runPubGet (String flutterRoot) {
284+ String binPath;
285+ List <String > parameters;
286+ if (requiresFlutter) {
287+ binPath = path.join (flutterRoot, 'bin' , 'flutter' );
288+ parameters = ['pub' , 'get' ];
289+ } else {
290+ binPath = path.join (path.dirname (Platform .resolvedExecutable), 'pub' );
291+ parameters = ['get' ];
292+ }
293+ if (Platform .isWindows) binPath += '.bat' ;
289294
290295 ProcessResult result =
291- Process .runSync (pubPath, [ 'get' ] , workingDirectory: dir.path);
296+ Process .runSync (binPath, parameters , workingDirectory: dir.path);
292297
293298 var trimmedStdout = (result.stdout as String ).trim ();
294299 if (trimmedStdout.isNotEmpty) {
@@ -385,7 +390,7 @@ class _SdkMeta extends PackageMeta {
385390 bool get isSdk => true ;
386391
387392 @override
388- void runPubGet () {
393+ void runPubGet (String flutterRoot ) {
389394 throw 'unsupported operation' ;
390395 }
391396
0 commit comments