Skip to content

Commit

Permalink
Merge pull request #293 from poppingmoon/dispose-text-editing-controller
Browse files Browse the repository at this point in the history
TextEditingControllerをdisposeする
  • Loading branch information
shiosyakeyakini-info authored Sep 9, 2023
2 parents 3835a71 + 7726c7f commit aa39a8a
Show file tree
Hide file tree
Showing 14 changed files with 87 additions and 3 deletions.
7 changes: 7 additions & 0 deletions lib/state_notifier/photo_edit_page/image_meta_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ class ImageMetaDialogState extends ConsumerState<ImageMetaDialog> {
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(
Expand Down
6 changes: 6 additions & 0 deletions lib/view/dialogs/note_detail_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ class NoteDetailDialogState extends ConsumerState<NoteDetailDialog> {
});
}

@override
void dispose() {
reactionTextField.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
return AlertDialog(
Expand Down
7 changes: 7 additions & 0 deletions lib/view/login_page/api_key_login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ class APiKeyLoginState extends ConsumerState<ApiKeyLogin> {
final serverController = TextEditingController();
final apiKeyController = TextEditingController();

@override
void dispose() {
serverController.dispose();
apiKeyController.dispose();
super.dispose();
}

Future<void> login() async {
try {
IndicatorView.showIndicator(context);
Expand Down
6 changes: 6 additions & 0 deletions lib/view/login_page/mi_auth_login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ class MiAuthLoginState extends ConsumerState<MiAuthLogin> {
final serverController = TextEditingController();
bool isAuthed = false;

@override
void dispose() {
serverController.dispose();
super.dispose();
}

Future<void> login() async {
try {
IndicatorView.showIndicator(context);
Expand Down
8 changes: 8 additions & 0 deletions lib/view/login_page/password_login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ class PasswordLoginState extends ConsumerState<PasswordLogin> {
final userController = TextEditingController();
final passwordController = TextEditingController();

@override
void dispose() {
serverController.dispose();
userController.dispose();
passwordController.dispose();
super.dispose();
}

Future<void> login() async {
await ref.read(accountRepository).loginAsPassword(
serverController.text, userController.text, passwordController.text);
Expand Down
6 changes: 6 additions & 0 deletions lib/view/note_create_page/cw_text_area.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ class CwTextAreaState extends ConsumerState<CwTextArea> {
});
}

@override
void dispose() {
cwController.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
ref.listen(
Expand Down
6 changes: 6 additions & 0 deletions lib/view/note_create_page/file_settings_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ class FileSettingsDialogState extends ConsumerState<FileSettingsDialog> {
isNsfw = widget.file.isNsfw;
}

@override
void dispose() {
captionController.dispose();
super.dispose();
}

String generateRandomText() {
var str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
.split("");
Expand Down
6 changes: 6 additions & 0 deletions lib/view/note_create_page/vote_area.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ class VoteContentListItemState extends ConsumerState<VoteContentListItem> {
});
}

@override
void dispose() {
controller.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
return Padding(
Expand Down
6 changes: 6 additions & 0 deletions lib/view/search_page/note_search.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ class NoteSearchState extends ConsumerState<NoteSearch> {
}
}

@override
void dispose() {
controller.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
final selectedUser = ref.watch(noteSearchUserProvider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ class TabSettingsAddDialogState extends ConsumerState<TabSettingsPage> {
}
}

@override
void dispose() {
nameController.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
return Scaffold(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ class HardMutePage extends ConsumerStatefulWidget {
class HardMutePageState extends ConsumerState<HardMutePage> {
final controller = TextEditingController();

@override
void dispose() {
controller.dispose();
super.dispose();
}

String muteValueString(List<MuteWord>? wordMutes) {
if (wordMutes == null) return "";

Expand Down
8 changes: 5 additions & 3 deletions lib/view/time_line_page/timeline_note.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand All @@ -26,10 +28,10 @@ class TimelineNoteFieldState extends ConsumerState<TimelineNoteField> {
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,
),
);
Expand Down
6 changes: 6 additions & 0 deletions lib/view/user_page/update_memo_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ class UpdateMemoDialogState extends ConsumerState<UpdateMemoDialog> {
controller.text = widget.initialMemo;
}

@override
void dispose() {
controller.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
return AlertDialog(
Expand Down
6 changes: 6 additions & 0 deletions lib/view/user_select_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ final usersSelectDialogOriginProvider =
class UserSelectContentState extends ConsumerState<UserSelectContent> {
final queryController = TextEditingController();

@override
void dispose() {
queryController.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
final origin = ref.watch(usersSelectDialogOriginProvider);
Expand Down

0 comments on commit aa39a8a

Please sign in to comment.