flutter_provider 1.1.0+3

flutter_provider #

Flutter generic provider using InheritedWidget

Getting Started #

This project is a starting point for a Dart package, a library module containing code that can be shared easily across multiple Flutter or Dart projects.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

[1.1.0+3] - April 14, 2019

  • No change

[1.1.0+2] - April 14, 2019

  • No change

[1.1.0+1] - April 14, 2019

  • Refactor

[1.1.0] - April 7, 2019

  • Add Providers, Consumer2, Consumer3, Consumer4, Consumer5, Consumer6, Consumer7, Consumer8, Consumer9.

[1.0.0] - March 31, 2019

  • Initial package

example/lib/main.dart

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

class Foo {
  const Foo();

  String foo() => 'Hello';
}

class Bar1 {
  const Bar1();

  String bar1() => 'Hello everyone';
}

class Bar2 {
  const Bar2();

  String bar2() => 'Fall in love with Flutter';
}

void main() {
  const Foo foo = Foo();
  const Bar1 bar1 = Bar1();
  const Bar2 bar2 = Bar2();

  runApp(
    Providers(
      providers: <Provider>[
        const Provider<Bar1>(value: bar1),
        const Provider<Bar2>(value: bar2),
      ],
      child: const Provider<Foo>(
        value: foo,
        child: MyApp(),
      ),
    ),
  );
}

class MyApp extends StatelessWidget {
  const MyApp({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Provider example',
      theme: ThemeData.dark(),
      home: const HomePage(),
    );
  }
}

class HomePage extends StatelessWidget {
  const HomePage({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Flutter provider example'),
      ),
      body: Consumer3<Foo, Bar1, Bar2>(
        builder: (BuildContext context, Foo a, Bar1 b, Bar2 c) {
          return Container(
            constraints: BoxConstraints.expand(),
            child: Center(
              child: Column(
                mainAxisSize: MainAxisSize.max,
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: <Widget>[
                  Text(a.foo()),
                  Text(b.bar1()),
                  Text(c.bar2()),
                ],
              ),
            ),
          );
        },
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_provider: ^1.1.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:flutter_provider/flutter_provider.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
75
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
85
Learn more about scoring.

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

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.3

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (meta).

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
meta >=1.1.1 <2.0.0 1.1.6 1.1.7
Transitive dependencies
collection 1.14.11
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test
test_api ^0.2.2

Admin