global_configuration 1.5.0

Flutter Android iOS web

A flutter package for managing different configurations and making them available everythere inside the app.

example/main.dart

import 'package:flutter/material.dart';
import 'package:global_configuration/global_configuration.dart';
import 'AppSettings.config.dart';
import 'DevSettings.config.dart';

void main() async {
  GlobalConfiguration().loadFromMap(appSettings).loadFromMap(devSettings);
  await GlobalConfiguration().loadFromUrl("https://swapi.co/api/people/1");
  runApp(MyApp());
}

class MyApp extends StatelessWidget {

  MyApp(){
    // Access configuration at constructor
    GlobalConfiguration cfg = new GlobalConfiguration();
    print("Key1 has value ${cfg.getString("key1")}");
    print("Key2 has value ${GlobalConfiguration().getString("key2")}");
    print("Key5 has value ${cfg.getString("key5")}, this should be null!");
  }

  @override
  Widget build(BuildContext context) {
    // Access configuration at build method
    GlobalConfiguration cfg = new GlobalConfiguration();
    print("Key3 has value ${cfg.getString("key3")}");
    return MaterialApp(
      title: 'Welcome to Flutter',
      home: Scaffold(
        appBar: AppBar(
          title: Text('Welcome to Flutter'),
        ),
        body: Center(
          child: Text('Hello World'),
        ),
      ),
    );
  }
}
29
likes
110
pub points
97%
popularity

A flutter package for managing different configurations and making them available everythere inside the app.

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

aic7to@gmail.com

License

MIT (LICENSE)

Dependencies

flutter, http

More

Packages that depend on global_configuration