提交 371b60fb authored 作者: yueweilu's avatar yueweilu

优化代码

上级 886bf4f5
......@@ -49,7 +49,7 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
bool get show => _show;
// 录音
FlutterSoundRecorder _mRecorder = FlutterSoundRecorder(logLevel:Level.error);
final FlutterSoundRecorder _mRecorder = FlutterSoundRecorder(logLevel:Level.error);
// 录音开始
bool startRecording = false;
// 是否存在离线文件
......@@ -137,9 +137,7 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
contentInput.dispose();
flutterTts.stop();
searchInput.dispose();
if (_mRecorder != null) {
_mRecorder.closeRecorder();
}
_mRecorder.closeRecorder();
// 关闭防截屏
// await ScreenProtector.preventScreenshotOff();
super.onClose();
......@@ -204,7 +202,7 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
String htmlStr = EncryptUtil.aesDecrypt(content!);
Console.log('解密-----------------$htmlStr');
Console.log('-------------使用本地文件-------------------');
webViewController.loadData(data: htmlStr??'');
webViewController.loadData(data: htmlStr);
}
......@@ -273,10 +271,8 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
await flutterTts.setSpeechRate(0.5);
await flutterTts.setPitch(1.0);
if (text != null) {
if (text!.isNotEmpty) {
await flutterTts.speak(text!);
}
if (text.isNotEmpty) {
await flutterTts.speak(text);
}
}
......@@ -338,9 +334,9 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
final path = await _mRecorder.stopRecorder();
Console.log('stopRecorder-----------path---------------------$path');
if(path!=null && path.isNotEmpty){
var duration = await audioPlayer.setFilePath(path!);
var duration = await audioPlayer.setFilePath(path);
Console.log('-----duration---------------------$duration------');
AudioModel audioModel = AudioModel(path: path!,duration: Tools.formatDuration(duration!),currentDuration: '0:00:00');
AudioModel audioModel = AudioModel(path: path,duration: Tools.formatDuration(duration!),currentDuration: '0:00:00');
if(audioModel.duration !='0:00:00'){
discussInputAudios.add(audioModel);
}
......@@ -663,7 +659,7 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
}
CustomToast.dismiss();
Toast.show('离线成功');
final exit = await _isExistFile(bookId);
await _isExistFile(bookId);
update();
} else {
......@@ -774,7 +770,7 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
if (file is File && file.path.toLowerCase().endsWith('.html')) {
String fileName = path.basenameWithoutExtension(file.path);
if (int.parse(fileName.split('-').first) == findIndex){
print('HTML File--------------------------------${file.path}');
Console.log('HTML File--------------------------------${file.path}');
toReadHtmlPath = file.path;
chapterId = fileName.split('-').last;
chapterName = getChapterName(chapterId);
......@@ -884,7 +880,7 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
ChapterModel? tModel = findChapterById(chapters, int.parse(chapterId));
if(tModel != null){
updateParentsStatus(chapters, tModel!);
updateParentsStatus(chapters, tModel);
}
}
......@@ -925,7 +921,7 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
/// 添加阅读时长
void _addReadTime({required type}) async{
final result = await LibraryAPI.addReadTime(bookId: bookId, readTypes: type);
LibraryAPI.addReadTime(bookId: bookId, readTypes: type);
}
/// 获取离线文件路径
void getBookDown() async{
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论