Skip to content

Getting Started

Sudhi S edited this page Jul 28, 2026 · 1 revision

Getting Started

Install

flutter pub add native_datastore

or add to pubspec.yaml:

dependencies:
  native_datastore: ^1.6.0

First read/write

import 'package:native_datastore/native_datastore.dart';

final store = NativeDatastore();

await store.setString('username', 'sudhi');
await store.setInt('loginCount', 42);
await store.setBool('darkMode', true);

final name  = await store.getString('username');   // 'sudhi'
final count = await store.getInt('loginCount');     // 42

All operations are async (they cross a platform channel), so await them. Missing keys return null — see Handling Null Values.

Supported types

String, bool, int, double, List<String>, Uint8List, DateTime, and Map<String, dynamic>. See Storage Details for how each maps onto the native store.

Coming from shared_preferences?

The API is intentionally similar; you can also import existing values in one call:

final imported = await store.migrateFromSharedPreferences();

Full guide: Migrating from shared_preferences.

Next

Clone this wiki locally