Giter Club home page Giter Club logo

flutter-global-config's Introduction

Flutter Global Configuration

A flutter package for managing different configurations by merging them together and making them available everythere inside the app via a singleton.

Table of Contents

Preamble

This package is also part of the EZ Flutter Framework.

Install

pubspec.yaml

Update pubspec.yaml and add the following line to your dependencies.

dependencies:
  global_configuration: ^2.0.0

Import

Import the package with :

import 'package:global_configuration/global_configuration.dart';

Loading configuration

There are many ways where you can store your configuration files and load them.

Load from asset

Creating a configuration file inside assets/cfg folder

Create a .json file and place it under assets/cfg/ Example filename: assets/cfg/app_settings.json

{
  "key1": "value1",
  "key2": "value2"
}

Remember to update your pubspec.yaml file, so the config can be loaded from the assets directory! The config files must be placed under the assets/cfg/ directory.

flutter:
 assets:
  - assets/cfg/

Load configuration from assets at app start

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

void main() async{
  await GlobalConfiguration().loadFromAsset("app_settings");
  runApp(MyApp());
}
class MyApp extends StatelessWidget {
  ...
}

Load from path

Creating a configuration file anywhere

Create a file anywhere inside your app.

Load configuration from path at app start

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

void main() async {
  await GlobalConfiguration().loadFromPath("/path/file.json");
  runApp(MyApp());
}
class MyApp extends StatelessWidget {
  ...
}

Load from path into key

The same as loadFromPath, but the config is added under the given key.

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

void main() async {
  await GlobalConfiguration().loadFromPathIntoKey("/path/file.json", "env_settings");
  runApp(MyApp());
}
class MyApp extends StatelessWidget {
  ...
}

Load from map

Creating a configuration inside .dart file

Create a dart file which includes your configuration and import it in your main file. Example filename: /config/app_settings.config.dart

final Map<String, String> appSettings = {
  "key1": "value1",
  "key2": "value2"
};

Load configuration from map at app start

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

void main() async {
  GlobalConfiguration().loadFromMap(appSettings);
  runApp(MyApp());
}
class MyApp extends StatelessWidget {
  ...
}

Load from url

It is possible to load any json configuration file from a url. Use the method loadFromUrl to load the config via GET request. Please consider using a try / catch. This method will throw an exception if the status code of the GET request is not 200.

The method also accepts query parameters and headers! The header "Accept: application/json" is always included.

Load configuration from url at app start

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

void main() async{
  try{
    await GlobalConfiguration().loadFromUrl("http://urlToMyConfig.com");
  }catch(e){
    // something went wrong while fetching the config from the url ... do something
  }
  runApp(MyApp());
}
class MyApp extends StatelessWidget {
  ...
}

Using the configuration in your app

Instatiate the GlobalConfiguration class and call any get($key) method.

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

class CustomWidget extends StatelessWidget {

    CustomWiget(){
        // Access the config in the constructor
        print(GlobalConfiguration().getString("key1")); // prints value1
    }

    @override
     Widget build(BuildContext context) {
        // Access the config in the build method
        return Text(GlobalConfiguration().getString("key2")); // prints value2
     }
}

Overriding configuration

Sometimes it is necessary to override data in the configuration. This can be done by the updateValue method. This method makes a check for the given type of the value and then performs an update the configuration map.

  Map<String, String> appSettings = {
    "key1": "value1",
    "key2": 1
  };
  GlobalConfiguration().loadFromMap(appSettings); // loading the configuration
  print(GlobalConfiguration().getString("key1")); // output : value1
  print(GlobalConfiguration().getString("key2")); // output : 1
  GlobalConfiguration().updateValue("key1", "value2"); // update the value for key1
  GlobalConfiguration().updateValue("key2", 2); // update the value for key2
  print(GlobalConfiguration().getString("key1")); // output : value2
  print(GlobalConfiguration().getString("key2")); // output : 2

Full example

You can find a full example in the example folder.

Changelog

For a detailed changelog, see the CHANGELOG.md file

Copyright and license

MIT License

Copyright (c) 2023 Ephenodrom

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

flutter-global-config's People

Contributors

ephenodrom avatar geograppy avatar haritonstefan avatar lok0613 avatar radvansky-tomas avatar up9cloud avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

flutter-global-config's Issues

Flutter http ^0.13.2 support

When compiling I run into this error:

Using:

  • http^0.13.2
  • global_configuration ^1.6.0
