canonical / wizard_router Goto Github PK
View Code? Open in Web Editor NEWA classic linear wizard router for Flutter
Home Page: https://pub.dev/packages/wizard_router
License: BSD 3-Clause "New" or "Revised" License
A classic linear wizard router for Flutter
Home Page: https://pub.dev/packages/wizard_router
License: BSD 3-Clause "New" or "Revised" License
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
This repository currently has no open or pending branches.
.github/workflows/ci.yaml
actions/checkout v3
subosito/flutter-action v2
actions/checkout v3
subosito/flutter-action v2
codecov/codecov-action v3
actions/checkout v3
subosito/flutter-action v2
actions/checkout v3
subosito/flutter-action v2
actions/checkout v3
subosito/flutter-action v2
actions/checkout v3
subosito/flutter-action v2
actions/checkout v3
subosito/flutter-action v2
.github/workflows/pr.yaml
.github/workflows/release.yaml
example/pubspec.yaml
flutter_markdown ^0.6.2
provider ^6.0.0
flutter_lints ^2.0.0
pubspec.yaml
collection ^1.15.0
flow_builder ^0.0.9
safe_change_notifier ^0.3.0
flutter_lints ^2.0.0
By dynamically set I mean wizards that skip certain routes, like when we set the inital route to other than the first element of the routes map. In such cases the widget._index
counts the number of routes that we actually passed by (not counting the ones we skipped), thus the comparison returns true even for the last element of the routes map.
/// Returns `false` if the wizard page is the last page.
bool get hasNext => widget._index < widget._routes.length - 1;
The test case below demonstrate the behavior reported. It consists with three routes, where the second is set as initial. The third (and last) route checks for Wizard.of(context).hasNext
, but that is not enough to prevent calling next()
from the last route, thus causing an assertion failure.
testWidgets('hasNext returns false for the last route', (tester) async {
await pumpWizardApp(
tester,
initialRoute: Routes.second,
routes: {
Routes.first: WizardRoute(builder: (_) => const Text(Routes.first)),
Routes.second: WizardRoute(
builder: (context) => ElevatedButton(
child: Text(Routes.second), onPressed: Wizard.of(context).next),
),
Routes.third: WizardRoute(
builder: (context) => TextButton(
child: Text(Routes.third),
onPressed: () {
final wiz = Wizard.of(context);
// Third should never call next() because it's the last route.
if (wiz.hasNext) wiz.next();
},
),
),
},
);
// We are on the second route.
await tester.tap(find.byType(ElevatedButton));
await tester.pumpAndSettle();
//Now we should be on the third
expect(find.text(Routes.first), findsNothing);
expect(find.text(Routes.second), findsNothing);
expect(find.text(Routes.third), findsOneWidget);
// Nothing should happen now:
await tester.tap(find.byType(TextButton));
await tester.pumpAndSettle();
expect(find.text(Routes.first), findsNothing);
expect(find.text(Routes.second), findsNothing);
expect(find.text(Routes.third), findsOneWidget);
});
00:02 +3: hasNext should return false for the last route
══╡ EXCEPTION CAUGHT BY GESTURE ╞══════════════════════════════════════════════════════════════════
The following assertion was thrown while handling a gesture:
`Wizard.next()` called from the last route /third.
'package:wizard_router/src/scope.dart':
Failed assertion: line 103 pos 14: 'index < widget._routes.length - 1'
The solution is baked inside the WizardScope.next()
method. Unfortunately that will make the hasNext getter to be more expensive.
If the controller has been disposed when the execution returns from an asynchronous callback, it must not call ChangeNotifier.notifyListeners()
which throws if already disposed...
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following assertion was thrown running a test (but after the test had completed):
A WizardController was used after being disposed.
Once you have called dispose() on a WizardController, it can no longer be used.
When the exception was thrown, this was the stack:
#0 ChangeNotifier.debugAssertNotDisposed.<anonymous closure> (package:flutter/src/foundation/change_notifier.dart:179:9)
#1 ChangeNotifier.debugAssertNotDisposed (package:flutter/src/foundation/change_notifier.dart:186:6)
#2 ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:382:27)
#3 WizardController._loadRoute (package:wizard_router/src/controller.dart:30:28)
2
<asynchronous suspension>
(elided one frame from package:stack_trace)
════════════════════════════════════════════════════════════════════════════════════════════════════
This is the classic reason why we're using safe_change_notifier all around but I'm not sure if we want to pull it as a dependency here...
Idea:
WizardObserver
that wraps NavigatorObserver
and offers next/back/done instead of push/pop operationsWizard.of(context).done()
from any page where the wizard endsWizardScopeState.done()
merely calls Wizard.onDone()
and WizardObserver.onDone()
done()
could optionally accept a result argMotivation:
Wizard.done()
in all last pages and TelemetryService.done()
could be called from one place i.e. the observerImported from canonical/ubuntu-flutter-plugins#31
Thanks for creating this package. It is so much easier to use than FlowBuilder when managing non-linear flows.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.