file_io_interface 0.1.1+1

  • Readme
  • Changelog
  • Example
  • Installing
  • new56

file_io_interface #

This implements the IO Interface class from the Abstract IO package using files and path provider

Getting Started #

start by creating an Abstract IO object and using either StringFileInterface or ByteFileInterface as the IOInterface

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

  • updated example app to latest version

[0.1.1] - 6/20/20. #

  • updated requestData function to not throw FileNotFound exception

[0.1.0] - 6/20/20. #

  • first release

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:
  file_io_interface: ^0.1.1+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:file_io_interface/file_io_interface.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
11
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]
56
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 does not support Flutter platform Android

Because:

  • package:file_io_interface/file_io_interface.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:file_io_interface/file_io_interface.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:file_io_interface/file_io_interface.dart that imports:
  • package:path_provider/path_provider.dart that declares support for platforms: Android, iOS, Linux, macOS

Package does not support Flutter platform iOS

Because:

  • package:file_io_interface/file_io_interface.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:file_io_interface/file_io_interface.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 not compatible with SDK dart

Because:

  • file_io_interface that is a package requiring null.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
abstract_io ^0.1.1+2 0.1.1+2
flutter 0.0.0
path_provider ^1.6.9 1.6.11
Transitive dependencies
collection 1.14.12 1.14.13
file 5.2.1
intl 0.16.1
meta 1.1.8 1.2.2
path 1.7.0
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