diff --git a/lib/state_notifier/photo_edit_page/image_meta_dialog.dart b/lib/state_notifier/photo_edit_page/image_meta_dialog.dart index e57ac5837..b93adb29f 100644 --- a/lib/state_notifier/photo_edit_page/image_meta_dialog.dart +++ b/lib/state_notifier/photo_edit_page/image_meta_dialog.dart @@ -29,6 +29,13 @@ class ImageMetaDialogState extends ConsumerState { late final TextEditingController captionController = TextEditingController() ..text = widget.initialMeta.caption; + @override + void dispose() { + fileNameController.dispose(); + captionController.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { return AlertDialog( diff --git a/lib/view/dialogs/note_detail_dialog.dart b/lib/view/dialogs/note_detail_dialog.dart index 9dbcce9b6..57351fee7 100644 --- a/lib/view/dialogs/note_detail_dialog.dart +++ b/lib/view/dialogs/note_detail_dialog.dart @@ -52,6 +52,12 @@ class NoteDetailDialogState extends ConsumerState { }); } + @override + void dispose() { + reactionTextField.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { return AlertDialog( diff --git a/lib/view/login_page/api_key_login.dart b/lib/view/login_page/api_key_login.dart index 40c43e016..9dc6f31ba 100644 --- a/lib/view/login_page/api_key_login.dart +++ b/lib/view/login_page/api_key_login.dart @@ -19,6 +19,13 @@ class APiKeyLoginState extends ConsumerState { final serverController = TextEditingController(); final apiKeyController = TextEditingController(); + @override + void dispose() { + serverController.dispose(); + apiKeyController.dispose(); + super.dispose(); + } + Future login() async { try { IndicatorView.showIndicator(context); diff --git a/lib/view/login_page/mi_auth_login.dart b/lib/view/login_page/mi_auth_login.dart index 07346aa0c..6415b3d50 100644 --- a/lib/view/login_page/mi_auth_login.dart +++ b/lib/view/login_page/mi_auth_login.dart @@ -19,6 +19,12 @@ class MiAuthLoginState extends ConsumerState { final serverController = TextEditingController(); bool isAuthed = false; + @override + void dispose() { + serverController.dispose(); + super.dispose(); + } + Future login() async { try { IndicatorView.showIndicator(context); diff --git a/lib/view/login_page/password_login.dart b/lib/view/login_page/password_login.dart index 48cab8937..d3ca3c74b 100644 --- a/lib/view/login_page/password_login.dart +++ b/lib/view/login_page/password_login.dart @@ -17,6 +17,14 @@ class PasswordLoginState extends ConsumerState { final userController = TextEditingController(); final passwordController = TextEditingController(); + @override + void dispose() { + serverController.dispose(); + userController.dispose(); + passwordController.dispose(); + super.dispose(); + } + Future login() async { await ref.read(accountRepository).loginAsPassword( serverController.text, userController.text, passwordController.text); diff --git a/lib/view/note_create_page/cw_text_area.dart b/lib/view/note_create_page/cw_text_area.dart index c4e021e78..02e9c7527 100644 --- a/lib/view/note_create_page/cw_text_area.dart +++ b/lib/view/note_create_page/cw_text_area.dart @@ -25,6 +25,12 @@ class CwTextAreaState extends ConsumerState { }); } + @override + void dispose() { + cwController.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { ref.listen( diff --git a/lib/view/note_create_page/file_settings_dialog.dart b/lib/view/note_create_page/file_settings_dialog.dart index 530f2ccb3..d43a10d1d 100644 --- a/lib/view/note_create_page/file_settings_dialog.dart +++ b/lib/view/note_create_page/file_settings_dialog.dart @@ -35,6 +35,12 @@ class FileSettingsDialogState extends ConsumerState { isNsfw = widget.file.isNsfw; } + @override + void dispose() { + captionController.dispose(); + super.dispose(); + } + String generateRandomText() { var str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" .split(""); diff --git a/lib/view/note_create_page/vote_area.dart b/lib/view/note_create_page/vote_area.dart index 94d363f65..4830729cb 100644 --- a/lib/view/note_create_page/vote_area.dart +++ b/lib/view/note_create_page/vote_area.dart @@ -112,6 +112,12 @@ class VoteContentListItemState extends ConsumerState { }); } + @override + void dispose() { + controller.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { return Padding( diff --git a/lib/view/search_page/note_search.dart b/lib/view/search_page/note_search.dart index 9bf7a5c93..1bca1837a 100644 --- a/lib/view/search_page/note_search.dart +++ b/lib/view/search_page/note_search.dart @@ -36,6 +36,12 @@ class NoteSearchState extends ConsumerState { } } + @override + void dispose() { + controller.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { final selectedUser = ref.watch(noteSearchUserProvider); diff --git a/lib/view/settings_page/tab_settings_page/tab_settings_page.dart b/lib/view/settings_page/tab_settings_page/tab_settings_page.dart index f0c56c0ae..4bf5fcf73 100644 --- a/lib/view/settings_page/tab_settings_page/tab_settings_page.dart +++ b/lib/view/settings_page/tab_settings_page/tab_settings_page.dart @@ -85,6 +85,12 @@ class TabSettingsAddDialogState extends ConsumerState { } } + @override + void dispose() { + nameController.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { return Scaffold( diff --git a/lib/view/several_account_settings_page/hard_mute_page/hard_mute_page.dart b/lib/view/several_account_settings_page/hard_mute_page/hard_mute_page.dart index 2d5376d2d..f46cd0be9 100644 --- a/lib/view/several_account_settings_page/hard_mute_page/hard_mute_page.dart +++ b/lib/view/several_account_settings_page/hard_mute_page/hard_mute_page.dart @@ -20,6 +20,12 @@ class HardMutePage extends ConsumerStatefulWidget { class HardMutePageState extends ConsumerState { final controller = TextEditingController(); + @override + void dispose() { + controller.dispose(); + super.dispose(); + } + String muteValueString(List? wordMutes) { if (wordMutes == null) return ""; diff --git a/lib/view/time_line_page/timeline_note.dart b/lib/view/time_line_page/timeline_note.dart index 205ae9185..6af0cc4e9 100644 --- a/lib/view/time_line_page/timeline_note.dart +++ b/lib/view/time_line_page/timeline_note.dart @@ -2,7 +2,9 @@ import 'package:flutter/material.dart'; import 'package:miria/view/themes/app_theme.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -final timelineNoteProvider = Provider((ref) => TextEditingController()); +final timelineNoteProvider = + ChangeNotifierProvider.autoDispose((ref) => TextEditingController()); + final timelineFocusNode = ChangeNotifierProvider.autoDispose((ref) => FocusNode()); @@ -26,10 +28,10 @@ class TimelineNoteFieldState extends ConsumerState { return Padding( padding: const EdgeInsets.only(left: 8.0, right: 8.0), child: TextField( - focusNode: ref.read(timelineFocusNode), + focusNode: ref.watch(timelineFocusNode), keyboardType: TextInputType.multiline, maxLines: null, - controller: ref.read(timelineNoteProvider), + controller: ref.watch(timelineNoteProvider), decoration: noteStyle, ), ); diff --git a/lib/view/user_page/update_memo_dialog.dart b/lib/view/user_page/update_memo_dialog.dart index cdb8b0c13..30d4b8254 100644 --- a/lib/view/user_page/update_memo_dialog.dart +++ b/lib/view/user_page/update_memo_dialog.dart @@ -38,6 +38,12 @@ class UpdateMemoDialogState extends ConsumerState { controller.text = widget.initialMemo; } + @override + void dispose() { + controller.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { return AlertDialog( diff --git a/lib/view/user_select_dialog.dart b/lib/view/user_select_dialog.dart index 8cbeeb570..307230dab 100644 --- a/lib/view/user_select_dialog.dart +++ b/lib/view/user_select_dialog.dart @@ -45,6 +45,12 @@ final usersSelectDialogOriginProvider = class UserSelectContentState extends ConsumerState { final queryController = TextEditingController(); + @override + void dispose() { + queryController.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { final origin = ref.watch(usersSelectDialogOriginProvider);