flutter_block_store 0.0.2 copy "flutter_block_store: ^0.0.2" to clipboard
flutter_block_store: ^0.0.2 copied to clipboard

PlatformAndroid

Flutter Block Store is a library for storing and retrieving data using the Blockstore service. It provides methods to save, retrieve, and delete data from the blockstore.

example/lib/main.dart

import 'dart:developer';

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

import 'package:flutter/services.dart';
import 'package:flutter_block_store/flutter_block_store.dart';

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

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final _flutterBlockStorePlugin = FlutterBlockStore();
  String key = 'test1';
  String key2 = 'test2';
  String res = '';

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              Text(
                res,
                textAlign: TextAlign.center,
              ),
              ElevatedButton(
                onPressed: () async {
                  res = (await _flutterBlockStorePlugin.save(
                    key: key,
                    value: 'test ygy',
                  ))
                      .toString();

                  setState(() {});
                },
                child: const Text('save'),
              ),
              ElevatedButton(
                onPressed: () async {
                  res = (await _flutterBlockStorePlugin.save(
                    key: key2,
                    value: 'test oke',
                  ))
                      .toString();

                  setState(() {});
                },
                child: const Text('save 2'),
              ),
              ElevatedButton(
                onPressed: () async {
                  res = (await _flutterBlockStorePlugin.retrieve(
                    key: key,
                  ))
                      .toString();

                  setState(() {});
                },
                child: const Text('retrieve'),
              ),
              ElevatedButton(
                onPressed: () async {
                  res =
                      (await _flutterBlockStorePlugin.retrieveAll()).toString();

                  setState(() {});
                },
                child: const Text('retrieve All'),
              ),
              ElevatedButton(
                onPressed: () async {
                  res = (await _flutterBlockStorePlugin.delete(
                    key: key,
                  ))
                      .toString();
                  log(res.toString());
                  setState(() {});
                },
                child: const Text('delete'),
              ),
              ElevatedButton(
                onPressed: () async {
                  res = (await _flutterBlockStorePlugin.deleteAll()).toString();
                  log(res.toString());
                  setState(() {});
                },
                child: const Text('delete all'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
3
likes
130
points
22
downloads

Publisher

verified publishersaddamnur.xyz

Weekly Downloads

Flutter Block Store is a library for storing and retrieving data using the Blockstore service. It provides methods to save, retrieve, and delete data from the blockstore.

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on flutter_block_store

Packages that implement flutter_block_store