Commit 457ac44701cb2c7594eb2105f0e3c4895b87d5b2

Authored by 吴启风
1 parent 5647d1be

feat:代码优化-空条件调用

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