import 'package:flutter/foundation.dart'; import '../models/scooter_state.dart'; /// Result of a local scooter authentication attempt. /// /// A missing response is deliberately NOT a value here: it surfaces as a /// [TimeoutException] so callers can tell "wrong PIN" from "no answer". enum AuthenticationResult { success, invalidCredential, } /// Base class for every supported scooter. /// /// The current [state] is always available synchronously and the UI rebuilds /// through [ListenableBuilder]. There is no replay problem because there is /// no stream to miss. abstract class Scooter extends ChangeNotifier { ScooterState get state; Future connect(); Future disconnect(); Future authenticate(String credential); Future lock(); Future unlock(); Future setHeadlight(bool enabled); /// True only when the implementation holds enough fresh scooter state to /// build a safe control write AND control writes are enabled for this build. bool get canWrite; /// Disconnects and releases every resource. The object is unusable after. Future disposeScooter(); } /// Thrown into any pending operation when the BLE link drops underneath it. class ScooterConnectionLostException implements Exception { const ScooterConnectionLostException([this.message = 'Connection to the scooter was lost']); final String message; @override String toString() => message; }