Skip to content

Commit

Permalink
perf: dispose some TextEditingController manually
Browse files Browse the repository at this point in the history
  • Loading branch information
MSOB7YY committed Dec 13, 2023
1 parent cc8b3f0 commit c0ed850
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 1 deletion.
7 changes: 7 additions & 0 deletions lib/ui/dialogs/edit_tags_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ Future<void> showSetYTLinkCommentDialog(List<Track> tracks, Color colorScheme) a
final ytlink = singleTrack.youtubeLink;
controller.text = ytlink;
NamidaNavigator.inst.navigateDialog(
onDisposing: () {
controller.dispose();
ytSearchController.dispose();
},
colorScheme: colorScheme,
dialogBuilder: (theme) => Form(
key: formKey,
Expand Down Expand Up @@ -246,6 +250,9 @@ Future<void> _editSingleTrackTagsDialog(Track track, Color colorScheme) async {
canEditTags.close();
didAutoExtractFromFilename.close();
currentImagePath.close();
for (final c in tagsControllers.values) {
c.dispose();
}
},
scale: 0.94,
colorScheme: colorScheme,
Expand Down
10 changes: 10 additions & 0 deletions lib/ui/dialogs/general_popup_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ Future<void> showGeneralPopupDialog(
final title = isTags ? lang.SET_TAGS : lang.SET_MOODS;
final subtitle = lang.SET_MOODS_SUBTITLE;
await openDialog(
onDisposing: () {
controller.dispose();
},
CustomBlurryDialog(
title: title,
actions: [
Expand Down Expand Up @@ -224,6 +227,9 @@ Future<void> showGeneralPopupDialog(
void setTrackRating() async {
final c = TextEditingController();
await openDialog(
onDisposing: () {
c.dispose();
},
CustomBlurryDialog(
title: lang.SET_RATING,
actions: [
Expand Down Expand Up @@ -255,6 +261,9 @@ Future<void> showGeneralPopupDialog(
final controller = TextEditingController(text: playlistName);
final GlobalKey<FormState> formKey = GlobalKey<FormState>();
await openDialog(
onDisposing: () {
controller.dispose();
},
Form(
key: formKey,
child: CustomBlurryDialog(
Expand Down Expand Up @@ -412,6 +421,7 @@ Future<void> showGeneralPopupDialog(
onDisposing: () {
filteredPaths.close();
shouldCleanUp.close();
txtc.dispose();
},
CustomBlurryDialog(
title: lang.CHOOSE,
Expand Down
2 changes: 2 additions & 0 deletions lib/ui/dialogs/set_lrc_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ void showLRCSetDialog(Track track, Color colorScheme) async {
await NamidaNavigator.inst.navigateDialog(
onDisposing: () {
newOffset.closeAfterDelay();
offsetController.dispose();
},
colorScheme: colorScheme,
dialogBuilder: (theme) => CustomBlurryDialog(
Expand Down Expand Up @@ -311,6 +312,7 @@ void showLRCSetDialog(Track track, Color colorScheme) async {
fetchedLyrics.close();
selectedLyrics.close();
expandedLyrics.close();
searchController.dispose();
},
colorScheme: colorScheme,
dialogBuilder: (theme) => CustomBlurryDialog(
Expand Down
3 changes: 3 additions & 0 deletions lib/ui/dialogs/setting_dialog_with_text_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ Future<void> showSettingDialogWithTextField({
void onTTSetChange() => onTrackTileSettingsChanged?.call();

await NamidaNavigator.inst.navigateDialog(
onDisposing: () {
controller.dispose();
},
dialog: Form(
key: formKey,
child: CustomBlurryDialog(
Expand Down
2 changes: 2 additions & 0 deletions lib/ui/dialogs/track_advanced_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,8 @@ void showLibraryTracksChooseDialog({
onDisposing: () {
allTracksList.close();
selectedTrack.close();
searchController.dispose();
focusNode.dispose();
},
colorScheme: colorScheme,
dialogBuilder: (theme) => CustomBlurryDialog(
Expand Down
2 changes: 2 additions & 0 deletions lib/ui/widgets/settings/advanced_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,8 @@ class UpdateDirectoryPathListTile extends StatelessWidget {
NamidaNavigator.inst.navigateDialog(
onDisposing: () {
updateMissingOnly.close();
oldDirController.dispose();
newDirController.dispose();
},
colorScheme: colorScheme,
dialogBuilder: (theme) => Form(
Expand Down
1 change: 1 addition & 0 deletions lib/ui/widgets/settings/indexer_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,7 @@ class IndexerSettings extends SettingSubpageProvider {
NamidaNavigator.inst.navigateDialog(
onDisposing: () {
updatingLibrary.close();
separatorsController.dispose();
},
onDismissing: isBlackListDialog
? null
Expand Down
3 changes: 2 additions & 1 deletion lib/youtube/functions/add_to_playlist_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void showAddToPlaylistSheet({

await Future.delayed(Duration.zero); // delay bcz sometimes doesnt show
// ignore: use_build_context_synchronously
showModalBottomSheet(
await showModalBottomSheet(
useRootNavigator: true,
backgroundColor: Colors.transparent,
context: context,
Expand Down Expand Up @@ -151,4 +151,5 @@ void showAddToPlaylistSheet({
);
},
);
controller.disposeAfterAnimation();
}
3 changes: 3 additions & 0 deletions lib/youtube/functions/video_download_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ Future<void> showVideoDownloadOptionsSheet({
);
},
);
for (final c in controllersMap.values) {
c.dispose();
}
}

class YTDownloadOptionFolderListTile extends StatefulWidget {
Expand Down

0 comments on commit c0ed850

Please sign in to comment.