Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NNBD] Conflicting generic type in Navigator's push methods #65938

Closed
sma opened this issue Sep 16, 2020 · 4 comments · Fixed by #65997
Closed

[NNBD] Conflicting generic type in Navigator's push methods #65938

sma opened this issue Sep 16, 2020 · 4 comments · Fixed by #65997
Labels
f: routes Navigator, Router, and related APIs. framework flutter/packages/flutter repository. See also f: labels. P0 Critical issues such as a build break or regression

Comments

@sma
Copy link

sma commented Sep 16, 2020

In class Navigator, there is Future<T> push<T>(Route<T> route) and static Future<T> push<T extends Object>(BuildContext context, Route<T> route). The latter restricts T to a subclass of Object which means that a Route<void> doesn't work here. I think, it should be possible to use such a route with both variants. The same if true for other variants of push or replace.

If there is a reason for not allowing Route<void> this should be documented, I think. Currently the documentation stats:

/// The type argument `T` is the route's return type, as used by
/// [currentResult], [popped], and [didPop]. The type `void` may be used if the
/// route does not return a value.
@TahaTesser TahaTesser added documentation f: routes Navigator, Router, and related APIs. framework flutter/packages/flutter repository. See also f: labels. labels Sep 16, 2020
@ndawod
Copy link

ndawod commented Sep 16, 2020

This is a recent change (horrible decision, btw) in Fluter -- it was possible to use void just yesterday.

The same can be said about many of the changes from today's upgrade. Apps are breaking because of the nullability changes.

@sma
Copy link
Author

sma commented Sep 16, 2020

Some time ago I ported a 7000 LOC app to NNBD and now I regularly check the progress and this was the first problem so far. Therefore, I can't deny or confirm other breakage :) I was able to work around this problem by using Navigator.of(context).push() and my app still runs. BTW, I don't think this is a documentation bug but a a typing error.

@goderbauer
Copy link
Member

/cc @a14n @chunhtai

I agree that Route<void> still needs to be allowed.

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 12, 2021
@flutter-triage-bot flutter-triage-bot bot added P0 Critical issues such as a build break or regression and removed P2 labels Jun 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
f: routes Navigator, Router, and related APIs. framework flutter/packages/flutter repository. See also f: labels. P0 Critical issues such as a build break or regression
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants