bfs_manager 0.0.23 copy "bfs_manager: ^0.0.23" to clipboard
bfs_manager: ^0.0.23 copied to clipboard

Offline-first Flutter sync SDK for SQLite ↔ server. Simple API: init, register/login, save/edit/remove, and sync.

example/README.md

Example — Easy table create + sync (bfs_manager) #

Easiest: init with tables: (auto DB) #

Developer ને અલગ CREATE TABLE SQL લખવાની જરૂર નથી. uuid TEXT PRIMARY KEY SDK આપમેળે ઉમેરે છે.

import 'package:flutter/widgets.dart';
import 'package:bfs_manager/bfs_manager.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await BfsManager.instance.init(
    baseUrl: 'https://your-api.com/api',
    dbName: 'my_app.db',
    dbVersion: 1,
    tables: {
      // table name → { column: SQL type }
      'tb_tasks': {
        'title': 'TEXT',
        'status': 'TEXT',
        'image_path': 'TEXT', // single or multiple images (List / JSON)
      },
      'tb_reminder': {
        'title': 'TEXT',
        'description': 'TEXT',
        'reminder_datetime': 'INTEGER',
        'is_complete': 'INTEGER',
      },
      'tb_category': {
        'name': 'TEXT',
        'color_value': 'INTEGER',
        'icon_path': 'TEXT',
      },
    },
  );

  runApp(const MyApp());
}

SQL અંદર આવું બને છે:

CREATE TABLE IF NOT EXISTS tb_tasks (
  uuid TEXT PRIMARY KEY,
  title TEXT,
  status TEXT,
  image_path TEXT
);

Full demo flow #

Future<void> demoFlow() async {
  // Guest mode — local + queue (no login)
  await BfsManager.instance.save('tb_tasks', {
    'title': 'Guest task',
    'status': 'pending',
  });

  // Register / Login
  await BfsManager.instance.register(
    {
      'name': 'Ashok',
      'email': 'ashok@example.com',
      'password': 'secret123',
    },
    onSuccess: (_) async {
      // Push guest queue + pull server data
      await BfsManager.instance.sync(type: BfsSyncType.push);
      await BfsManager.instance.sync(type: BfsSyncType.all);
    },
  );

  // Single file
  await BfsManager.instance.save('tb_tasks', {
    'title': 'One photo',
    'status': 'pending',
    'image_path': '/path/photo.jpg',
  });

  // Multiple files
  await BfsManager.instance.save('tb_tasks', {
    'title': 'Gallery',
    'status': 'pending',
    'image_path': [
      '/path/photo1.jpg',
      '/path/photo2.jpg',
    ],
  });

  // Everyday sync
  await BfsManager.instance.sync();
}

Optional: open DB separately #

final db = await BfsManager.openDatabase(
  name: 'my_app.db',
  version: 1,
  tables: {
    'tb_tasks': {
      'title': 'TEXT',
      'status': 'TEXT',
    },
  },
);

await BfsManager.instance.init(
  baseUrl: 'https://your-api.com/api',
  appDatabase: db,
);

Add a new table later #

  1. dbVersion વધારો (12)
  2. tables map માં નવી table ઉમેરો
await BfsManager.instance.init(
  baseUrl: '...',
  dbVersion: 2, // bump
  tables: {
    'tb_tasks': { 'title': 'TEXT', 'status': 'TEXT' },
    'tb_notes': { 'body': 'TEXT' }, // new
  },
);

SDK CREATE TABLE IF NOT EXISTS વાપરે છે — નવી table auto create થાય.

See ../doc/developer_guide.md for full docs.

0
likes
140
points
47
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Offline-first Flutter sync SDK for SQLite ↔ server. Simple API: init, register/login, save/edit/remove, and sync.

Homepage
Repository (GitHub)
View/report issues

Topics

#sync #sqlite #offline #flutter #laravel

License

MIT (license)

Dependencies

flutter, fluttertoast, http, path, shared_preferences, sqflite, uuid

More

Packages that depend on bfs_manager