build_it 0.2.8 copy "build_it: ^0.2.8" to clipboard
build_it: ^0.2.8 copied to clipboard

discontinued

The `build_it`is a builder that makes publicly available third-party source code generators and runs them during the build process for rapid development.

example/example.dart

import 'package:build_it/build_it_helper.dart';
import 'package:json_helpers/json_helpers.dart';

Future<void> main(List<String> args, [message]) async {
  return await buildIt(args, message, _build);
}

Future<BuildResult> _build(BuildConfig config) async {
  const _template = '''
void main() {
  stdout.writeln('Hello, {{NAME}}');
}
''';

  final data = config.data.json((e) => Data.fromMap(e));
  final name = data.name;
  final code = <String>[];
  final template = _template.replaceAll('{{NAME}}', name);
  code.add(template);
  final directives = <Directive>[];
  directives.add(Directive(type: 'import', url: 'dart:io'));
  return BuildResult(code: code.join('\n'), directives: directives);
}

class Data {
  final String name;

  Data({required this.name});

  factory Data.fromMap(Map<String, dynamic> json) {
    return Data(name: (json['name'] as String?) ?? '');
  }
}
1
likes
40
pub points
0%
popularity

Publisher

unverified uploader

The `build_it`is a builder that makes publicly available third-party source code generators and runs them during the build process for rapid development.

Repository (GitHub)
View/report issues

License

BSD-3-Clause (LICENSE)

Dependencies

analyzer, build, build_runner, code_builder, collection, dart_style, json_annotation, json_helpers, json_serializable, meta, path, yaml

More

Packages that depend on build_it