attach method
Called once per Dart isolate before anything else. A new generation
tells the native side a hot restart happened: drop every listener and
pending callback from the previous isolate.
Implementation
@override
Future<void> attach(int generation, Map<String, Object?> settings) async {
if (attachedGenerations.isNotEmpty &&
attachedGenerations.last != generation) {
// A new isolate: drop what the previous one left running.
await _closePositions();
}
attachedGenerations.add(generation);
await configure(settings);
}