adhara 0.3.4

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 78

adhara #

Base framework for Flutter Apps with intense networking and data interactivity. Adhara provides a seamless offline experience with much ease.

What adhara brings to the plate?

  1. Easy SQLite management - ORM, using DataInterfaces
  2. Easy network setup with the help of network middlewares
  3. Manage data using Data Beans in a well structured format. No more worries about runtime errors or key changes in JSON.
  4. Event Handlers: Listen to events across the widgets. An event can be triggered in one dart file and can be listened in any of stateful widgets*
  5. Internationalization - Manual i18N based on selected language.
  6. Easy routing: Simplified Regex based URL routing like in a web application
  7. Easy Sentry Logger in production with one DSN configuration
  8. Properties file parser, JSON file reader, running modes and many more...

*stateful widget is overridden by adhara and is called AdharaStatefulWidget, and has a state named AdharaState

Getting Started #

For help getting started with Flutter, view our online documentation.

For help on editing package code, view the documentation.

Report your issues: https://github.com/infitio/flutter-adhara/issues

[0.3.4] - 26th March, 2019

  • String Resources now supports placeholders

    search=Search among {0}

    is a valid string property, and can be accessed using r.getString("search", placeholders=["CPUs"])

[0.3.3] - 24th March, 2019

  • Fetching image issue fixed

[0.3.2] - 19th March, 2019

  • throw error if resource is un available

[0.3.0] - 21st February, 2019

  • Breaking change. Migrate from the deprecated original Android Support Library to AndroidX. This shouldn't result in any functional changes, but it requires any Android apps using this plugin to also migrate if they're using the original support library.

[0.2.4] - 18th January, 2019

  • dart:core lower limit raised from 2.0.0 to 2.1.0
  • return type added for r.getString

[0.2.2] - 18th January, 2019

  • Dev mode issue for fast actions while fetch resources

[0.2.1] - 10th January, 2019

  • default for string resources can be provided with the new signature... getString(key, {String defaultValue, bool suppressErrors: false})

if suppressErrors is set to true, errors related to key not found will not be thrown even in strict mode

[0.1.69] - 7th December, 2018

  • Introducing setData(key,value) and getData(key) in Adhara event
  • Event emitters can await for handler execution and get handler return value by using event.getData(tag)

[0.1.66] - 24th November, 2018

  • loading indicator update

[0.1.63] - 22nd November, 2018

  • Bug fixes for offlineProvider response type (changed Map to dynamic)
  • Asset file loader is now released of restrictions to read JSONArray from .json files. return type is made dynamic from Map

[0.1.62] - 22nd November, 2018

  • Data mock can be stored in assets/data/<API_URL_AS_PATH_SEPARATED_BY_HYPHEN>-<METHOD>.json file

    For example:

      Network Provider(Online) calls GET '/api/v1/items',
      Using Offline provider one can mock the data by creating '/assets/data/api-v1-items-get.json'
      (or)
      Network Provider(Online) calls DELETE '/api/v1/items/1',
      Using Offline provider one can mock the data by creating '/assets/data/api-v1-items-1-delete.json'
      (or)
      Network Provider(Online) calls PUT '/api/v1/items/?status=available',
      Using Offline provider one can mock the data by creating '/api/v1/items--status=available'
    

    Note that / and ? will eb replaced by -. This behavior can be overridden by overriding OfflineProvider and configuring the same on Config class

[0.1.61] - 22nd November, 2018

  • expanding network provider to an abstract classes data provider and 2 implementation classes network and offline

  • Offline provider can be helpful for data mocking in development Data mock can be stored in assets/data/<API_URL_AS_PATH>/<METHOD>.json file

    For example:

    Network Provider(Online) calls GET '/api/v1/items',
    Using Offline provider one can mock the data by creating '/assets/data/api/v1/items/get.json'
    (or)
    Network Provider(Online) calls DELETE '/api/v1/items/1',
    Using Offline provider one can mock the data by creating '/assets/data/api/v1/items/1/delete.json'
    

    Note that method name must be lowercase Offline provider greatly helps in integrated testing with data

[0.1.58] - 21st November, 2018

  • Introducing few commonly used widgets: Fetching, NoData, Paginator, PullToRefresh

[0.1.57] - 21st November, 2018

  • Introducing few commonly used widgets: Fetching, NoData, Paginator, PullToRefresh

