This explains how to write a simple analyzer plugin.
Create a Dart project called demo_plugin and add these dependencies to pubspec.yaml. The versions shown below should work with Dart 3.11. You might need to adapt them to your Dart version.
dependencies:
analysis_server_plugin: ^0.3.4
analyzer: ^9.0.0
analyzer_plugin: ^0.13.11