Skip to main content

bfs_manager 0.0.22 copy "bfs_manager: ^0.0.22" to clipboard
bfs_manager: ^0.0.22 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 usage (bfs_manager) #

Minimal pattern used by apps that depend on this package.

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

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

  final db = await openDatabase(
    'demo.db',
    version: 1,
    onCreate: (db, version) async {
      await db.execute('''
        CREATE TABLE tb_tasks (
          uuid TEXT PRIMARY KEY,
          title TEXT,
          status TEXT,
          image_path TEXT
        )
      ''');
    },
  );

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

Future<void> demoFlow() async {
  await BfsManager.instance.login(
    {'email': 'demo@example.com', 'password': 'secret123'},
    onSuccess: (_) async {
      await BfsManager.instance.sync(type: BfsSyncType.all);
    },
  );

  final row = await BfsManager.instance.save('tb_tasks', {
    'title': 'Hello sync',
    'status': 'pending',
  });

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

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

  // Or JSON string for TEXT columns
  await BfsManager.instance.save('tb_tasks', {
    'title': 'Gallery JSON',
    'status': 'pending',
    'image_path': '["/path/a.jpg","/path/b.jpg"]',
  });

  await BfsManager.instance.edit('tb_tasks', {
    'uuid': row['uuid'],
    'status': 'done',
  });

  await BfsManager.instance.sync();
}

See ../doc/developer_guide.md for the full guide (including multiple file uploads).

0
likes
0
points
1.13k
downloads

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

unknown (license)

Dependencies

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

More

Packages that depend on bfs_manager