project

Last updated:

0 purchases

project Image
project Images
Add to Cart

Description:

project

dart_project #
The goal of this library is to parse Dart's project with a simple API.
This library can help developers who develop flutter write useful tools more easily.
Import #
dependencies:
project: $latest_version
copied to clipboard
import 'package:project/project.dart';
copied to clipboard
Usage #
See example or test.dart.
Example 1:
final package = Package.fromPath('.');

print(package.name);
print(package.version);
print(package.yamlFile.path);
print(package.isFlutter);

final deps = package.dependencies;

for(final dep in deps) {
print('${dep.name}');
}

if(package.isFlutter) {
final flutterInfo = package.flutterInfo;
print(flutterInfo.useMaterialDesign);
print(flutterInfo.haveAndroid);
}
copied to clipboard
Example 2:
like use flutter pub deps or pub deps. The output you can preview example_log.
import 'package:project/project.dart';

Set<String> names = {};

void main() {
final rootPkg = Package.fromPath('.');

printPktInfo(rootPkg, 1, false);
}

String tab(int level) {
if (level == 0) {
return '';
}

return ('| ' * (level - 1)) + '|--';
}

void printPktInfo(Package pkg, int level, [bool showInfo = true]) {
final name = pkg.name;
final ouputName = '${tab(level - 1)}${name}: ';
if (names.contains(name)) {
print('$ouputName ...');
return;
}
print('$ouputName${pkg.version}');

names.add(name);
final space = tab(level);
// print('${space}version: ${pkg.version}');
if (showInfo) {
print('${space}description: ${pkg.description}');
print('${space}local path: ${pkg.packageDir.path}');
}

for (var dependency in pkg.dependencies) {
final pkg = dependency.package;
printPktInfo(pkg, level + 1, showInfo);
}

for (var dependency in pkg.devDependencies) {
final subPkg = dependency.package;
if (subPkg == null) {
continue;
}
printPktInfo(subPkg, level + 1, showInfo);
}
}
copied to clipboard
LICENSE #
BSD 3.0 Style.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.