flutter_oss_licenses is a tool to generate detail and better OSS license list using
Unlike the package name, it still runs with pure Dart environment :)
Adding the package name to
dev_dependencies; not to
dependencies because the package does nothing on runtime.
dev_dependencies: flutter_oss_licenses: ^2.0.1
Before executing the command, you must update your
pub get (or
pub upgrade if you want).
flutter pub get
And then, the following command generates
oss_licenses.dart on the project's
flutter pub run flutter_oss_licenses:generate.dart
The following fragment is just a part of generated
const ossLicenses = <Package>[ ... Package( name: 'dart_pubspec_licenses', description: 'A library to make it easy to extract OSS license information from Dart packages using pubspec.yaml', homepage: 'https://github.com/espresso3389/flutter_oss_licenses/tree/master/packages/dart_pubspec_licenses', repository: 'https://github.com/espresso3389/flutter_oss_licenses', authors: , version: '2.0.1', license: '''MIT License Copyright (c) 2019 Takashi Kawasaki Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.''', isMarkdown: false, isSdk: false, isDirectDependency: false, ), ... ];
For a full generated sample, see example code's oss_licenses.dart.
Command line options
The following command line generates JSON file instead of dart file:
flutter pub run flutter_oss_licenses:generate.dart -o licenses.json --json
The following table lists the acceptable options:
||Specify output file path. If the file extension is .json, --json option is implied anyway. The default output file path depends on the
||Explicitly specify project root directory that contains
||Generate JSON file rather than dart file.|
||Show the help.|
bin/generated.dart uses one or two environment variable(s) depending on your use case:
PUB_CACHEis used to determine package directory.
FLUTTER_ROOTis for Flutter projects only. If not set, Flutter SDK dependencies are simply ignored and not listed.
They are normally set by
dart run or
flutter pub run.
Report any bugs on the project's issues.