【问题标题】:Flutter: 'package:flutter/src/cupertino/route.dart': Failed assertion: line 660 pos 12: '_backGestureController != null': is not trueFlutter:'package:flutter/src/cupertino/route.dart':断言失败:第 660 行 pos 12:'_backGestureController != null':不正确
【发布时间】:2021-03-22 14:33:13
【问题描述】:

问题:
单击后退按钮(AppBar 小部件上的默认按钮)时,有时它不起作用并且屏幕冻结。之后我必须重新启动应用程序。我还尝试用自定义图标替换后退按钮并给它 navigator.pop(context)。仍然显示相同的错误。
注意:我没有使用 Cupertino 小部件。所有软件都是最新的。

我的代码:

import 'package:flutter/material.dart';
 
class SearchLocation extends StatefulWidget {
  static const String id = 'SearchLocation';
  @override
  _SearchLocationState createState() => _SearchLocationState();
}

class _SearchLocationState extends State<SearchLocation> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Theme.of(context).cardColor,
      appBar: AppBar(
        backgroundColor: Theme.of(context).accentColor,
        title: Text(
          'Search Location',
          style: Theme.of(context).textTheme.headline1,
        ),
        leading: IconButton(
          onPressed: () => Navigator.pop(context),
          icon: Icon(
            Icons.close,
            color: Colors.black,
          ),
        ),
      ),
      body: Container(
        padding: EdgeInsets.all(8),
        child: Column(
          children: [
          ],
        ),
      ),
    );
  }
}





Error:<br>
======== Exception caught by gesture ===============================================================
The following RangeError was thrown while handling a gesture:
RangeError (index): Invalid value: Not in inclusive range 0..1: -1

When the exception was thrown, this was the stack: 
#0      List.[] (dart:core-patch/growable_array.dart:177:60)
#1      NavigatorState.didStartUserGesture (package:flutter/src/widgets/navigator.dart:3987:44)
#2      new _CupertinoBackGestureController (package:flutter/src/cupertino/route.dart:737:15)
#3      CupertinoRouteTransitionMixin._startPopGesture (package:flutter/src/cupertino/route.dart:256:12)
#4      CupertinoRouteTransitionMixin.buildPageTransitions.<anonymous closure> (package:flutter/src/cupertino/route.dart:303:36)
...
Handler: "onStart"
Recognizer: HorizontalDragGestureRecognizer#b4e39
  debugOwner: _CupertinoBackGestureDetectorState<dynamic>#2f05b
  start behavior: start
====================================================================================================

======== Exception caught by gesture ===============================================================
The following StateError was thrown while handling a gesture:
Bad state: No element

When the exception was thrown, this was the stack: 
#0      ListMixin.lastWhere (dart:collection/list.dart:180:5)
#1      NavigatorState.pop (package:flutter/src/widgets/navigator.dart:3820:40)
#2      Navigator.pop (package:flutter/src/widgets/navigator.dart:2068:27)
#3      _SearchLocationState.build.<anonymous closure> (package:fb_client/screens/search_location.dart:23:38)
#4      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:993:19)
...
Handler: "onTap"
Recognizer: TapGestureRecognizer#48bf1
  debugOwner: GestureDetector
  state: possible
  won arena
  finalPosition: Offset(24.3, 79.3)
  finalLocalPosition: Offset(24.3, 32.3)
  button: 1
  sent tap down
====================================================================================================

======== Exception caught by gesture ===============================================================
'package:flutter/src/cupertino/route.dart': Failed assertion: line 654 pos 12: '_backGestureController != null': is not true.
====================================================================================================

======== Exception caught by gesture ===============================================================
'package:flutter/src/cupertino/route.dart': Failed assertion: line 660 pos 12: '_backGestureController != null': is not true.
====================================================================================================

【问题讨论】:

  • 是的!刚刚在这里遇到了同样的问题 - 4 小时后

标签: flutter


【解决方案1】:

我认为问题出在模拟器上。当我使用 iPhone12 模拟器时,问题就来了。使用其他模拟器,代码运行良好。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-12-28
    • 2021-03-27
    • 1970-01-01
    • 2020-03-01
    • 2021-05-04
    • 2020-10-10
    • 1970-01-01
    • 2020-04-03
    相关资源
    最近更新 更多