SchabanBo / qlevar_router

Manage you project Routes. Create nested routes. Simply navigation without context to your pages. Change only one sub widget in your page when navigating to new route.
MIT License
87 stars 22 forks source link

Crash in _BrowserAddressBarState #151

Closed BarashkovaElena closed 1 month ago

BarashkovaElena commented 3 months ago

_BrowserAddressBarState subscribes to listen to the controller, but doesn't remove listener when the widgets is destroyed. Because of that the code crashes after the widget is rebuilt whenever the current path changes. Here is a fix suggestion for browser_address_bar.dart:

  void _listener() {
    setState(() {
      controller.text = QR.currentPath;
      if (_paths.isNotEmpty && QR.currentPath != _paths.last) {
        _paths.clear();
      }
    });
  }

  @override
  void initState() {
    super.initState();
    widget._controller.addListener(_listener);
  }

  @override
  void dispose() {
    widget._controller.removeListener(_listener);
    super.dispose();
  }
SchabanBo commented 1 month ago

Thanks for the fix suggestion. I have added it.