water 1.1.0+1

  • Readme
  • Changelog
  • Example
  • Installing
  • 71
water

water pub style: pedantic license

An implementation of HydratedStorage using Hive, a fast and lightweight key-value database

Usage #

final water = await Water.getInstance();

Example #

With HydratedBlocDelegate

BlocSupervisor.delegate = await WaterDelegate.build();

Desktop #

Until path_provder supports desktop, use this fork:

path_provider_fde:
  git:
    url: https://github.com/google/flutter-desktop-embedding
    path: plugins/flutter_plugins/path_provider_fde
    ref: 4340dec47dd88206ed421d8c1c9ecdff2ba02fff

Changelog #

1.1.0+1 #

  • Moved linter config to dev_dependencies

1.1.0 #

  • Added WaterDelegate, and extension of HydratedBlocDelegate
  • Added support for desktop, web
  • Added macOS example target
  • Updated readme sample

1.0.0+2 #

  • Fixed license badge

1.0.0+1 #

  • Fixed wrong homepage

1.0.0 #

  • Added changelog
  • Bumped to major release

0.0.1 #

  • Initial release

example/lib/main.dart

import 'dart:io';

import 'package:path_provider/path_provider.dart';
import 'package:bloc/bloc.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:hydrated_bloc/hydrated_bloc.dart';
import 'package:water/water.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  Directory dir;
  if (!kIsWeb) {
    dir = await getApplicationDocumentsDirectory();
  }

  BlocSupervisor.delegate = await WaterDelegate.build(storageDirectory: dir);

  runApp(Example());
}

/// Sample bloc with an [int] event and [int] state
class SampleBloc extends HydratedBloc<int, int> {
  @override
  int get initialState => super.initialState ?? 0;

  @override
  int fromJson(Map<String, dynamic> json) => json['state'];

  @override
  Stream<int> mapEventToState(int event) async* {
    yield event;
  }

  @override
  Map<String, dynamic> toJson(int state) => {'state': state};
}

/// Example counter app
class Example extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return BlocProvider(
      create: (context) => SampleBloc(),
      child: MaterialApp(
        home: BlocBuilder<SampleBloc, int>(
          builder: (context, state) {
            return Scaffold(
              body: Center(
                child: Text('$state'),
              ),
              floatingActionButton: FloatingActionButton(
                child: Icon(Icons.add),
                onPressed: () => BlocProvider.of<SampleBloc>(context).add(state + 1),
              ),
            );
          },
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  water: ^1.1.0+1

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:water/water.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
43
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]
71
Learn more about scoring.

We analyzed this package on Apr 5, 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/src/delegate.dart.

Run flutter format to format lib/src/delegate.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.6.0 <3.0.0
flutter 0.0.0
hive ^1.1.1 1.4.1+1
hydrated_bloc ^3.0.0-dev.1 3.0.0
path_provider ^1.5.1 1.6.5
Transitive dependencies
bloc 3.0.0 4.0.0-dev.1
charcode 1.1.3
collection 1.14.11 1.14.12
convert 2.1.1
crypto 2.1.4
meta 1.1.8
path_provider_macos 0.0.4
path_provider_platform_interface 1.0.1
platform 2.2.1
plugin_platform_interface 1.0.2
rxdart 0.23.1 0.24.0-dev.1
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test
pedantic ^1.8.0