safe_effect 0.0.1 copy "safe_effect: ^0.0.1" to clipboard
safe_effect: ^0.0.1 copied to clipboard

A Flutter utility for safely executing side-effects with lifecycle-aware guards.

example/lib/main.dart

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

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

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

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(home: HomePage());
  }
}

class HomePage extends StatelessWidget {
  const HomePage({super.key});

  @override
  Widget build(BuildContext context) {
    SafeEffect.runOnce(
      key: 'fetch_profile',
      scope: EventScope.session,
      effect: () async {
        debugPrint('Profile API called');
      },
    );

    SafeEffect.onResume(
      key: 'sync',
      debounce: const Duration(seconds: 5),
      effect: () async {
        debugPrint('App resumed');
      },
    );

    return const Scaffold(
      body: Center(child: Text('Check console logs')),
    );
  }
}
1
likes
160
points
93
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter utility for safely executing side-effects with lifecycle-aware guards.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, shared_preferences

More

Packages that depend on safe_effect