Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

flutter

The Problem:
On clicking the back button(default on AppBar widget), at times it doesn't work and the screen freezes. I have to restart the app after that. I also tried to replace the back button with custom icon and gave it navigator.pop(context). Still it is showing the same error.
Note: I am not using Cupertino widgets. All the softwares are up to date.

My Code:

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.
====================================================================================================
like image 306
Ujjwal Raijada Avatar asked Oct 25 '25 03:10

Ujjwal Raijada


1 Answers

I think the problem is with the simulator. The problem is coming when I am using iPhone12 simulator. With other simulators, the code is working fine.

like image 59
Ujjwal Raijada Avatar answered Oct 28 '25 03:10

Ujjwal Raijada



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!