Skip to content

Instantly share code, notes, and snippets.

@xinthink
Last active March 6, 2020 04:26
Show Gist options
  • Save xinthink/55c8d5ee739d729e4556ba78e53af4fc to your computer and use it in GitHub Desktop.
Save xinthink/55c8d5ee739d729e4556ba78e53af4fc to your computer and use it in GitHub Desktop.
// The editor of a [Note], also shows every detail about a single note.
class NoteEditor extends StatefulWidget {
/// Create a [NoteEditor],
/// provides an existed [note] in edit mode, or `null` to create a new one.
const NoteEditor({Key key, this.note}) : super(key: key);
final Note note;
@override
State<StatefulWidget> createState() => _NoteEditorState(note);
}
class _NoteEditorState extends State<NoteEditor> {
_NoteEditorState(Note note)
: this._note = note ?? Note(),
_originNote = note?.copy() ?? Note(),
this._titleTextController = TextEditingController(text: note?.title),
this._contentTextController = TextEditingController(text: note?.content);
...
/// Returns `true` if the note is modified.
bool get _isDirty => _note != _originNote;
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment