daohoangson / flutter_widget_from_html

Flutter package to render html as widgets that supports hyperlink, image, audio, video, iframe and many other tags.
https://pub.dev/packages/flutter_widget_from_html
MIT License
635 stars 235 forks source link

Fix audio_player throws exception when max value is 0 #1156

Closed ngthailam closed 9 months ago

ngthailam commented 9 months ago

General:

Running on IOS simulator Closes #980 Closes #981

Describe problem:

980: Due to Slider assert constructor, when max == 0 and value == 0, it throws

The following assertion was thrown building CupertinoSlider(value: 0.0, min: 0.0, max: 0.0, dependencies: [_InheritedCupertinoTheme], state: _CupertinoSliderState#e94ea):
'package:flutter/src/cupertino/slider.dart': Failed assertion: line 334 pos 15: 'value >= 0.0 && value <= 1.0': is not true.

981: Same issue, only when back to home_page, the slider max && value is reset to 0, causing the same exception but in a different screen

🔔 This affects not just the Demo app, but anywhere which has the same html element.

Changes:

UI Evidence:

Before:

https://github.com/daohoangson/flutter_widget_from_html/assets/48094980/dd7d0016-b563-40e4-8874-4d22ff909988

After

https://github.com/daohoangson/flutter_widget_from_html/assets/48094980/8d8954fa-6ead-4a97-adb9-0f9e9c882361

ngthailam commented 9 months ago

@daohoangson Please have a look at the PR, simple fix but solves noticeable problem when running the Demo App.

codecov[bot] commented 9 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (2dc197d) 99.58% compared to head (882ee43) 99.58%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1156 +/- ## ======================================= Coverage 99.58% 99.58% ======================================= Files 72 72 Lines 4334 4335 +1 ======================================= + Hits 4316 4317 +1 Misses 18 18 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

daohoangson commented 9 months ago

This is great! I have merged the PR, thank you very much.