Commit 457ac44701cb2c7594eb2105f0e3c4895b87d5b2
1 parent
5647d1be
feat:代码优化-空条件调用
Showing
8 changed files
with
15 additions
and
19 deletions
lib/common/utils/click_with_music_controller.dart
| @@ -23,7 +23,7 @@ class ClickWithMusicController { | @@ -23,7 +23,7 @@ class ClickWithMusicController { | ||
| 23 | ///@param action 可以是同步函数也可以是异步函数 | 23 | ///@param action 可以是同步函数也可以是异步函数 | 
| 24 | Future<void> playMusicAndPerformAction(BuildContext? context, | 24 | Future<void> playMusicAndPerformAction(BuildContext? context, | 
| 25 | AudioPlayerUtilType audioType, FutureOr<void> Function() action) async { | 25 | AudioPlayerUtilType audioType, FutureOr<void> Function() action) async { | 
| 26 | - Log.d("$TAG playMusicAndPerformAction _isPlaying=$_isPlaying"); | 26 | + Log.d("$TAG playMusicAndPerformAction _isPlaying=$_isPlaying audioType=$audioType"); | 
| 27 | ///todo 是否需要考虑打断覆盖能力 | 27 | ///todo 是否需要考虑打断覆盖能力 | 
| 28 | if (_isPlaying) return; | 28 | if (_isPlaying) return; | 
| 29 | 29 | 
lib/common/widgets/throttledGesture_gesture_detector.dart
| @@ -24,9 +24,7 @@ class _ThrottledGestureDetectorState extends State<ThrottledGestureDetector> { | @@ -24,9 +24,7 @@ class _ThrottledGestureDetectorState extends State<ThrottledGestureDetector> { | ||
| 24 | 24 | ||
| 25 | void _handleTap() { | 25 | void _handleTap() { | 
| 26 | if (!_isThrottled) { | 26 | if (!_isThrottled) { | 
| 27 | - if (widget.onTap != null) { | ||
| 28 | - widget.onTap!(); | ||
| 29 | - } | 27 | + widget.onTap?.call(); | 
| 30 | _isThrottled = true; | 28 | _isThrottled = true; | 
| 31 | Timer(Duration(milliseconds: widget.throttleTime), () { | 29 | Timer(Duration(milliseconds: widget.throttleTime), () { | 
| 32 | _isThrottled = false; | 30 | _isThrottled = false; | 
lib/common/widgets/we_app_bar.dart
| @@ -41,7 +41,7 @@ class WEAppBar extends StatelessWidget implements PreferredSizeWidget { | @@ -41,7 +41,7 @@ class WEAppBar extends StatelessWidget implements PreferredSizeWidget { | ||
| 41 | if (onBack == null) { | 41 | if (onBack == null) { | 
| 42 | Navigator.pop(context); | 42 | Navigator.pop(context); | 
| 43 | } else { | 43 | } else { | 
| 44 | - onBack!(); | 44 | + onBack?.call(); | 
| 45 | } | 45 | } | 
| 46 | }, | 46 | }, | 
| 47 | child: Container( | 47 | child: Container( | 
lib/pages/reading/bloc/reading_bloc.dart
| @@ -6,7 +6,6 @@ import 'package:flutter_bloc/flutter_bloc.dart'; | @@ -6,7 +6,6 @@ import 'package:flutter_bloc/flutter_bloc.dart'; | ||
| 6 | import 'package:flutter_easyloading/flutter_easyloading.dart'; | 6 | import 'package:flutter_easyloading/flutter_easyloading.dart'; | 
| 7 | import 'package:flutter_screenutil/flutter_screenutil.dart'; | 7 | import 'package:flutter_screenutil/flutter_screenutil.dart'; | 
| 8 | import 'package:permission_handler/permission_handler.dart'; | 8 | import 'package:permission_handler/permission_handler.dart'; | 
| 9 | -import 'package:wow_english/common/extension/string_extension.dart'; | ||
| 10 | import 'package:wow_english/pages/reading/widgets/ReadingModeType.dart'; | 9 | import 'package:wow_english/pages/reading/widgets/ReadingModeType.dart'; | 
| 11 | import 'package:wow_english/pages/section/subsection/base_section/bloc.dart'; | 10 | import 'package:wow_english/pages/section/subsection/base_section/bloc.dart'; | 
| 12 | import 'package:wow_english/pages/section/subsection/base_section/event.dart'; | 11 | import 'package:wow_english/pages/section/subsection/base_section/event.dart'; | 
| @@ -16,7 +15,6 @@ import '../../../common/core/user_util.dart'; | @@ -16,7 +15,6 @@ import '../../../common/core/user_util.dart'; | ||
| 16 | import '../../../common/permission/permissionRequester.dart'; | 15 | import '../../../common/permission/permissionRequester.dart'; | 
| 17 | import '../../../common/request/dao/listen_dao.dart'; | 16 | import '../../../common/request/dao/listen_dao.dart'; | 
| 18 | import '../../../common/request/exception.dart'; | 17 | import '../../../common/request/exception.dart'; | 
| 19 | -import '../../../common/utils/click_with_music_controller.dart'; | ||
| 20 | import '../../../common/utils/show_star_reward_dialog.dart'; | 18 | import '../../../common/utils/show_star_reward_dialog.dart'; | 
| 21 | import '../../../models/course_process_entity.dart'; | 19 | import '../../../models/course_process_entity.dart'; | 
| 22 | import '../../../models/singsound_result_detail_entity.dart'; | 20 | import '../../../models/singsound_result_detail_entity.dart'; | 
| @@ -339,7 +337,7 @@ class ReadingPageBloc | @@ -339,7 +337,7 @@ class ReadingPageBloc | ||
| 339 | color: detail.score > 80 | 337 | color: detail.score > 80 | 
| 340 | ? const Color(0XFF35C137) | 338 | ? const Color(0XFF35C137) | 
| 341 | : const Color(0xFF333333), | 339 | : const Color(0xFF333333), | 
| 342 | - fontSize: 20.sp, | 340 | + fontSize: 18.sp, | 
| 343 | ), | 341 | ), | 
| 344 | ); | 342 | ); | 
| 345 | }).toList(); | 343 | }).toList(); | 
lib/pages/reading/reading_page.dart
| @@ -189,8 +189,8 @@ class _ReadingPage extends StatelessWidget { | @@ -189,8 +189,8 @@ class _ReadingPage extends StatelessWidget { | ||
| 189 | ), | 189 | ), | 
| 190 | RecorderWidget( | 190 | RecorderWidget( | 
| 191 | isPlaying: bloc.isRecording, | 191 | isPlaying: bloc.isRecording, | 
| 192 | - width: 60.w, | ||
| 193 | - height: 60.w, | 192 | + width: 54.w, | 
| 193 | + height: 54.w, | ||
| 194 | onTap: () { | 194 | onTap: () { | 
| 195 | if (bloc.isRecording) { | 195 | if (bloc.isRecording) { | 
| 196 | bloc.add(XSVoiceStopEvent()); | 196 | bloc.add(XSVoiceStopEvent()); | 
| @@ -200,9 +200,6 @@ class _ReadingPage extends StatelessWidget { | @@ -200,9 +200,6 @@ class _ReadingPage extends StatelessWidget { | ||
| 200 | } | 200 | } | 
| 201 | }, | 201 | }, | 
| 202 | ), | 202 | ), | 
| 203 | - SizedBox( | ||
| 204 | - width: 10.w, | ||
| 205 | - ), | ||
| 206 | GestureDetector( | 203 | GestureDetector( | 
| 207 | onTap: () { | 204 | onTap: () { | 
| 208 | if (bloc.isRecording) { | 205 | if (bloc.isRecording) { | 
| @@ -216,8 +213,8 @@ class _ReadingPage extends StatelessWidget { | @@ -216,8 +213,8 @@ class _ReadingPage extends StatelessWidget { | ||
| 216 | bloc.isRecordAudioPlaying | 213 | bloc.isRecordAudioPlaying | 
| 217 | ? 'record_pause'.assetWebp | 214 | ? 'record_pause'.assetWebp | 
| 218 | : 'record_play'.assetWebp, | 215 | : 'record_play'.assetWebp, | 
| 219 | - height: 33.h, | ||
| 220 | - width: 33.w, | 216 | + height: 35.h, | 
| 217 | + width: 35.h, | ||
| 221 | ), | 218 | ), | 
| 222 | )), | 219 | )), | 
| 223 | // RecorderPlaybackWidget( | 220 | // RecorderPlaybackWidget( | 
| @@ -229,6 +226,9 @@ class _ReadingPage extends StatelessWidget { | @@ -229,6 +226,9 @@ class _ReadingPage extends StatelessWidget { | ||
| 229 | // bloc.add(PlayRecordAudioEvent()); | 226 | // bloc.add(PlayRecordAudioEvent()); | 
| 230 | // }, | 227 | // }, | 
| 231 | // ) | 228 | // ) | 
| 229 | + SizedBox( | ||
| 230 | + width: 10.w, | ||
| 231 | + ) | ||
| 232 | ], | 232 | ], | 
| 233 | ), | 233 | ), | 
| 234 | ), | 234 | ), | 
lib/pages/section/subsection/base_section/bloc.dart
| @@ -39,7 +39,7 @@ abstract class BaseSectionBloc<E extends BaseSectionEvent, | @@ -39,7 +39,7 @@ abstract class BaseSectionBloc<E extends BaseSectionEvent, | ||
| 39 | child: GestureDetector( | 39 | child: GestureDetector( | 
| 40 | onTap: () { | 40 | onTap: () { | 
| 41 | popPage(); | 41 | popPage(); | 
| 42 | - againSectionTap!(); | 42 | + againSectionTap?.call(); | 
| 43 | }, | 43 | }, | 
| 44 | child: Image.asset('section_finish_again'.assetPng), | 44 | child: Image.asset('section_finish_again'.assetPng), | 
| 45 | ), | 45 | ), | 
| @@ -53,7 +53,7 @@ abstract class BaseSectionBloc<E extends BaseSectionEvent, | @@ -53,7 +53,7 @@ abstract class BaseSectionBloc<E extends BaseSectionEvent, | ||
| 53 | child: GestureDetector( | 53 | child: GestureDetector( | 
| 54 | onTap: () { | 54 | onTap: () { | 
| 55 | popPage(); | 55 | popPage(); | 
| 56 | - nextSectionTap!(); | 56 | + nextSectionTap?.call(); | 
| 57 | }, | 57 | }, | 
| 58 | child: Image.asset('section_finish_next'.assetPng), | 58 | child: Image.asset('section_finish_next'.assetPng), | 
| 59 | ), | 59 | ), | 
lib/pages/section/widgets/section_header_widget.dart
| @@ -32,7 +32,7 @@ class SectionHeaderWidget extends StatelessWidget { | @@ -32,7 +32,7 @@ class SectionHeaderWidget extends StatelessWidget { | ||
| 32 | if (onBack == null) { | 32 | if (onBack == null) { | 
| 33 | Navigator.pop(context); | 33 | Navigator.pop(context); | 
| 34 | } else { | 34 | } else { | 
| 35 | - onBack!(); | 35 | + onBack?.call(); | 
| 36 | } | 36 | } | 
| 37 | }, | 37 | }, | 
| 38 | child: Container( | 38 | child: Container( | 
lib/pages/unit/widget/home_tab_header_widget.dart
| @@ -45,7 +45,7 @@ class HomeTabHeaderWidget extends StatelessWidget { | @@ -45,7 +45,7 @@ class HomeTabHeaderWidget extends StatelessWidget { | ||
| 45 | if (onBack == null) { | 45 | if (onBack == null) { | 
| 46 | Navigator.pop(context); | 46 | Navigator.pop(context); | 
| 47 | } else { | 47 | } else { | 
| 48 | - onBack!(); | 48 | + onBack?.call(); | 
| 49 | } | 49 | } | 
| 50 | }, | 50 | }, | 
| 51 | child: Container( | 51 | child: Container( | 