[0.1.55] - 14th November, 2018

  • AdharaStatefulWidget~isFirstLoadComplete was returning wrong status, issue fixed.

[0.1.54] - 14th November, 2018

  • code optimization

[0.1.53] - 14th November, 2018

  • removing fragile socket.io dependency thereby removing support for webSockets.
  • new getter fromFile in Config. Using this configuration json variables can be accessed

[0.1.52] - 12th November, 2018

  • Bug Fix for filter and exclude combinations in dataInterface.query

[0.1.51] - 9th November, 2018

  • Optimize setData in KeyValueStorageProvider

[0.1.50] - 6th November, 2018

  • isFirstLoadComplete getter to know if the widget has completed loading for the very first time in app lifecycle

[0.1.48] - 14th October, 2018

  • registerSocketEvents removed. added get eventHandlers => {}; this should return event-handler map.
  • Example:
get eventHandlers => {
    'app:new-notification': this.refreshNotificationIcon
};

[0.1.45] - 14th October, 2018

  • registerSocketEvents signature changed to Future registerSocketEvents(SocketIO socket);

[0.1.44] - 14th October, 2018.

  • Introducing socket connections using socket.io
  • Override registerSocketEvents from NetworkProvider and use instance level socket field to listen to events
  • Usage
      //example
      Future registerSocketEvents() async {
          await socket.on('message', (greeting) {
            print('Hello, $greeting');
          });
          await socket.emit('init', [
            {'Hello': 'world!'},
          ]);
        }
    

[0.1.43] - 14th October, 2018.

  • Optimized/Enhanced event handler. Introducing Event object

[0.1.42] - 14th October, 2018.

  • Introducing event handler. Register and trigger events across widgets.
  • Usage: inside State class extending AdharaState,
      on("eventName", handlerFn);     //to register
      off("eventName")                //to de-register
      trigger("someOtherEvent")       //to trigger event across all mounted stateful widgets
    

[0.1.41] - 13th October, 2018.

  • Removed HTTPStorageProvider support. Use KeyValue storage provider if required, or create a HTTPStorage provider extending KeyValueStorage.

[0.1.40] - 13th October, 2018.

  • Removed storage provider schema configurations. Only fields can be configured now using storage_classes

[0.1.39] - 13th October, 2018.

  • Dart 2.0 Support.

[0.1.33] - 08th October, 2018.

  • KeyValueStorageProvider - value was Unique, now changed to non unique

[0.1.32] - 28th September, 2018.

  • printing preload errors

[0.1.31] - 28th September, 2018.

  • Enforcing usage of

[0.1.30] - 28th September, 2018.

  • Config can now configure config configFile field which returns a file from assets - config file. this eases up development files...

[0.1.25] - 28th September, 2018.

  • flutter's presky setState error in development for "setState called after dispose" is suppressed by performing a check in adhara's stateful_widget

[0.1.24] - 27th September, 2018.

  • Enhanced logging for network calls

[0.1.22] - 26th September, 2018.

  • Bug Fix for constraints in Schema Columns

[0.1.21] - 24th September, 2018.

  • Enhancements in bean.dart

[0.1.19] - 21th September, 2018.

  • Bug Fixes in 0.1.0

[0.1.0] - 13th September, 2018.

  • Storage Field classes introduced. table schema can now be declared easily with introduced classes by making field types mandatory
  • Storage Field classes will support storing boolean/json fields - serialization and deserialization will be taken care by these classes

[0.0.45] - 2nd September, 2018.

  • Adding examples

[0.0.44] - 2nd September, 2018.

  • Adding shared preferences in Resources. User r.preferences to access shared_preferences API's

[0.0.42] - 29th August, 2018.

  • Reverting to previous

[0.0.41] - 29th August, 2018.

  • Upgrade all dependencies to latest

[0.0.39] - 29th August, 2018.

  • Resources made available in DataInterface by public field r.

[0.0.38] - 19th August, 2018.

  • Router's getRoute function's argument urlPatterns now accepts kwargs, ex: {"pattern": "^posts/{{postId}}([0-9]+)/edit\$", "router": NewPost.router, "kwargs": {"edit": true}},

[0.0.36] - 17th August, 2018.

  • Storage provider create table error handled for IOS

[0.0.35] - 12th August, 2018.

  • Sentry ignore strings introduced. List<String> get sentryIgnoreStrings in Config

[0.0.34] - 11th August, 2018.

  • Adding sentry. use Config.sentryDSN to configure sentry data source name

