get_storage_wasm 2.1.3 copy "get_storage_wasm: ^2.1.3" to clipboard
get_storage_wasm: ^2.1.3 copied to clipboard

A fast, extra light and synchronous key-value storage written entirely in Dart with WebAssembly support. Based on the original get_storage package.

example/lib/main.dart

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

import 'package:get_storage_wasm/get_storage_wasm.dart';

void main() async {
  await GetStorage.init();
  runApp(App());
}

class Controller extends GetxController {
  final box = GetStorage();

  RxBool isDark = false.obs;

  @override
  void onInit() {
    super.onInit();
    isDark.value = box.read('darkmode') ?? false;
  }

  ThemeData get theme => isDark.value ? ThemeData.dark() : ThemeData.light();

  void changeTheme(bool val) {
    isDark.value = val;
    box.write('darkmode', val);
  }
}

class App extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final controller = Get.put(Controller());
    return Obx(() => GetMaterialApp(
          theme: controller.theme,
          home: Scaffold(
            appBar: AppBar(title: Text("Get Storage")),
            body: Center(
              child: SwitchListTile(
                value: controller.isDark.value,
                title: Text("Touch to change ThemeMode"),
                onChanged: controller.changeTheme,
              ),
            ),
          ),
        ));
  }
}
1
likes
150
points
122
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A fast, extra light and synchronous key-value storage written entirely in Dart with WebAssembly support. Based on the original get_storage package.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, get, path_provider

More

Packages that depend on get_storage_wasm