Dart event handling refactoring