shared_preferences_red 0.2.9

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 49

Don't use it!

[0.2.4+1] - 2017-06-05

  • Fixed typo in changelog

[0.2.4] - 2017-06-04

  • Added setMockInitialValues
  • Added a test
  • Updated README

[0.2.3] - 2017-06-02

  • Suppress warning about unchecked operations when compiling for Android

[0.2.2] - 2017-05-17

  • BREAKING CHANGE: setStringSet API changed to setStringList and plugin now supports ordered storage.

[0.2.1] - 2017-05-17

  • Support arbitrary length integers for setInt.

[0.2.0+1] - 2017-05-16

  • Updated README

[0.2.0] - 2017-05-10

  • Upgrade to new plugin registration. (https://groups.google.com/forum/#!topic/flutter-dev/zba1Ynf2OKM)

[0.1.1] - 2017-05-09

  • Upgrade Android SDK Build Tools to 25.0.3.

[0.1.0] - 2017-05-05

  • Initial Open Source release.

example/lib/main.dart

// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:async';

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'SharedPreferences Demo',
      home: new SharedPreferencesDemo(),
    );
  }
}

class SharedPreferencesDemo extends StatefulWidget {
  SharedPreferencesDemo({Key key}) : super(key: key);

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

class SharedPreferencesDemoState extends State<SharedPreferencesDemo> {
  Future<SharedPreferences> _prefs = SharedPreferences.getInstance();

  Future<Null> _incrementCounter() async {
    final SharedPreferences prefs = await _prefs;
    final int counter = (prefs.getInt('counter') ?? 0) + 1;
    setState(() {
      prefs.setInt("counter", counter);
    });
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: const Text("SharedPreferences Demo"),
      ),
      body: new Center(
          child: new FutureBuilder<SharedPreferences>(
              future: _prefs,
              builder: (BuildContext context,
                  AsyncSnapshot<SharedPreferences> snapshot) {
                if (snapshot.connectionState == ConnectionState.waiting)
                  return const Text('Loading...');
                final int counter = snapshot.requireData.getInt('counter') ?? 0;
                // ignore: prefer_const_constructors
                return new Text(
                  'Button tapped $counter time${ counter == 1 ? '' : 's' }.\n\n'
                      'This should persist across restarts.',
                );
              })),
      floatingActionButton: new FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: new Icon(Icons.add),
      ),
    );
  }
}

1. Depend on it

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


dependencies:
  shared_preferences_red: "^0.2.9"

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:shared_preferences_red/shared_preferences_red.dart';
        
Version Uploaded Documentation Archive
0.2.9 Aug 12, 2017 Go to the documentation of shared_preferences_red 0.2.9 Download shared_preferences_red 0.2.9 archive
0.2.8 Aug 11, 2017 Go to the documentation of shared_preferences_red 0.2.8 Download shared_preferences_red 0.2.8 archive
0.2.7 Aug 11, 2017 Go to the documentation of shared_preferences_red 0.2.7 Download shared_preferences_red 0.2.7 archive
0.2.6 Aug 11, 2017 Go to the documentation of shared_preferences_red 0.2.6 Download shared_preferences_red 0.2.6 archive
0.2.5 Aug 11, 2017 Go to the documentation of shared_preferences_red 0.2.5 Download shared_preferences_red 0.2.5 archive
0.2.4+1 Aug 11, 2017 Go to the documentation of shared_preferences_red 0.2.4+1 Download shared_preferences_red 0.2.4+1 archive

Analysis

This feature is new.
We welcome feedback.

We analyzed this package, and provided a score, details, and suggestions below.

  • completed on Dec 6, 2017
  • Dart: 2.0.0-dev.8.0
  • pana: 0.7.3+1
  • Flutter: 0.0.19

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
93
Overall score:
Weighted score of the above. [more]
49

Platforms

Detected platforms: Flutter

pubspec reference with no conflicts

Suggestions

  • Maintain README.md.

    Readme should inform others about your project, what it does, and how they can use it.

Dependencies

Package Constraint Resolved Available
Direct dependencies
flutter 0.0.39
meta ^1.0.4 1.1.1 1.1.2
Transitive dependencies
async 1.13.3 2.0.1
charcode 1.1.1
collection 1.14.3
http 0.11.3+14 0.11.3+16
http_parser 3.1.1
path 1.5.1
sky_engine 0.0.99
source_span 1.4.0
stack_trace 1.9.1
string_scanner 1.0.2
typed_data 1.1.4 1.1.5
vector_math 2.0.5
Dev dependencies
mockito ^2.0.2
test 0.12.21