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
86 stars 22 forks source link

fix "Null check operator used on a null value" #124

Closed rounce closed 1 year ago

rounce commented 1 year ago

The error may occur after using updateUrlInfo for example. 2023-03-31_14-43

codecov[bot] commented 1 year ago

Codecov Report

Merging #124 (18148fc) into master (ec5d9b5) will increase coverage by 0.00%. The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #124   +/-   ##
=======================================
  Coverage   90.74%   90.74%           
=======================================
  Files          25       25           
  Lines        1134     1135    +1     
=======================================
+ Hits         1029     1030    +1     
  Misses        105      105           
Impacted Files Coverage Δ
lib/src/controllers/match_controller.dart 95.65% <100.00%> (+0.03%) :arrow_up:
lib/src/routers/router_delegate.dart 85.07% <100.00%> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

SchabanBo commented 1 year ago

Hi @rounce , Thanks for the PR. could you add test for it or give a code where I can reproduce the error, so I could write test.

rounce commented 1 year ago
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:qlevar_router/qlevar_router.dart';

import 'helpers.dart';
import 'test_widgets/test_widgets.dart';

void main() {
  QR.settings.enableDebugLog = false;
  QR.settings.enableLog = false;
  final pages = [
    QRoute(path: '/', builder: () => const Scaffold(body: WidgetOne())),
    QRoute(
        name: 'two',
        path: '/two/:id',
        builder: () => const Scaffold(body: WidgetTwo())),
    QRoute(
        name: 'three',
        path: '/three',
        builder: () => const Scaffold(body: WidgetThree())),
  ];

  testWidgets('124', (tester) async {
    QR.reset();
    await tester.pumpWidget(AppWrapper(pages));
    await QR.navigator.push('/two/1');
    QR.updateUrlInfo('/two/1/test');
    QR.updateUrlInfo('/two/1');
    await QR.navigator.push('/three');
    await QR.back();
    await QR.back();
    printCurrentHistory();
  });
}