mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-29 10:17:16 +08:00
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.
This commit is contained in:
@ -36,7 +36,11 @@ class NoteBrowsingScreenState extends State<NoteBrowsingScreen> {
|
|||||||
controller: pageController,
|
controller: pageController,
|
||||||
itemCount: widget.notes.length,
|
itemCount: widget.notes.length,
|
||||||
itemBuilder: (BuildContext context, int pos) {
|
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 Note note;
|
||||||
final _biggerFont = const TextStyle(fontSize: 18.0);
|
final _biggerFont = const TextStyle(fontSize: 18.0);
|
||||||
|
|
||||||
const NoteViewer({@required this.note});
|
const NoteViewer({Key key, @required this.note}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -31,7 +31,7 @@ class JournalList extends StatelessWidget {
|
|||||||
|
|
||||||
var note = notes[i];
|
var note = notes[i];
|
||||||
return Dismissible(
|
return Dismissible(
|
||||||
key: Key(note.filePath),
|
key: ValueKey("JournalList_" + note.filePath),
|
||||||
child: _buildRow(context, note, i),
|
child: _buildRow(context, note, i),
|
||||||
background: Container(color: Theme.of(context).accentColor),
|
background: Container(color: Theme.of(context).accentColor),
|
||||||
onDismissed: (direction) {
|
onDismissed: (direction) {
|
||||||
@ -60,7 +60,6 @@ class JournalList extends StatelessWidget {
|
|||||||
var textTheme = Theme.of(context).textTheme;
|
var textTheme = Theme.of(context).textTheme;
|
||||||
|
|
||||||
var tile = ListTile(
|
var tile = ListTile(
|
||||||
key: ValueKey(journal.filePath),
|
|
||||||
isThreeLine: true,
|
isThreeLine: true,
|
||||||
title: Text(
|
title: Text(
|
||||||
title,
|
title,
|
||||||
|
Reference in New Issue
Block a user