[0.0.32] - 7th August, 2018.

  • NetworkProvider enhanced. Interceptors introduced.

[0.0.30] - 4th August, 2018.

  • single instance database referred from resources. It is expected to be auto closed on app closing...

[0.0.28] - 1st August, 2018.

  • loadLanguage introduced. Can call this to load new languages whenever required

[0.0.28] - 29th July, 2018.

  • clearResources introduced. This can be called on logout from the application.
  • clearResources by default clear's AppState and calls DataInterface's clearDataStores method.
  • dataStores getter introduced in DataInterface. This must return all data stores whose creation and truncation will be handled with easy utils.

[0.0.27] - 19th July, 2018.

  • Mode utilities added

[0.0.25] - 19th July, 2018.

  • Introducing tag for AdharaState to manage state related unique variables

[0.0.22] - 19th July, 2018.

  • Dart 2 support

[0.0.22] - 19th July, 2018.

  • All calling functions enhanced with same signature

[0.0.21] - 19th July, 2018.

  • StorageProvider methods relating to get list now accepts all arguments supported by sqflite

[0.0.20] - 19th July, 2018.

  • StorageProvider delete operation Signature changes

[0.0.18] - 19th July, 2018.

  • Introducing Batch Udpate.

[0.0.16] - 18th July, 2018.

  • Created time and Updated time for all beans and storage's.

[0.0.13] - 18th July, 2018.

  • Introducing AdharaStatelessWidget. Use buildWithResources(BuildContext context, Resources r) to access resources.

[0.0.12] - 15th July, 2018.

  • Network provider failure responses now throw error

[0.0.10] - 15th July, 2018.

  • App state scope get and set method names changed to getValue setValue.
  • default value made optional for getValue

[0.0.6] - 15th July, 2018.

  • providing r as a getter in adhara stateful widget

[0.0.5] - 15th July, 2018.

  • Introducing remove in KeyValueStorageProvider

[0.0.4] - 15th July, 2018.

  • Adding option for custom data interface in config.dart

[0.0.2] - 15th July, 2018.

  • Adding URL launcher as a single function call which abstracts checks for canLaunch

[0.0.1] - 15th July, 2018.

  • AdharaStatefulWidget and AdharaSState to manage lifecycle events for data
  • Resource Handling for languages
  • Router to handle URL's by path
  • SQFLite integrated for database interactions
  • Bean (~ POJO classes from Java) based storage handlers
  • KeyValue stores in database
  • http storage for URL based storage

example/main.dart

/// appconfig.dart

//import "app.dart";  TODO uncomment
import "package:adhara/adhara.dart";
import 'package:flutter/material.dart';

//TODO declare in a separate file and implement required methods
class AppNetworkProvider extends NetworkProvider {
  AppNetworkProvider(Config config) : super(config);
}

//TODO declare in a separate file and implement required methods
class AppDataInterface extends DataInterface {
  AppDataInterface(Config config) : super(config);
}

class AppConfig extends Config {
  ///Return App Container Widget
  get container => App();

  ///Return Network URL
  String get baseURL {
    return isReleaseMode()
      ? "http://mysite.com/" //TODO set production URL
      : "http://192.168.1.1:8000/"; //TODO set development URL
  }

  ///Return App Network Provider
  NetworkProvider get networkProvider => AppNetworkProvider(this);

  OfflineProvider get offlineProvider => OfflineProvider(this);

  ///Return App Data Interface
  DataInterface get dataInterface => AppDataInterface(this);

  ///return SQLite DB Name
  String get dbName {
    return isReleaseMode() ? "production.db" : "development.db";
  }

  ///return SQLite DB Version -  to increment on new releases if required...
  int get dbVersion {
    return isReleaseMode() ? 1 : 1;
  }

  ///  Language file map will be used to display the text content where ever r.getString(RESOURCE_KEY) is used
  ///    Language file is a .properties file
  ///    Pattern: RESOURCE_KEY=RESOURCE_VALUE
  ///-----------------------------------------
  ///    key1=Value 1
  ///    key2=Value 2
  ///    ....
  ///-----------------------------------------
  Map<String, String> get languageResources => {
//  TODO create language files, refer them in pubspec assets and map it here.
    "en": "assets/languages/en.properties",
    "fr": "assets/languages/fr.properties",
    "ka": "assets/languages/te.properties",
    "hi": "assets/languages/hi.properties",
  };
}

