foss42 / apidash

API Dash is a beautiful open-source cross-platform API Client built using Flutter which can help you easily create & customize your API requests, visually inspect responses and generate API integration code. A lightweight alternative to postman/insomnia.

Home Page:https://apidash.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ability to clear current response

animator opened this issue · comments

Tell us about the task you want to perform and are unable to do so because the feature is not available
There should be a small recycle bin or clear button in the response section to clear the current response.

Hi @animator
I have implemented this functionality (have attached a demo video of it).
Below is the implementation of the ClearResponseButton. Unlike all the other buttons, it extends ConsumerWidget instead of Stateless/Stateful Widget. Before I open a PR, I wanted to confirm whether this is allowed or not.
Thanks in advance

class ClearResponseButton extends ConsumerWidget {
  const ClearResponseButton({super.key});

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    var sm = ScaffoldMessenger.of(context);
    return SizedBox(
      child: TextButton(
        style: TextButton.styleFrom(minimumSize: const Size(40, 40)),
        onPressed: () {
          final selectedId = ref.watch(selectedIdStateProvider);
          ref
              .read(collectionStateNotifierProvider.notifier)
              .clearResponse(selectedId!);
          sm.hideCurrentSnackBar();
          sm.showSnackBar(
            SnackBar(
              content: const Text('Response cleared'),
              action: SnackBarAction(
                label: 'Undo',
                onPressed: () {},
              ),
            ),
          );
        },
        child: const Icon(
          Icons.delete,
          size: 20,
        ),
      ),
    );
  }
}
ApiDash.Clear.Response.Demo.mp4

@mdmohsin7 Please open a PR for review.