api_toggle 1.0.1 copy "api_toggle: ^1.0.1" to clipboard
api_toggle: ^1.0.1 copied to clipboard

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

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

4
likes
150
points
23
downloads

Publisher

unverified uploader

Weekly Downloads

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

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on api_toggle