provider_widget 0.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 57

provider_widget #

ProviderWidget provides data and components downstream without any side effects that you get while using InheritedWidget.

Getting Started #

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

For help on editing package code, view the documentation.

[0.0.1] - TODO: Add release date. #

  • TODO: Describe initial release.

example/lib/main.dart

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

void main() => runApp(
      ProviderWidget<ProviderStore>(
        child: MyApp(),
        provided: ProviderStore([
          CounterState(),
        ]),
      ),
    );

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'ProviderWidget demo',
      theme: new ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: new MyHomePage(title: 'Demo'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => new _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  CounterState counterState;

  @override
  void initState() {
    super.initState();
    counterState = ProviderWidget.of<ProviderStore>(context).get(CounterState);
  }

  void _incrementCounter() {
    setState(() {
      counterState.counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text(widget.title),
      ),
      body: new Center(
        child: new Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            new Text(
              'You have pushed the button this many times:',
            ),
            new Text(
              '${counterState.counter}',
              style: Theme.of(context).textTheme.display1,
            ),
            new FlatButton(
              onPressed: () => Navigator.of(context).push(
                    MaterialPageRoute(
                      builder: (context) => CounterOverviewScreen(),
                    ),
                  ),
              child: Text("See overview"),
            )
          ],
        ),
      ),
      floatingActionButton: new FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: new Icon(Icons.add),
      ),
    );
  }
}

class CounterOverviewScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    CounterState counterState =
        ProviderWidget.of<ProviderStore>(context).get(CounterState);
    return Scaffold(
      body: Center(
          child: Text(
        "You clicked ${counterState.counter} times",
        style: TextStyle(fontSize: 40.0),
      )),
    );
  }
}

class CounterState implements ProvidedComponent {
  int counter = 0;

  @override
  void dispose() {
    // TODO: implement dispose
  }
}

class Api implements ProvidedComponent {
  @override
  void dispose() {
    // TODO: implement dispose
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  provider_widget: ^0.1.0

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_widget/provider_widget.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
38
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
41
Overall:
Weighted score of the above. [more]
57
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.15
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

Because:

  • provider_widget that is a package requiring null.

Health suggestions

Fix lib/src/inherited_provider_widget.dart. (-0.50 points)

Analysis of lib/src/inherited_provider_widget.dart reported 1 hint:

line 25 col 51: 'inheritFromWidgetOfExactType' is deprecated and shouldn't be used. Use dependOnInheritedWidgetOfExactType instead. This feature was deprecated after v1.12.1..

Fix lib/src/provider_widget.dart. (-0.50 points)

Analysis of lib/src/provider_widget.dart reported 1 hint:

line 32 col 10: 'ancestorWidgetOfExactType' is deprecated and shouldn't be used. Use findAncestorWidgetOfExactType instead. This feature was deprecated after v1.12.1..

Format lib/generated/i18n.dart.

Run flutter format to format lib/generated/i18n.dart.

Maintenance suggestions

Package is getting outdated. (-58.63 points)

The package was last published 82 weeks ago.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test