blob: 7de23c08be74643acce877f496c8dfd9d2faf7ee [file] [edit]
// Copyright 2026 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:io';
import 'package:native_assets_cli/native_assets_cli.dart';
void main(List<String> args) async {
await build(args, (config, output) async {
// 1. Read the source file (e.g., your App Engine config)
final configFile = File('config.yaml');
final content = await configFile.readAsString();
// 2. Define the path for the generated code
// It's best to put this in 'lib/src/generated_config.dart'
final outputFile = File('lib/src/generated_config.dart');
// 3. Write the file as a raw string constant
await outputFile.writeAsString("""
// GENERATED CODE - DO NOT MODIFY BY HAND
// Generated by build.dart hook
const String configFileContent =
r\'\'\'$content\'\'\';
""");
// 4. (Optional) Tell Dart that this hook depends on the config file
// This ensures that if config.yaml changes, the hook runs again.
output.addDependency(configFile.uri);
});
}