Running Gradle task 'assembleDebug'...
../../api/flutter/.pub-cache/hosted/pub.dartlang.org/global_configuration-1.6.0/lib/global_configuration.dart:233:39: Error: The argument type 'String' can't be assigned to the parameter type 'Uri'.
 - 'Uri' is from 'dart:core'.
    var response = await http.get(Uri.encodeFull(finalUrl), headers: headers);

doesn't support the latest http version 0.13.

I have a big project and I have recently upgraded flutter so some packages require http versions more the 0.12.2 so I had to update but global configurations need 0.12.2 which is why i had to take out global configurations and look in to other packeges please look into it

Asset Loading does'nt seems to work on Web

Config that I want to load :

{
    "key1": "value1",
    "key2": "value2"
}

"Code" i wrote

import 'package:flutter/material.dart';

import 'package:global_configuration/global_configuration.dart';

void main() async {
  GlobalConfiguration().loadFromAsset('app_settings.json');
  print(GlobalConfiguration().appConfig.toString());

  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to Colors.green and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or simply save your changes to "hot reload" in a Flutter IDE).
        // Notice that the counter didn't reset back to zero; the application
        // is not restarted.
        primarySwatch: Colors.blue,
      ),
      home: Text('Flutter Demo Home Page'),
    );
  }
}

Config I did :

  • assets
flutter:


  # The following line ensures that the Material Icons font is
  # included with your application so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # To add assets to your application, add an assets section, like this:
  assets:
    - assets/cfg/
  • of course the package itself
dependencies:
  flutter:
    sdk: flutter
  global_configuration: ^1.4.0

I don't have any Error at Runtime :

Launching lib/main.dart on Chrome in debug mode...
Debug service listening on ws://127.0.0.1:43769/2IaTBAq6l2k=
{}

