TechproCar class
Controls what the car display shows, on CarPlay and Android Auto.
final car = TechproCar.instance;
await car.setRoot(CarListTemplate(
title: 'Stores',
items: [
CarListItem(
title: 'Main Street',
showsChevron: true,
onSelect: () => car.push(CarInfoTemplate(
title: 'Main Street',
rows: [CarInfoRow(label: 'Open', value: '9:00 – 18:00')],
)),
),
],
));
The car keeps a stack of screens: setRoot sets the first one, push adds one on top and pop goes back. When the driver uses the car's own Back button, stack follows, and listeners are notified. Listen to this object (it is a ChangeNotifier) to keep a phone UI in sync.
The methods can be called before a car is connected: the screens are shown as soon as one connects. When the car disconnects, every screen except the root is dropped.
Calls run one after another, in the order they were made, so
car.push(a); car.pop(); works without await. Errors are reported
through the returned future, so await it or add a catchError when
a call can fail.
- Inheritance
-
- Object
- ChangeNotifier
- TechproCar
Properties
- alert → CarAlert?
-
The alert on screen, if any.
no setter
- connection → CarConnection
-
Whether a car display is connected, and which kind.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
-
onConnectionChanged
→ Stream<
CarConnection> -
Emits whenever a car display connects or disconnects.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
stack
→ List<
CarTemplate> -
The screens on the car display, root first. The last one is visible.
no setter
- topTemplate → CarTemplate?
-
The visible screen, or
nullbefore setRoot is called.no setter
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
dismissAlert(
) → Future< void> - Closes the alert, if one is shown.
-
dispose(
) → void -
Discards any resources used by the object.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
pop(
) → Future< void> - Goes back to the previous screen. Does nothing when only the root is shown.
-
popToRoot(
) → Future< void> - Goes back to the root screen.
-
push(
CarTemplate template) → Future< void> -
Shows
templateon top of the current screen, closing the alert if one is open. -
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
setRoot(
CarTemplate template) → Future< void> -
Replaces all screens, and any alert, with
template. -
showAlert(
CarAlert alert) → Future< void> -
Shows
alerton top of the current screen. It closes by itself when one of its buttons is tapped. -
toString(
) → String -
A string representation of this object.
inherited
-
update(
CarTemplate template) → Future< void> -
Replaces the shown screen that has the same
idastemplate.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- instance → TechproCar
-
The shared controller.
no setter
Static Methods
-
resetForTesting(
) → void -
Drops the shared controller, so that the next instance starts empty
and uses the current
TechproCarPlatform.instance.