hive_listener 0.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • new77

hive_listener #

A tiny widget to listen hive box changes

How to use #

HiveListener(
  box: Hive.box('settings'),
  keys: ['dark_theme'], // keys is optional to specify listening value changes
  builder: (box) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: box.get('dark_theme', defaultValue: false) ? ThemeData.dark() : ThemeData.light(),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  },
)

[0.0.1] - 11 June 2020 #

  • The package created

[0.0.1+1] - 11 June 2020 #

  • The licence added to repository

[0.0.1+2] - 11 June 2020 #

  • 'How to use' is added to readme file

[0.0.1+3] - 11 June 2020 #

  • 'homepage' is added to package

[0.0.1+4] - 11 June 2020 #

  • dershub.com is added to homepage property

[0.0.2+1] - 11 June 2020 #

  • dershub.com and year are added to licence

[0.1.0] - 11 June 2020 #

  • added more information to package description

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:hive/hive.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:hive_listener/hive_listener.dart';

void main() async {
  await Hive.initFlutter('example_hive_folder');
  await Hive.openBox('settings');
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return HiveListener(
      box: Hive.box('settings'),
      keys: ['dark_theme'], // keys is optional to specify listening value changes
      builder: (box) {
        return MaterialApp(
          title: 'Flutter Demo',
          theme: box.get('dark_theme', defaultValue: false) ? ThemeData.dark() : ThemeData.light(),
          home: MyHomePage(title: 'Flutter Demo Home Page'),
        );
      },
    );
  }
}

class MyHomePage extends StatelessWidget {
  final String title;

  const MyHomePage({Key key, this.title}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    Box settingsBox = Hive.box('settings');
    return Scaffold(
      appBar: AppBar(
        title: Text(title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'You have pushed the button this many times:',
            ),
            HiveListener(
              box: settingsBox,
              keys: ['counter'], // keys is optional to specify listening value changes
              builder: (box) {
                return Text(
                  '${box.get('counter', defaultValue: 0)}',
                  style: Theme.of(context).textTheme.headline4,
                );
              },
            ),
            RaisedButton(
              onPressed: () {
                bool darkTheme = settingsBox.get('dark_theme', defaultValue: false);
                settingsBox.put('dark_theme', !darkTheme);
              },
              child: Text("Switch Dark Theme"),
            ),
            RaisedButton(
              onPressed: () {
                settingsBox.put('counter', 0);
              },
              child: Text("Reset Counter"),
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          int counter = settingsBox.get('counter', defaultValue: 0);
          settingsBox.put('counter', ++counter);
        },
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


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

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

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform android

Because:

  • package:hive_listener/hive_listener.dart that imports:
  • package:hive_flutter/hive_flutter.dart that imports:
  • package:path_provider/path_provider.dart that imports:
  • package:path_provider_linux/path_provider_linux.dart that declares support for platforms: linux

Package does not support Flutter platform ios

Because:

  • package:hive_listener/hive_listener.dart that imports:
  • package:hive_flutter/hive_flutter.dart that imports:
  • package:path_provider/path_provider.dart that imports:
  • package:path_provider_linux/path_provider_linux.dart that declares support for platforms: linux

Package does not support Flutter platform macos

Because:

  • package:hive_listener/hive_listener.dart that imports:
  • package:hive_flutter/hive_flutter.dart that imports:
  • package:path_provider/path_provider.dart that imports:
  • package:path_provider_linux/path_provider_linux.dart that declares support for platforms: linux

Package does not support Flutter platform web

Because:

  • package:hive_listener/hive_listener.dart that imports:
  • package:hive_flutter/hive_flutter.dart that imports:
  • package:path_provider/path_provider.dart that declares support for platforms: android, ios, linux, macos

Package does not support Flutter platform windows

Because:

  • package:hive_listener/hive_listener.dart that imports:
  • package:hive_flutter/hive_flutter.dart that imports:
  • package:path_provider/path_provider.dart that declares support for platforms: android, ios, linux, macos

Package not compatible with SDK dart

Because:

  • hive_listener that is a package requiring null.

Health suggestions

Format lib/hive_listener.dart.

Run flutter format to format lib/hive_listener.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
flutter 0.0.0
hive ^1.4.1+1 1.4.1+1
hive_flutter ^0.3.0+2 0.3.0+2
Transitive dependencies
charcode 1.1.3
collection 1.14.12 1.14.13
convert 2.1.1
crypto 2.1.5
file 5.2.1
intl 0.16.1
meta 1.1.8 1.2.2
path 1.6.4 1.7.0
path_provider 1.6.11
path_provider_linux 0.0.1+2
path_provider_macos 0.0.4+3
path_provider_platform_interface 1.0.2
platform 2.2.1
plugin_platform_interface 1.0.2
process 3.0.13
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
xdg_directories 0.1.0