feat: fix some bugs.

dev
DebuggerX 3 years ago
parent a088f857e8
commit c567122d84

@ -287,6 +287,8 @@ class _CherryToastState extends State<CherryToast> with TickerProviderStateMixin
late Animation<Offset> offsetAnimation; late Animation<Offset> offsetAnimation;
late AnimationController slideController; late AnimationController slideController;
late BoxDecoration toastDecoration; late BoxDecoration toastDecoration;
bool _dismissed = false;
@override @override
void initState() { void initState() {
@ -311,7 +313,10 @@ class _CherryToastState extends State<CherryToast> with TickerProviderStateMixin
Timer(this.widget.toastDuration, () { Timer(this.widget.toastDuration, () {
slideController.reverse(); slideController.reverse();
Timer(this.widget.animationDuration, () { Timer(this.widget.animationDuration, () {
if (mounted) Navigator.pop(context); if (mounted && !_dismissed) {
_dismissed = true;
Navigator.pop(context);
}
}); });
}); });
} }
@ -463,7 +468,10 @@ class _CherryToastState extends State<CherryToast> with TickerProviderStateMixin
onTap: () { onTap: () {
slideController.reverse(); slideController.reverse();
Timer(this.widget.animationDuration, () { Timer(this.widget.animationDuration, () {
if (mounted) Navigator.pop(context); if (mounted && !_dismissed) {
_dismissed = true;
Navigator.pop(context);
}
}); });
}, },
child: Icon(Icons.close, color: Colors.grey[500], size: CLOSE_BUTTON_SIZE), child: Icon(Icons.close, color: Colors.grey[500], size: CLOSE_BUTTON_SIZE),

@ -52,6 +52,8 @@ class Api {
if (builder is GetStatusCodeFunc) return builder({"statusCode": resp.statusCode}); if (builder is GetStatusCodeFunc) return builder({"statusCode": resp.statusCode});
T? res; T? res;
try { try {
if (resp.statusCode != HttpStatus.ok && resp.bodyBytes.length == 0)
throw HttpErrorCode(resp.statusCode, message: 'No resp body');
var decodeBody = json.decode(utf8.decode(resp.bodyBytes)); var decodeBody = json.decode(utf8.decode(resp.bodyBytes));
res = decodeBody is Map ? builder(decodeBody) : builder({'list': decodeBody}); res = decodeBody is Map ? builder(decodeBody) : builder({'list': decodeBody});
} catch (e) { } catch (e) {

@ -6,7 +6,6 @@ import 'package:dde_gesture_manager/utils/helper.dart';
import 'package:dde_gesture_manager/utils/notificator.dart'; import 'package:dde_gesture_manager/utils/notificator.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:markdown_editor_ot/markdown_editor.dart'; import 'package:markdown_editor_ot/markdown_editor.dart';
import 'package:url_launcher/url_launcher.dart';
class DMarkdownField extends StatefulWidget { class DMarkdownField extends StatefulWidget {
const DMarkdownField({ const DMarkdownField({

@ -34,7 +34,6 @@ class _MarketWidgetState extends State<MarketWidget> {
MarketSortType _type = MarketSortType.recommend; MarketSortType _type = MarketSortType.recommend;
String? _selected; String? _selected;
String? _hovering; String? _hovering;
int _refreshKey = 0;
List<int> _likedSchemes = []; List<int> _likedSchemes = [];
@override @override

@ -23,8 +23,7 @@ class TableCellShortcutListener extends StatefulWidget {
class _TableCellShortcutListenerState extends State<TableCellShortcutListener> { class _TableCellShortcutListenerState extends State<TableCellShortcutListener> {
List<KeyNames> _shortcut = []; List<KeyNames> _shortcut = [];
bool inputMode = false; final FocusNode _focusNode = FocusNode();
FocusNode _focusNode = FocusNode();
_handleFocusChange() { _handleFocusChange() {
if (!_focusNode.hasFocus) { if (!_focusNode.hasFocus) {
@ -43,6 +42,7 @@ class _TableCellShortcutListenerState extends State<TableCellShortcutListener> {
@override @override
void initState() { void initState() {
super.initState();
var __shortcut = widget.initShortcut.split('+'); var __shortcut = widget.initShortcut.split('+');
__shortcut.forEach((name) { __shortcut.forEach((name) {
var keyNames = getPhysicalKeyNamesByRealName(name); var keyNames = getPhysicalKeyNamesByRealName(name);
@ -50,7 +50,6 @@ class _TableCellShortcutListenerState extends State<TableCellShortcutListener> {
}); });
_shortcut.sort(); _shortcut.sort();
_focusNode.addListener(_handleFocusChange); _focusNode.addListener(_handleFocusChange);
super.initState();
} }
@override @override
@ -70,8 +69,8 @@ class _TableCellShortcutListenerState extends State<TableCellShortcutListener> {
onTap: () { onTap: () {
setState(() { setState(() {
_shortcut = []; _shortcut = [];
inputMode = true;
}); });
_focusNode.requestFocus();
}, },
child: Focus( child: Focus(
autofocus: true, autofocus: true,

Loading…
Cancel
Save