From 62f22ef18d5bc9b6c0d09e1928bcc201802cebba Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Sat, 16 Feb 2019 19:24:54 +0100 Subject: [PATCH] Give some widgets keys This should result in a bit of a performance boost. I'm not sure if I understand the concept of keys correctly, though. --- lib/screens/note_viewer.dart | 8 ++++++-- lib/widgets/journal_list.dart | 3 +-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/screens/note_viewer.dart b/lib/screens/note_viewer.dart index 1c739f86..e8794f27 100644 --- a/lib/screens/note_viewer.dart +++ b/lib/screens/note_viewer.dart @@ -36,7 +36,11 @@ class NoteBrowsingScreenState extends State { controller: pageController, itemCount: widget.notes.length, itemBuilder: (BuildContext context, int pos) { - return NoteViewer(note: widget.notes[pos]); + var note = widget.notes[pos]; + return NoteViewer( + key: ValueKey("Viewer_" + note.filePath), + note: widget.notes[pos], + ); }, ); @@ -114,7 +118,7 @@ class NoteViewer extends StatelessWidget { final Note note; final _biggerFont = const TextStyle(fontSize: 18.0); - const NoteViewer({@required this.note}); + const NoteViewer({Key key, @required this.note}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/lib/widgets/journal_list.dart b/lib/widgets/journal_list.dart index 219b0845..393d0b82 100644 --- a/lib/widgets/journal_list.dart +++ b/lib/widgets/journal_list.dart @@ -31,7 +31,7 @@ class JournalList extends StatelessWidget { var note = notes[i]; return Dismissible( - key: Key(note.filePath), + key: ValueKey("JournalList_" + note.filePath), child: _buildRow(context, note, i), background: Container(color: Theme.of(context).accentColor), onDismissed: (direction) { @@ -60,7 +60,6 @@ class JournalList extends StatelessWidget { var textTheme = Theme.of(context).textTheme; var tile = ListTile( - key: ValueKey(journal.filePath), isThreeLine: true, title: Text( title,