parseDart method

BentoWidget parseDart(
  1. String name,
  2. String source
)

Implementation

BentoWidget parseDart(String name, String source) {
  final parsed = parseString(content: source);

  final variants = <BentoWidgetVariant>[];
  for (final declaration in parsed.unit.declarations) {
    if (declaration is FunctionDeclaration &&
        _isVariantDeclaration(declaration)) {
      _variantValidator(declaration);
      variants.add(
        BentoWidgetVariant(
          buildFunction: declaration,
        ),
      );
    }
  }

  return BentoWidget(
    name: name,
    unit: parsed.unit,
    variants: variants,
  );
}