build method Null safety

  1. @override
Future<FutureOr<void>> build(
  1. BuildStep buildStep
)
override

Generates the outputs for a given BuildStep.

Implementation

@override
Future<FutureOr<void>> build(BuildStep buildStep) async {
  DocumentationModel model =
      await buildStep.fetchResource<DocumentationModel>(resource);
  for (var markdownPage in model.markdownPages) {
    try {
      AssetId assetId = markdownPage.destinationFilePath.toAssetId();
      FutureOr<String> contents = markdownPage.toString();
      buildStep.writeAsString(assetId, contents);
    } on Exception catch (e) {
      print(
          'Could not write file: ${markdownPage.destinationFilePath}, $e');
    }
  }
}