Just extend SyncedBloc and add toJson/fromJson methods
Changes are pushed to other devices immediately
Changes are queued and synced when connection is restored
Choose between public (shared) or private (per-user) states
Self-host or use our managed service
Firebase, Supabase, Auth0, and custom auth providers
import 'package:blocsync/blocsync.dart'; class CounterBloc extends SyncedBloc { CounterBloc() : super(0) { on((event, emit) => emit(state + 1)); on((event, emit) => emit(state - 1)); } @override int fromJson(Map json) => json['value'] as int; @override Map? toJson(int state) => {'value': state}; }
// Configure remote sync BlocSyncConfig.apiClient = ApiClient( baseUrl: Uri.parse('https://your-server.com'), apiKey: 'your_api_key', ); // Optional: Configure authentication BlocSyncConfig.authProvider = FirebaseAuthProvider();
BlocProvider( create: (context) => CounterBloc(), child: BlocBuilder( builder: (context, state) { return Text('Count: $state'); }, ), )
That's it! Your bloc state will now automatically sync across all devices.
Use blocsync.dev for hassle-free cloud hosting with:
Run your own server using the included server package for complete control over your data and infrastructure.
Start syncing your Flutter bloc states across devices in minutes with BlocSync.