mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-26 16:46:51 +08:00
Tags AutoCompletion: Null Safety++
This commit is contained in:
@ -1,5 +1,3 @@
|
||||
// @dart=2.9
|
||||
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
@ -16,11 +14,11 @@ class AutoCompletionWidget extends StatefulWidget {
|
||||
final Widget child;
|
||||
|
||||
AutoCompletionWidget({
|
||||
@required this.textFieldFocusNode,
|
||||
@required this.textFieldKey,
|
||||
@required this.textFieldStyle,
|
||||
@required this.textController,
|
||||
@required this.child,
|
||||
required this.textFieldFocusNode,
|
||||
required this.textFieldKey,
|
||||
required this.textFieldStyle,
|
||||
required this.textController,
|
||||
required this.child,
|
||||
});
|
||||
|
||||
@override
|
||||
@ -28,7 +26,7 @@ class AutoCompletionWidget extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _AutoCompletionWidgetState extends State<AutoCompletionWidget> {
|
||||
OverlayEntry overlayEntry;
|
||||
OverlayEntry? overlayEntry;
|
||||
|
||||
var autoCompleter = TagsAutoCompleter();
|
||||
|
||||
@ -83,7 +81,8 @@ class _AutoCompletionWidgetState extends State<AutoCompletionWidget> {
|
||||
|
||||
//print('showOverlaidTag: $newText');
|
||||
|
||||
RenderBox renderBox = widget.textFieldKey.currentContext.findRenderObject();
|
||||
RenderBox renderBox =
|
||||
widget.textFieldKey.currentContext!.findRenderObject() as RenderBox;
|
||||
// print("render Box: ${renderBox.size}");
|
||||
|
||||
TextPainter painter = TextPainter(
|
||||
@ -135,7 +134,7 @@ class _AutoCompletionWidgetState extends State<AutoCompletionWidget> {
|
||||
),
|
||||
);
|
||||
});
|
||||
Overlay.of(context).insert(overlayEntry);
|
||||
Overlay.of(context)!.insert(overlayEntry!);
|
||||
|
||||
// Removes the over lay entry from the Overly after 500 milliseconds
|
||||
await Future.delayed(5000.milliseconds);
|
||||
@ -144,7 +143,7 @@ class _AutoCompletionWidgetState extends State<AutoCompletionWidget> {
|
||||
|
||||
void _hideOverlay() {
|
||||
if (overlayEntry != null) {
|
||||
overlayEntry.remove();
|
||||
overlayEntry!.remove();
|
||||
overlayEntry = null;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,3 @@
|
||||
// @dart=2.9
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
@ -30,8 +28,8 @@ abstract class EditorState with ChangeNotifier {
|
||||
}
|
||||
|
||||
class TextEditorState {
|
||||
String text;
|
||||
int cursorPos;
|
||||
late String text;
|
||||
late int cursorPos;
|
||||
|
||||
TextEditorState(this.text, this.cursorPos);
|
||||
|
||||
@ -56,17 +54,17 @@ class EditorAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
final Editor editor;
|
||||
final EditorState editorState;
|
||||
final bool noteModified;
|
||||
final IconButton extraButton;
|
||||
final IconButton? extraButton;
|
||||
final bool allowEdits;
|
||||
final Func0<void> onEditingModeChange;
|
||||
|
||||
EditorAppBar({
|
||||
Key key,
|
||||
@required this.editor,
|
||||
@required this.editorState,
|
||||
@required this.noteModified,
|
||||
@required this.allowEdits,
|
||||
@required this.onEditingModeChange,
|
||||
Key? key,
|
||||
required this.editor,
|
||||
required this.editorState,
|
||||
required this.noteModified,
|
||||
required this.allowEdits,
|
||||
required this.onEditingModeChange,
|
||||
this.extraButton,
|
||||
}) : preferredSize = const Size.fromHeight(kToolbarHeight),
|
||||
super(key: key);
|
||||
@ -85,7 +83,7 @@ class EditorAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
},
|
||||
),
|
||||
actions: <Widget>[
|
||||
if (extraButton != null) extraButton,
|
||||
if (extraButton != null) extraButton!,
|
||||
IconButton(
|
||||
icon: allowEdits
|
||||
? const Icon(Icons.remove_red_eye)
|
||||
|
@ -1,5 +1,3 @@
|
||||
// @dart=2.9
|
||||
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
@ -23,7 +21,7 @@ class EditorScaffold extends StatefulWidget {
|
||||
final EditorState editorState;
|
||||
final bool noteModified;
|
||||
final bool editMode;
|
||||
final IconButton extraButton;
|
||||
final IconButton? extraButton;
|
||||
final Widget body;
|
||||
final NotesFolderFS parentFolder;
|
||||
|
||||
@ -33,19 +31,19 @@ class EditorScaffold extends StatefulWidget {
|
||||
final bool undoAllowed;
|
||||
final bool redoAllowed;
|
||||
|
||||
final Widget extraBottomWidget;
|
||||
final Widget? extraBottomWidget;
|
||||
|
||||
EditorScaffold({
|
||||
@required this.editor,
|
||||
@required this.editorState,
|
||||
@required this.noteModified,
|
||||
@required this.editMode,
|
||||
@required this.body,
|
||||
@required this.parentFolder,
|
||||
@required this.onUndoSelected,
|
||||
@required this.onRedoSelected,
|
||||
@required this.undoAllowed,
|
||||
@required this.redoAllowed,
|
||||
required this.editor,
|
||||
required this.editorState,
|
||||
required this.noteModified,
|
||||
required this.editMode,
|
||||
required this.body,
|
||||
required this.parentFolder,
|
||||
required this.onUndoSelected,
|
||||
required this.onRedoSelected,
|
||||
required this.undoAllowed,
|
||||
required this.redoAllowed,
|
||||
this.extraBottomWidget,
|
||||
this.extraButton,
|
||||
});
|
||||
@ -57,13 +55,13 @@ class EditorScaffold extends StatefulWidget {
|
||||
class _EditorScaffoldState extends State<EditorScaffold> {
|
||||
var hideUIElements = false;
|
||||
var editingMode = true;
|
||||
Note note;
|
||||
late Note note;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
SchedulerBinding.instance
|
||||
SchedulerBinding.instance!
|
||||
.addPostFrameCallback((_) => _initStateWithContext());
|
||||
}
|
||||
|
||||
@ -146,7 +144,7 @@ class _EditorScaffoldState extends State<EditorScaffold> {
|
||||
log("local section link: " + section.toString());
|
||||
},
|
||||
onSectionLongPress: (OrgSection section) {
|
||||
log('local section long-press: ' + section.headline.rawTitle);
|
||||
log('local section long-press: ' + section.headline.rawTitle!);
|
||||
},
|
||||
);
|
||||
break;
|
||||
@ -201,14 +199,14 @@ class _EditorScaffoldState extends State<EditorScaffold> {
|
||||
}
|
||||
});
|
||||
},
|
||||
metaDataEditable: note != null ? note.canHaveMetadata : false,
|
||||
metaDataEditable: note.canHaveMetadata,
|
||||
onUndoSelected: widget.onUndoSelected,
|
||||
onRedoSelected: widget.onRedoSelected,
|
||||
undoAllowed: widget.undoAllowed,
|
||||
redoAllowed: widget.redoAllowed,
|
||||
),
|
||||
),
|
||||
if (widget.extraBottomWidget != null) widget.extraBottomWidget,
|
||||
if (widget.extraBottomWidget != null) widget.extraBottomWidget!,
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -220,7 +218,7 @@ class _AnimatedOpacityIgnorePointer extends StatelessWidget {
|
||||
final bool visible;
|
||||
final Widget child;
|
||||
|
||||
_AnimatedOpacityIgnorePointer({@required this.visible, @required this.child});
|
||||
_AnimatedOpacityIgnorePointer({required this.visible, required this.child});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -1,5 +1,3 @@
|
||||
// @dart=2.9
|
||||
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import 'package:gitjournal/editors/autocompletion_widget.dart';
|
||||
|
Reference in New Issue
Block a user