the things I tried

  • try with an invalid path (I got an error saying that it can't find the path (obviously))
  • restart the app (nothing change)
  • clean cache (to update assets)

Resets Configuration on Restarting Application

For example, I'm using a string named language, its initial value is 'en'. when i change it to for example 'ar', then close the application and reopen it, the value is set back to 'en'. Is it my issue only? Am i using it wrongly or something like that?

http ^0.13.0 Library upgrade required

Hello,

I upgraded my flutter version to 2.0.0 and I upgraded my firebase libraries. There has been an upgrade on FirebaseStorage, and then this library is blocking me of upgrading my project to use the latest version of firebase.

Because firebase_storage >=8.0.0 depends on firebase_storage_web ^1.0.0 which depends on http ^0.13.0, firebase_storage >=8.0.0 requires http ^0.13.0.
And because global_configuration >=1.6.0 depends on http ^0.12.2, firebase_storage >=8.0.0 is incompatible with global_configuration >=1.6.0.
So, because fitwin depends on both global_configuration ^1.6.0 and firebase_storage ^8.0.0, version solving failed.
pub get failed (1; So, because fitwin depends on both global_configuration ^1.6.0 and firebase_storage ^8.0.0, version solving failed.)

Changes in configuration file does not change values

Hi,
When the configuration file is changed, in my case a json file under assets, it does not change cfg values when read in the app.
I have restarted the app without success. Still old values. It seems be cashed somewhere.
How can I force the ClobalConfig to read the updated json file?
Thanks in advanced

setValue key.runtimeType != appConfig[key].runtimeType

/// Write a value from persistent storage, throwing an exception if it's not /// the correct type void setValue(key, value) { key.runtimeType != appConfig[key].runtimeType ? throw("wrong type") : appConfig.update(key, value); }
The runtimeType of the key and value must be ==?
why?

Use different configurations based on current build mode

Is there any built in way to load different configs based on what is the current build mode?

I mean under the cfg folder there could be an app_settings.json for the general things, app_settings.debug.json for debug values like local server urls, and app_settings.release.json for release values.

Support the memory configurations

Sometime we need to store memory configurations (not in persistent storage), it would be great if this package supports to this.
I'd expect something like:

void addMemoryValue(String key, dynamic value){}

And it just uses the same for getString(), getDouble()... (memory cache first)
And all the memory configurations should be cleared when exit app.
Thanks!

Read nested values in a json

Hello,

I'm, try to read nested values in a json string and I don't know how to do that because I'm new in Dart/Flutter.
In an ordinary json string like next:
{ "configuration": { "key1": "value1", "key2": "value2" } }

I want to read the "key1" value. In C# we can do something lik: string value = jsonConfig.ReadValue["configuration:key1"];
I add a similar function in the Flutter-Global-Config thah it permit read a nested value using the metho getDeepValue<T> whet "T" is the data type that you are waiting read.

You can use something like: GlobalConfiguration().getDeepValue<Color>("appColors:primaryColor");. I this case the value readed is a string with a hexadecimal RGB value, for this cases I'm added a function to convert the striing to a Color object.

Here some examples:

String stringValue = GlobalConfiguration().getDeepValue<String>("myStringValue");
String stringValue = GlobalConfiguration().getDeepValue<String>("values:myNestedStringValue");
int intValue =  GlobalConfiguration().getDeepValue<int>("myIntValue");
int intValue =  GlobalConfiguration().getDeepValue<int>("values:myNestedIntValue");
bool boolValue = GlobalConfiguration().getDeepValue<bool>("myBoleanValue");

Updating configuration file on update?

Hi and thank you for a handy little lib!
no bug report here, but a suggestion: maybe I missed something, but it seems that at the moment, when updating an option, only the option map is updated and not the source configuration file.
It could be very convenient to have an option to have the config file updated too, so that when starting up the app again, the updated configuration would be taken into account.

Best regards

why could not change the config file name

I changed the config file name to:

dev_app_settings
pro_app_settings

but when I load the config file, show this error:


Syncing files to device sdk gphone x86 arm...
I/flutter (16237): null
E/flutter (16237): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: Null check operator used on a null value
E/flutter (16237): #0      PlatformAssetBundle.load (package:flutter/src/services/asset_bundle.dart:222:39)
E/flutter (16237): #1      AssetBundle.loadString (package:flutter/src/services/asset_bundle.dart:68:33)
E/flutter (16237): #2      CachingAssetBundle.loadString.<anonymous closure> (package:flutter/src/services/asset_bundle.dart:165:56)
E/flutter (16237): #3      _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:311:23)
E/flutter (16237): #4      CachingAssetBundle.loadString (package:flutter/src/services/asset_bundle.dart:165:27)
E/flutter (16237): #5      GlobalConfiguration.loadFromAsset (package:global_configuration/global_configuration.dart:52:39)
E/flutter (16237): #6      main (package:flutter_learn/main.dart:7:25)
E/flutter (16237): #7      _runMainZoned.<anonymous closure>.<anonymous closure> (dart:ui/hooks.dart:142:25)
E/flutter (16237): #8      _rootRun (dart:async/zone.dart:1354:13)
E/flutter (16237): #9      _CustomZone.run (dart:async/zone.dart:1258:19)
E/flutter (16237): #10     _runZoned (dart:async/zone.dart:1789:10)
E/flutter (16237): #11     runZonedGuarded (dart:async/zone.dart:1777:12)
E/flutter (16237): #12     _runMainZoned.<anonymous closure> (dart:ui/hooks.dart:138:5)
E/flutter (16237): #13     _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:283:19)
E/flutter (16237): #14     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
E/flutter (16237): 
I/flutter (16237): Home

this is the minimal example: https://github.com/jiangxiaoqiang/flutter-learn

Keep getting undefined when trying to use this repo

I tried loading from an asset and from a path to the file, neither work.
Seems to be failing because of a null check.
Log:
Restarted application in 243ms.
Error: Unexpected null value.
at Object.throw_ [as throw] (http://localhost:60043/dart_sdk.js:5063:11)
at Object.nullCheck (http://localhost:60043/dart_sdk.js:5390:30)
at load (http://localhost:60043/packages/flutter/src/services/restoration.dart.lib.js:6180:33)
at load.next ()
at runBody (http://localhost:60043/dart_sdk.js:40211:34)
at Object._async [as async] (http://localhost:60043/dart_sdk.js:40242:7)
at asset_bundle.PlatformAssetBundle.new.load (http://localhost:60043/packages/flutter/src/services/restoration.dart.lib.js:6178:20)
at asset_bundle.PlatformAssetBundle.new.loadString (http://localhost:60043/packages/flutter/src/services/restoration.dart.lib.js:6039:32)
at loadString.next ()
at runBody (http://localhost:60043/dart_sdk.js:40211:34)
at Object._async [as async] (http://localhost:60043/dart_sdk.js:40242:7)
at asset_bundle.PlatformAssetBundle.new.loadString (http://localhost:60043/packages/flutter/src/services/restoration.dart.lib.js:6038:20)
at http://localhost:60043/packages/flutter/src/services/restoration.dart.lib.js:6127:83
at IdentityMap.new.putIfAbsent (http://localhost:60043/dart_sdk.js:27706:21)
at asset_bundle.PlatformAssetBundle.new.loadString (http://localhost:60043/packages/flutter/src/services/restoration.dart.lib.js:6127:57)
at global_configuration.GlobalConfiguration._internal.loadFromAsset (http://localhost:60043/packages/global_configuration/global_configuration.dart.lib.js:71:54)
at loadFromAsset.next ()
at runBody (http://localhost:60043/dart_sdk.js:40211:34)
at Object._async [as async] (http://localhost:60043/dart_sdk.js:40242:7)
at global_configuration.GlobalConfiguration._internal.loadFromAsset (http://localhost:60043/packages/global_configuration/global_configuration.dart.lib.js:67:20)
at main$ (http://localhost:60043/packages/flutter_application_1/main.dart.lib.js:886:60)
at main$.next ()
at runBody (http://localhost:60043/dart_sdk.js:40211:34)
at Object._async [as async] (http://localhost:60043/dart_sdk.js:40242:7)
at main$ (http://localhost:60043/packages/flutter_application_1/main.dart.lib.js:885:18)
at main (http://localhost:60043/web_entrypoint.dart.lib.js:36:29)
at main.next ()
at http://localhost:60043/dart_sdk.js:40192:33
at _RootZone.runUnary (http://localhost:60043/dart_sdk.js:40062:59)
at _FutureListener.thenAwait.handleValue (http://localhost:60043/dart_sdk.js:34983:29)
at handleValueCallback (http://localhost:60043/dart_sdk.js:35551:49)
at Function._propagateToListeners (http://localhost:60043/dart_sdk.js:35589:17)
at _Future.new.[_completeWithValue] (http://localhost:60043/dart_sdk.js:35437:23)
at http://localhost:60043/dart_sdk.js:34617:46
at _RootZone.runUnary (http://localhost:60043/dart_sdk.js:40062:59)
at _FutureListener.then.handleValue (http://localhost:60043/dart_sdk.js:34983:29)
at handleValueCallback (http://localhost:60043/dart_sdk.js:35551:49)
at Function._propagateToListeners (http://localhost:60043/dart_sdk.js:35589:17)
at _Future.new.[_completeWithValue] (http://localhost:60043/dart_sdk.js:35437:23)
at async._AsyncCallbackEntry.new.callback (http://localhost:60043/dart_sdk.js:35458:35)
at Object._microtaskLoop (http://localhost:60043/dart_sdk.js:40330:13)
at _startMicrotaskLoop (http://localhost:60043/dart_sdk.js:40336:13)
at http://localhost:60043/dart_sdk.js:35811:9

why sometimes return null collection

This is the code I am using:

import 'package:global_configuration/global_configuration.dart';

enum ConfigType { DEV, PRO }

class GlobalConfig {
  GlobalConfig(this.baseUrl, this.shareUrl, this.staticResourceUrl);

  static GlobalConfiguration config = GlobalConfiguration();
  String baseUrl = config.get("baseUrl");
  String shareUrl = config.get("shareUrl");
  String staticResourceUrl = config.get("staticUrl");

  static getBaseUrl() {
    String configBaseUrl = config.get("baseUrl");
    return configBaseUrl;
  }

  static getShareUrl() {
    return config.get("shareUrl");
  }

  static getStaticResourceUrl() {
    return config.get("staticUrl");
  }

  static getConfig(String key) {
    return config.get(key);
  }

  static init(ConfigType configType) {
    switch (configType) {
      case ConfigType.DEV:
        break;
      case ConfigType.PRO:
        break;
    }
  }
}

sometimes the config get a null collection, the size of result is 0(sometimes it could successful read). I am sure the config load complete when read the config key. this is the question from stackoverflow.

image

Pass in default value to be returned if value not found in Global Configuration

Hi I am using Global configuration to be build a reusable and configurable template but everywhere that can be configured I am using code like this:

final x = GlobalConfiguration().getValue("key")
final y = x == null ? DefaultX : x 

Since if null then return default is a common use then would be great if a default value can be passed.

I am aware the code can be written as:

final x = GlobalConfiguration().getValue("key") ?? DefaultX

Just feel that it as an improvement in the library API if a default value can be passed.

cant add await GlobalConfiguration().loadFromUrl( ""); to splash screean

import 'package:firebase_remote_config/firebase_remote_config.dart';
import 'package:flutter/material.dart';
import 'package:global_configuration/global_configuration.dart';

import 'package:readhubnew/logic/callAPI.dart';
import 'package:readhubnew/logic/config.dart';
import 'package:readhubnew/main.dart';
import 'package:connectivity/connectivity.dart';
import 'package:readhubnew/Components/components.dart';

class Splash extends StatefulWidget {

@OverRide
_SplashState createState() => _SplashState();
}

class _SplashState extends State {
String mywebadse =
"https://public-api.wordpress.com/wp/v2/sites/kiyawamulk.wordpress.com/posts?per_page=5&_embed";

Future check() async {

var connectivityResult = await (Connectivity().checkConnectivity());



if (connectivityResult == ConnectivityResult.mobile) {
  await GlobalConfiguration().loadFromUrl(
      "https://raw.githubusercontent.com/TSCSOftware/api/master/api1.json");

  return true;
} else if (connectivityResult == ConnectivityResult.wifi) {
  return true;
}
return false;

}
Future getconfig() async {

  await GlobalConfiguration().loadFromUrl(
      "https://myconfig url.com/api1.json");

}

@OverRide
void initState() {
// TODO: implement initState
super.initState();

sendEnglishPosts(mywebadse).then((onValue) {
  {
    Navigator.pushAndRemoveUntil(
      context,
      MaterialPageRoute(builder: (context) => MyHomePage()),
      (Route<dynamic> route) => false,
    );
  }
  ;
}).catchError((onError) {
  showColoredToast('Please Check Your Internet Connection & Try again!');
});
initMobileNumberState(){};

}

@OverRide
Widget build(BuildContext context) {

double height = MediaQuery.of(context).size.height;
return Scaffold(
    body: Container(
  decoration: new BoxDecoration(
    image: new DecorationImage(
      colorFilter: new ColorFilter.mode(
          Colors.white.withOpacity(0.45), BlendMode.dstATop),
      image: new AssetImage("assets/images/back.png"),
      fit: BoxFit.fill,
    ),
  ),
  child: new Center(
      child: Column(
    children: <Widget>[
      Expanded(
          child: Container(
        child: Image.asset('assets/images/logo.png'),
        height: height / 3,
        width: height / 3,
      )),
      Container(child: CircularProgressIndicator()),
      Container(
        margin: EdgeInsets.all(8),
        padding: const EdgeInsets.all(8.0),
        child: Text(
          "welcome",
          style: TextStyle(
              letterSpacing: 3,
              color: Colors.red,
              fontSize: 20.0,
              fontWeight: FontWeight.bold,
              fontFamily: 'Poppins'),
        ),
      ),
    ],
  )),
));

}
}

Is is possible to set/read the configuration in a top level function when app is killed?

I am currently setting my configuration in main, and everything works perfectly when the app is alive. When I kill the app though, I cannot seem to read the values of the configuration in a top level function.

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

  await GlobalConfiguration()
      .loadFromAsset(kReleaseMode ? "production.json" : "local.json");

In my case, this function is in a background task which fires every couple minutes the user is logged in, and needs to function properly when the app is killed. I have tried calling loadFromAsset from within this function but it still doesn't seem to work. If I hard code the value instead of reading from the config, it works properly so I'm quite sure this is the issue. Even though it's fairly annoying to get insight into what's going on when an app is killed.

My background tasks works properly with GlobalConfiguration when the app is not killed.

This works:

  await dio.post(
    "https://hardcoded.redacted/v2/endpoint",
    data: {
      "example": [example]
    },
  );

This does not:

  String tenant = GlobalConfiguration().getString("tenant");
  await dio.post(
    "https://$tenant.redacted/v2/endpoint",
    data: {
      "example": [example]
    },
  );

Suggestions?

null safety

just a simple question. Why null safety is still not released. Is there any bug with it ?

Cannot Update Null Value

Thank you for this great package. I have problems when I want to update the value that originally Null became one of the string / int values.
The Error Log

E/flutter ( 9084): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: wrong type
E/flutter ( 9084): #0      GlobalConfiguration.updateValue (package:global_configuration/global_configuration.dart:138:13)
E/flutter ( 9084): #1      _MapScreenState._sendAttendance (package:n4_attendance/app/screens/map_screen.dart:519:17)
E/flutter ( 9084): <asynchronous suspension>
....```

errors compiling

E/flutter (25789): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: ServicesBinding.defaultBinaryMessenger was accessed before the binding was initialized.
E/flutter (25789): If you're running an application and need to access the binary messenger before runApp() has been called (for example, during plugin initialization), then you need to explicitly call the WidgetsFlutterBinding.ensureInitialized() first.
E/flutter (25789): If you're running a test, you can call the TestWidgetsFlutterBinding.ensureInitialized() as the first line in your test's main() method to initialize the binding.

flutter 1.26.0.17.6-pre

void main() async {
await GlobalConfiguration().loadFromAsset("app_settings");
runApp(MyApp());
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.