addPackage method

  1. @override
Future<Either<Failure, Unit>> addPackage(
  1. String packageNameOrIndex
)
override

Implementation

@override
Future<Either<Failure, Unit>> addPackage(String packageNameOrIndex) async {
  try {
    final packageName = dataSource.packageName(packageNameOrIndex);
    final isDev = dataSource.isDevPackageType(packageName);
    await run('dart pub add $packageName ${isDev ? '-d' : ''}');
    return const Right(unit);
  } on NotExistsResource catch (e) {
    return Left(e);
  } catch (e) {
    return Left(UnknownFailure(cause: e.toString()));
  }
}