ueman / feedback

A simple widget for getting better feedback.
https://pub.dev/packages/feedback
392 stars 94 forks source link

allow awaiting submission #181

Closed bgetsug closed 2 years ago

bgetsug commented 2 years ago

:scroll: Description

Changed the OnSubmit typedef to return a Future<void> instead of just void.

:bulb: Motivation and Context

I'm using a custom feedback sheet via BetterFeedback.feedbackBuilder and would like to be able to display a loading indicator while awaiting submission to complete. Otherwise, the UI sits on the feedback screen with no visible activity until submission completes. To the user, this may feel like the app has frozen momentarily.

:green_heart: How did you test it?

  1. My feedback widget is stateful and holds a bool isSubmitting. OnSubmit is passed to my feedback widget from FeedbackBuilder. A "Submit" button is displayed at the bottom of the sheet, which changes to a loading indicator when isSubmitting is true. It contains an onPressed similar to the following:
onPressed: () async {
  setState(() => isSubmitting = true);

  await widget.onSubmit(
    messageController.text,
    extras: <String, dynamic>{
      "subject": subjectController.text,
    },
  );

  setState(() => isSubmitting = false);
},
  1. I ran the package's tests with flutter test

:pencil: Checklist

codecov[bot] commented 2 years ago

Codecov Report

Merging #181 (1a4441c) into master (6af6b7f) will increase coverage by 0.05%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #181      +/-   ##
==========================================
+ Coverage   82.36%   82.41%   +0.05%     
==========================================
  Files          21       21              
  Lines         652      654       +2     
==========================================
+ Hits          537      539       +2     
  Misses        115      115              
Impacted Files Coverage Δ
feedback/lib/src/better_feedback.dart 97.77% <ø> (+2.22%) :arrow_up:
feedback/lib/src/feedback_bottom_sheet.dart 81.96% <100.00%> (+0.30%) :arrow_up:
feedback/lib/src/l18n/translation.dart 42.85% <0.00%> (-0.78%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update f973386...1a4441c. Read the comment docs.