/// app.dart
//import 'package:flutter/material.dart'; //TODO uncomment
//import 'package:adhara/adhara.dart'; //TODO uncomment

class App extends AdharaStatefulWidget {
  @override
  _AppState createState() => _AppState();
}

/*App code Starts here*/
class _AppState extends AdharaState<App> {
  @override
  void initState() {
    super.initState();
  }

  @override
  firstLoad() async {
    //    This will be called only when this widget is called for the very first time of app lifecycle
  }

  String get tag => "App"; //Unique identifier for this widget

  bool isLoggedIn;
//  Widget home = SplashScreen();

  @override
  fetchData(Resources r) async {
//    TODO perform any database queries from AppDataInterface
//  This function will be called whenever widget's init state is called. For the first time, this will be called only after firstLoad.

//    isLoggedIn = await (r.dataInterface as AppDataInterface).isLoggedIn();
//    home = isLoggedIn?HomePage():LoginPage();
//    home = HomePage();

    setState(() {});
  }

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: r.getString(
        "app_title"), //Query String resource from properties files... ( i18n )
      debugShowCheckedModeBanner: false,
//      home:  home,
//      onGenerateRoute: routeGenerator,
    );
  }
}

/// main.dart
//import 'package:flutter/material.dart'; //TODO uncomment
//import 'appconfig.dart'; //TODO uncomment
//import 'package:adhara/adhara.dart'; //TODO uncomment

void main() => AdharaApp.init(AppConfig());

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  adhara: ^0.3.4

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:adhara/adhara.dart';
  
Version Uploaded Documentation Archive
0.3.4 Mar 26, 2019 Go to the documentation of adhara 0.3.4 Download adhara 0.3.4 archive
0.3.3 Mar 24, 2019 Go to the documentation of adhara 0.3.3 Download adhara 0.3.3 archive
0.3.2 Mar 19, 2019 Go to the documentation of adhara 0.3.2 Download adhara 0.3.2 archive
0.3.1 Mar 19, 2019 Go to the documentation of adhara 0.3.1 Download adhara 0.3.1 archive
0.3.0 Feb 21, 2019 Go to the documentation of adhara 0.3.0 Download adhara 0.3.0 archive
0.2.4 Jan 22, 2019 Go to the documentation of adhara 0.2.4 Download adhara 0.2.4 archive
0.2.3 Jan 22, 2019 Go to the documentation of adhara 0.2.3 Download adhara 0.2.3 archive
0.2.2 Jan 18, 2019 Go to the documentation of adhara 0.2.2 Download adhara 0.2.2 archive
0.2.1 Jan 10, 2019 Go to the documentation of adhara 0.2.1 Download adhara 0.2.1 archive
0.2.0 Jan 10, 2019 Go to the documentation of adhara 0.2.0 Download adhara 0.2.0 archive

All 120 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
58
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
78
Learn more about scoring.

We analyzed this package on Apr 16, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.2.0
  • pana: 0.12.14
  • Flutter: 1.4.7

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Fix lib/datainterface/storage/storage_provider.dart. (-0.50 points)

Analysis of lib/datainterface/storage/storage_provider.dart reported 1 hint:

line 6 col 8: Don't import implementation files from another package.

Fix lib/resources/r.dart. (-0.50 points)

Analysis of lib/resources/r.dart reported 1 hint:

line 95 col 37: Avoid using braces in interpolation when not needed.

Format lib/config.dart.

Run flutter format to format lib/config.dart.

Format lib/resources/ri.dart.

Run flutter format to format lib/resources/ri.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0-dev.9.4 <3.0.0
flutter 0.0.0
http ^0.12.0+1 0.12.0+2
path ^1.6.2 1.6.2
path_provider ^0.5.0+1 0.5.0+1
sentry ^2.2.0 2.2.0
shared_preferences ^0.5.1+1 0.5.2
sqflite ^1.1.1 1.1.5
url_launcher ^5.0.1 5.0.2
Transitive dependencies
async 2.2.0
charcode 1.1.2
collection 1.14.11
http_parser 3.1.3
meta 1.1.6 1.1.7
pedantic 1.5.0
sky_engine 0.0.99
source_span 1.5.5
stack_trace 1.9.3
string_scanner 1.0.4
synchronized 2.1.0
term_glyph 1.1.0
typed_data 1.1.6
usage 3.4.1
vector_math 2.0.8