Browse Source

fix(neon,neon_files,neon_news,neon_notes): properly dispoe TextEditingController

Signed-off-by: Nikolas Rimikis <leptopoda@users.noreply.github.com>
pull/714/head
Nikolas Rimikis 1 year ago
parent
commit
1829bf1b7a
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 14
      packages/neon/neon/lib/src/utils/rename_dialog.dart
  2. 6
      packages/neon/neon_files/lib/dialogs/create_folder.dart
  3. 6
      packages/neon/neon_news/lib/dialogs/add_feed.dart
  4. 6
      packages/neon/neon_news/lib/dialogs/create_folder.dart
  5. 6
      packages/neon/neon_notes/lib/dialogs/create_note.dart
  6. 9
      packages/neon/neon_notes/lib/pages/note.dart

14
packages/neon/neon/lib/src/utils/rename_dialog.dart

@ -34,7 +34,19 @@ class _RenameDialog extends StatefulWidget {
class _RenameDialogState extends State<_RenameDialog> { class _RenameDialogState extends State<_RenameDialog> {
final formKey = GlobalKey<FormState>(); final formKey = GlobalKey<FormState>();
late final controller = TextEditingController()..text = widget.value; final controller = TextEditingController();
@override
void initState() {
controller.text = widget.value;
super.initState();
}
@override
void dispose() {
controller.dispose();
super.dispose();
}
void submit() { void submit() {
if (formKey.currentState!.validate()) { if (formKey.currentState!.validate()) {

6
packages/neon/neon_files/lib/dialogs/create_folder.dart

@ -14,6 +14,12 @@ class _FilesCreateFolderDialogState extends State<FilesCreateFolderDialog> {
final controller = TextEditingController(); final controller = TextEditingController();
@override
void dispose() {
controller.dispose();
super.dispose();
}
void submit() { void submit() {
if (formKey.currentState!.validate()) { if (formKey.currentState!.validate()) {
Navigator.of(context).pop(controller.text.split('/')); Navigator.of(context).pop(controller.text.split('/'));

6
packages/neon/neon_news/lib/dialogs/add_feed.dart

@ -42,6 +42,12 @@ class _NewsAddFeedDialogState extends State<NewsAddFeedDialog> {
); );
} }
@override
void dispose() {
controller.dispose();
super.dispose();
}
@override @override
Widget build(final BuildContext context) => ResultBuilder<List<NewsFolder>>.behaviorSubject( Widget build(final BuildContext context) => ResultBuilder<List<NewsFolder>>.behaviorSubject(
stream: widget.bloc.folders, stream: widget.bloc.folders,

6
packages/neon/neon_news/lib/dialogs/create_folder.dart

@ -14,6 +14,12 @@ class _NewsCreateFolderDialogState extends State<NewsCreateFolderDialog> {
final controller = TextEditingController(); final controller = TextEditingController();
@override
void dispose() {
controller.dispose();
super.dispose();
}
void submit() { void submit() {
if (formKey.currentState!.validate()) { if (formKey.currentState!.validate()) {
Navigator.of(context).pop(controller.text); Navigator.of(context).pop(controller.text);

6
packages/neon/neon_notes/lib/dialogs/create_note.dart

@ -19,6 +19,12 @@ class _NotesCreateNoteDialogState extends State<NotesCreateNoteDialog> {
final controller = TextEditingController(); final controller = TextEditingController();
String? selectedCategory; String? selectedCategory;
@override
void dispose() {
controller.dispose();
super.dispose();
}
void submit() { void submit() {
if (formKey.currentState!.validate()) { if (formKey.currentState!.validate()) {
Navigator.of(context).pop((controller.text, widget.category ?? selectedCategory)); Navigator.of(context).pop((controller.text, widget.category ?? selectedCategory));

9
packages/neon/neon_notes/lib/pages/note.dart

@ -15,8 +15,8 @@ class NotesNotePage extends StatefulWidget {
} }
class _NotesNotePageState extends State<NotesNotePage> { class _NotesNotePageState extends State<NotesNotePage> {
late final _contentController = TextEditingController()..text = widget.bloc.initialContent; final _contentController = TextEditingController();
late final _titleController = TextEditingController()..text = widget.bloc.initialTitle; final _titleController = TextEditingController();
final _contentFocusNode = FocusNode(); final _contentFocusNode = FocusNode();
final _titleFocusNode = FocusNode(); final _titleFocusNode = FocusNode();
bool _showEditor = false; bool _showEditor = false;
@ -36,6 +36,9 @@ class _NotesNotePageState extends State<NotesNotePage> {
handleNotesException(context, error); handleNotesException(context, error);
}); });
_contentController.text = widget.bloc.initialContent;
_titleController.text = widget.bloc.initialTitle;
_contentStreamController.stream.debounceTime(const Duration(seconds: 1)).listen(widget.bloc.updateContent); _contentStreamController.stream.debounceTime(const Duration(seconds: 1)).listen(widget.bloc.updateContent);
_titleStreamController.stream.debounceTime(const Duration(seconds: 1)).listen(widget.bloc.updateTitle); _titleStreamController.stream.debounceTime(const Duration(seconds: 1)).listen(widget.bloc.updateTitle);
_contentController.addListener(() => _contentStreamController.add(_contentController.text)); _contentController.addListener(() => _contentStreamController.add(_contentController.text));
@ -56,6 +59,8 @@ class _NotesNotePageState extends State<NotesNotePage> {
@override @override
void dispose() { void dispose() {
_contentController.dispose();
_titleController.dispose();
unawaited(_contentStreamController.close()); unawaited(_contentStreamController.close());
unawaited(_titleStreamController.close()); unawaited(_titleStreamController.close());
super.dispose(); super.dispose();

Loading…
Cancel
Save