-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
I could be mistaken, but PersistentBottomSheetController is currently generic, PersistentBottomSheetController<T>, and the type variable, T, provides no value; it is usually void, sometimes dynamic, but should just be removed. Here are the current declarations:
class PersistentBottomSheetController<T> extends ScaffoldFeatureController<_StandardBottomSheet, T> {
const PersistentBottomSheetController._(...);
// No uses of T in the declaration.
// ...
}
class ScaffoldFeatureController<T extends Widget, U> {
// ...
final Completer<U> _completer;
Future<U> get closed => _completer.future;
// ...
}A few points:
- PersistentBottomSheetController has one constructor, which is private; all instantiations of this class are controlled from the library in which it is declared,
lib/src/material/scaffold.dart. - PersistentBottomSheetController never references T in its declaration.
- The only use for the type variable, U, on ScaffoldFeatureController, is for the private field,
Completer<U> _completer, and the associated public getter,Future<U> get closed. - The one (one) place where
PersistentBottomSheetController._()is called, is_buildBottomSheet. This function creates aCompleter<T>, but then always completes that Completer with a value ofnull(completer.complete()). There is nothing in the public API which can affect what the Completer completes with; it is alwaysnull. So,- the Completer should really be a
Completer<void>, - the returned PersistentBottomSheetController should be a
PersistentBottomSheetController<void>, and the PersistentBottomSheetController class should extendScaffoldFeatureController<_StandardBottomSheet, void>.
- the Completer should really be a
Because the constructor is private, and the type variable is unused (has no effect on any PersistentBottomSheetController instance), you'd hope it could be removed in a non-breaking change. But it's not quite so simple. Here is the public API which instantiates PersistentBottomSheetController:
PersistentBottomSheetController<T> showBottomSheet<T>(...)PersistentBottomSheetController<T> Scaffold.showBottomSheet<T>(...)
These two functions are also generic, and their type variable, T, is only used for inference to return a PersistentBottomSheetController<T>, so each function's type variable is also unused. In a complete fix, the type variables would be removed from the PersistentBottomSheetController class, and the showBottomSheet and Scaffold.showBottomSheet functions, which would be breaking, for each position in user code that explicitly specifies a type variable.
If a non-breaking (or, less breaking) intermediate change would be desirable, these functions, and even the class, could remain generic, but then literally reference that type variable in 0 places; so the functions would still have a <T>, but return a PersistentBottomSheetController<void>. The class would still have a <T>, but would extend ScaffoldFeatureController<_StandardBottomSheet, void>.