Pub Package


Build your app config via code generation from .json files. Type-Safe and no unnecessary IO/Parsing on app-startup!


  • Avoid storing your configuration in dart files
  • Avoid reading config files from disk and parsing them at app start
  • Type safe
  • Supports String, bool, int, double and Enums

How to use

Add to your devDependencies (see example):

  build_runner: <version>
  config_builder: <version>

Define your configuration model:

part 'config.g.dart'; //use the <filename>.g.dart, where <filename> is the name of this dart file

  ConfigFile(configName: "devConfig", path: "lib/secrets/"),
  ConfigFile(configName: "testConfig", path: "lib/secrets/config.test.json"),
class Config{
  final String name;
  final int value;
  final Environment environment;

  const Config({, this.value, this.environment});

Make sure the config-class has a const constructor with exclusively named parameters. The generated code will assume that such a constructor exists.

Add your configuration-json file (must be saved in the lib/ directory):

  "name" : "devApp",
  "value": 1,
  "environment" : "Dev"

Run the code generation via

flutter packages pub run build_runner build

(flutter projects)

 pub run build_runner build 

(dart-only projects)

Now you can access your config object for example via different entry points in your app:

import 'config.dart';

void main() => printConfig(devConfig);


import 'config.dart';

void main() => printConfig(testConfig);