global_configs 1.1.2 copy "global_configs: ^1.1.2" to clipboard
global_configs: ^1.1.2 copied to clipboard

A flutter package to manage application configurations via singleton pattern.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:global_configs/global_configs.dart';

import 'configs/dev.dart' as configs;

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  // Load configs from map
  GlobalConfigs().loadFromMap(configs.dev);

  // Load configs from json
  await GlobalConfigs().loadJsonFromdir('configs/dev.json');

  print(GlobalConfigs().get('config1'));

  // Set new config
  GlobalConfigs().set('appearance.defaultTheme', 'Light');
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Global config example',
      home: Scaffold(
        appBar: AppBar(
          title: Text('Global config example'),
        ),
        body: Center(
          child: Text(
              'appearance.defaultTheme = ${GlobalConfigs().get("appearance.defaultTheme")}'),
        ),
      ),
    );
  }
}
14
likes
160
points
641
downloads

Publisher

unverified uploader

Weekly Downloads

A flutter package to manage application configurations via singleton pattern.

Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

License

MIT (license)

Dependencies

flutter, gato

More

Packages that depend on global_configs