abstract_io 0.1.1+2

  • Readme
  • Changelog
  • Example
  • Installing
  • new52

Abstract IO #

This Package is designed to simplify and generalize saving data. Because Abstract IO is meant to generalize saving data both localy and externaly no specific implementation is provided in this package. As of the time I'm writting this local file storage and storage for firebase has been implemented.

The very base of this package is the Abstract_IO object, which takes a Translator and an IOInterface. The translator translates the data from it's saved type into whatever type you decide, this often will have to be implemented by you. The IOInterface provides a way for Abstract_IO to send and recieve data from wherever it is stored, some IOInterfaces have been implenented in seperate packages and you are free to create your own

For more in depth information look at the documention. At the time of writing documentation is complete.

Getting Started #

start by importing abstract_io.dart and extending Abstract_IO, consider using either the ValueStorage mixin or the ValueFetcher mixin both of which complete the functionality of Abstract_IO

[0.1.1+2] - 6/20/2020 #

  • made sure example app was working and updated its pubspec.yaml to reflect the latest version

[0.1.1+1] - 6/20/2020 #

  • fix to translators so that translateWritable can handle a null value
  • fix to ValueAccess so that setting value works properly now

[0.1.1] - 6/20/2020 #

  • added example app
  • lots of little tweaks for formating and dart doc
  • changes to automatic notifying and saving system in ValueStorage
  • updated some code to support IOInterface not throwing errors during requestData

[0.1.0] - 6/19/2020 #

  • initial release of Abstract IO

example/lib/main.dart

import 'package:file_io_interface/file_io_interface.dart';
import 'package:flutter/material.dart';
import 'package:abstract_io/abstract_io.dart';

/// the translator used for [Counter]
class StringIntTranslator extends Translator<String, int>{
  @override
  String translateReadable(int readable) {
    return "$readable";
  }

  @override
  int translateWritable(String writable) {
    if(writable == null){
      return null;
    }
    return int.parse(writable);
  }
}

/// counts a value and stores it in a file
/// 
/// gives an initial value of 0
class Counter extends AbstractIO<String, int> with ValueStorage, ValueAccess, ValueListenableSupport, InitialValue{

  Counter(
    String filePath
  ):super(
    StringFileInterface(filePath),
    translator: StringIntTranslator()
  );

  @override
  int get initialValue => 0;

}



void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

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

  final String title;

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

class _MyHomePageState extends State<MyHomePage> {
  Counter _count;

  // increments the value in the counter
  void _incrementCounter() {
    _count.value += 1;
  }

  @override
  void initState() {
    _count = Counter("counter");
    _count.load();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'You have pushed the button this many times:',
            ),

            // listens to the counter object and rebuilds whenever the value is updated
            ValueListenableBuilder(
              valueListenable: _count, 
              builder: (context, count, child){
                return Text(
                  "$count",
                  style: Theme.of(context).textTheme.headline6,
                );
              }
            )
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        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:
  abstract_io: ^0.1.1+2

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:abstract_io/abstract_io.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
4
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]
52
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 not compatible with SDK dart

Because:

  • abstract_io that is a package requiring null.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.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