ApiToggle


Pub

API toggle widget - it helps not to call the API multiple times when repeatedly clicking on a widget.

Usage

Find the example wiring in the example app

Installation

Add the following line to pubspec.yaml:

dependencies:
  api_toggle: ^1.0.1

Add the following import to your Dart code:

import 'package:api_toggle/api_toggle.dart';

Api Toggle Widget

ApiToggle(
  activated: isActivated,
  delay: 1000,
  disabledChild: const Icon(
    Icons.favorite,
    color: Colors.grey,
    size: 100,
  ),
  enabledChild: const Icon(
    Icons.favorite,
    color: Colors.redAccent,
    size: 100,
  ),
  onTrigger: (activated) {
    if (activated) {
      // write functions call API
      setState(() {
        callApiCount = callApiCount + 1;
      });
    }
  },
  onTap: (activated) {
    // write other functions that are not API calls
    setState(() {
      heartCount = activated ? heartCount + 1 : heartCount - 1;
      isActivated = activated;
    });
  },
);

ScreenShots

Android

| | :------------:

Issues and feedback

Please file issues to send feedback or report a bug. Thank you!

License

MIT License

Buy Me A Coffee

Libraries

api_toggle