conditional_trigger 0.5.1+1 copy "conditional_trigger: ^0.5.1+1" to clipboard
conditional_trigger: ^0.5.1+1 copied to clipboard

Make it easier for you to set the conditions (such as min days or min calls) for specific method or widget.

example/lib/main.dart

import 'package:conditional_trigger/conditional_trigger.dart';
import 'package:flutter/material.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 bannerSurvey = const ConditionalTrigger('BannerSurvey', debugLog: true);
  final announce = const ConditionalTrigger('Announce', debugLog: true);

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

  void initial() async {
    if (await announce.checkOnce() == ConditionalState.satisfied) {
      if (mounted) {
        showDialog(
          context: context,
          builder: (_) => const AlertDialog(
            title: Text('Announce'),
            content: Text('This is an announcement'),
          ),
        );
      }
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: FutureBuilder(
            future: bannerSurvey.checkOnce(),
            builder: (ctx, snapshot) {
              if (!snapshot.hasData) {
                return SizedBox.fromSize();
              }

              return const Text('This is a survey banner');
            }),
      ),
    );
  }
}
3
likes
160
pub points
5%
popularity

Publisher

verified publisherlamnhan.dev

Make it easier for you to set the conditions (such as min days or min calls) for specific method or widget.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, package_info_plus, satisfied_version, shared_preferences

More

Packages that depend on conditional_trigger