hasFlutterBuildScript method

bool hasFlutterBuildScript()

Returns true if the pubspec.yaml defines a serverpod.scripts.flutter_build entry.

Implementation

bool hasFlutterBuildScript() {
  if (_rawYamlContent.isEmpty) {
    return false;
  }

  try {
    final yamlDoc = loadYaml(_rawYamlContent);
    if (yamlDoc is! YamlMap) {
      return false;
    }

    final serverpod = yamlDoc['serverpod'];
    if (serverpod is! YamlMap) {
      return false;
    }

    final scripts = serverpod['scripts'];
    if (scripts is! YamlMap) {
      return false;
    }

    return scripts.containsKey('flutter_build');
  } catch (_) {
    return false;
  }
}