provider_assist 2.0.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 76

Provider Assist #

Provider assist is a ton of helpful tools designed to improve development within Flutter even further! This project is a brainchild of mine and is the core of any flutter application I personally develop. It serves these purposes:

Breaking Change (2.0.0) #

As well as moving to Provider version 4.0.0. A lot of minor quality of life improvements have been done to make using this a lot easier.
To name a few:

  1. Events are now dynamic, meaning you can pass anything as an event
  2. All global functions are now in the ProviderAssist singleton class, meaning it can be mocked easier
  3. Errors have been removed to reduce the amount of streams in a BaseView. As they're events in their own right, pass them as events

In short, see the new example project for all the updates!

Layout Information #

This is a handy helper which is automatically passed into your build function in views. It will supply a number of useful properties about the devices, as well as the localizations for your current Locale if you registered them earlier.

Note: This is an inherited widget so if there are times when you require it outside of the view, you can obtain it anytime by doing the following.

void main() {

Map<Locale, Map<String, String>> translations = {
  Locale('en'): {
    'view_title': 'Example Title',
    'view_raise_event': 'Raise Event',
  Locale('hi'): {
    'view_title': 'उदाहरण शीर्षक',
    'view_raise_event': 'घटना को बढ़ाएँ',

Example View #

class View extends StatelessWidget {
  Widget build(BuildContext context) {
    return BaseView<ViewModel>(
      model: ViewModel(),
      onEventOccured: (BuildContext context, ViewModel model, dynamic event) {
        print("Got a new event: $event");
      onModelReady: (ViewModel model) {
        print("Model is ready, but view is still not visible");
      onViewFirstLoad: (BuildContext context, ViewModel model) {
        print("View is rendered");
      builder: (BuildContext context, ViewModel vm, LayoutInformation layout) {
        print("Device type: ${layout.deviceType}");
        print("Device orientation: ${layout.orientation}");
        return Scaffold(
          backgroundColor: layout.theme.backgroundColor,
          appBar: AppBar(
            title: Text(layout.translations['view_title']),
          body: Container(
            width: double.infinity,
            child: Column(
              children: <Widget>[
                  child: Text(layout.translations['view_raise_event']),
                  onPressed: () => vm.onEventRequested(),

Example View Model #

class ViewModel extends BaseViewModel {
  void onEventRequested() {
    try {
      notifyEvent('Random event');
    } finally {

Any questions? Fire them over on Github or Facebook!

  • Ryan

[2.0.3] - 25/03/2020 #

  • Simplify Layout information class

[2.0.2] - 25/03/2020 #

  • Dont add event to sink if closed

[2.0.1] - 29/12/2019 #

  • Fix broken readme from merge

[2.0.0] - 29/12/2019 #

  • Migrate to provider version 4
  • Wrap common functions in singlton ProviderAssist class. All previous global functions will be found there, for example registerTranslations.
  • Pass metadata in events
  • Events and Errors replaced with just Events. As errors are a type of event it seems redundant to have both of these fields
  • Events are now of type dynamic, this means you can pass complex classes down now instead (for example, including metadata)

[1.5.3] - 08/11/2019 #

  • Fix a potential NPE when trying to create a mock for a view model

[1.5.2] - 06/11/2019 #

  • Fix example in documentation

[1.5.1] - 17/09/2019 #

  • Improve Documentation

[1.5.0] - 17/09/2019 #

  • BREAKING CHANGE: onEventReceived and onErrorReceived will now supply the model. You will need to ammend your code to include this!

[1.4.1] - 20/09/2019 #

  • Provide the current context of the consumer in layoutInformation, use this sparingly!

[1.4.0] - 17/09/2019 #

  • BREAKING CHANGE: onViewFirstLoad will now supply the model. You will need to ammend your code to include this!

[1.3.2] - 17/09/2019 #

  • Fix another small bug with event streams.

[1.3.1] - 17/09/2019 #

  • Fix a bug where the same stream was being listened to twice causing an assertion.

[1.3.0] - 16/09/2019 #

  • Added a new callback on BaseViewModel to raise events back to the UI via a string, this can be used for anything. Examples being login, navigation requests, etc.

[1.2.0] - 13/09/2019 #

  • Basic localization support, see example

[1.1.0] - 10/09/2019 #

  • (BREAKING CHANGES) Refactored the LayoutInformation passed back from the build function to be more futureproof.

[1.0.0] - 10/09/2019 #

  • Leverage locale in layout information, first stable release

[0.0.2] - 09/09/2019 #

  • Improve documentation around BaseView

[0.0.1] - 09/09/2019 #

  • Initial release with basic feature set


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

import 'package:example/views/sample_view.dart';

import 'package:provider_assist/provider_assist.dart';

void main() {

class MyApp extends StatelessWidget {
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Example',
      // Swap below to change locale
      locale: Locale('en'),
      // locale: Locale('hi'),
      supportedLocales: <Locale>[
      localizationsDelegates: <LocalizationsDelegate>[
      theme: ThemeData(
      home: SampleView(),

Map<Locale, Map<String, String>> translations = {
  Locale('en'): {
    'view_title': 'Example Title',
    'view_raise_event': 'Raise Event',
  Locale('hi'): {
    'view_title': 'उदाहरण शीर्षक',
    'view_raise_event': 'घटना को बढ़ाएँ',

Use this package as a library

1. Depend on it

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

  provider_assist: ^2.0.3

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:

import 'package:provider_assist/provider_assist.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Mar 31, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health suggestions

Format lib/helpers/layout_information.dart.

Run flutter format to format lib/helpers/layout_information.dart.

Format lib/provider_assist.dart.

Run flutter format to format lib/provider_assist.dart.

Format lib/view_models/base_view_model.dart.

Run flutter format to format lib/view_models/base_view_model.dart.

Format lib/views/base_view.dart.

Run flutter format to format lib/views/base_view.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.5.0 <3.0.0
flutter 0.0.0
flutter_localizations 0.0.0
provider ^4.0.4 4.0.4 4.1.0-dev+2
Transitive dependencies
collection 1.14.11 1.14.12
intl 0.16.0 0.16.1
meta 1.1.8
nested 0.0.4
path 1.6.4
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies