@@ -6,6 +6,7 @@ import 'dart:async';
66import 'dart:io' hide ProcessException;
77
88import 'package:dartdoc/src/io_utils.dart' ;
9+ import 'package:dartdoc/src/package_meta.dart' ;
910import 'package:grinder/grinder.dart' ;
1011import 'package:io/io.dart' ;
1112import 'package:path/path.dart' as path;
@@ -759,17 +760,37 @@ Future<String> _buildPubPackageDocs(
759760 Directory (path.join (env['PUB_CACHE' ], 'hosted' , 'pub.dartlang.org' ));
760761 Directory pubPackageDir =
761762 cache.listSync ().firstWhere ((e) => e.path.contains (pubPackageName));
762- await launcher.runStreamed ('pub' , ['get' ],
763- workingDirectory: pubPackageDir.absolute.path);
764- await launcher.runStreamed (
765- Platform .resolvedExecutable,
766- [
767- '--enable-asserts' ,
768- path.join (Directory .current.absolute.path, 'bin' , 'dartdoc.dart' ),
769- '--json' ,
770- '--show-progress' ,
771- ]..addAll (dartdocParameters),
772- workingDirectory: pubPackageDir.absolute.path);
763+ if (PackageMeta .fromDir (pubPackageDir).requiresFlutter) {
764+ FlutterRepo flutterRepo =
765+ await FlutterRepo .fromExistingFlutterRepo (await cleanFlutterRepo);
766+ await launcher.runStreamed (flutterRepo.cachePub, ['get' ],
767+ environment: flutterRepo.env,
768+ workingDirectory: pubPackageDir.absolute.path);
769+ await launcher.runStreamed (
770+ flutterRepo.cacheDart,
771+ [
772+ '--enable-asserts' ,
773+ path.join (Directory .current.absolute.path, 'bin' , 'dartdoc.dart' ),
774+ '--json' ,
775+ '--link-to-remote' ,
776+ '--show-progress' ,
777+ ]..addAll (dartdocParameters),
778+ environment: flutterRepo.env,
779+ workingDirectory: pubPackageDir.absolute.path);
780+ } else {
781+ await launcher.runStreamed ('pub' , ['get' ],
782+ workingDirectory: pubPackageDir.absolute.path);
783+ await launcher.runStreamed (
784+ Platform .resolvedExecutable,
785+ [
786+ '--enable-asserts' ,
787+ path.join (Directory .current.absolute.path, 'bin' , 'dartdoc.dart' ),
788+ '--json' ,
789+ '--link-to-remote' ,
790+ '--show-progress' ,
791+ ]..addAll (dartdocParameters),
792+ workingDirectory: pubPackageDir.absolute.path);
793+ }
773794 return path.join (pubPackageDir.absolute.path, 'doc' , 'api' );
774795}
775796
0 commit comments