As you know there are some pre-defined rules for linter, but I wonder how can I define a custom linter rule for flutter and dart?
You would need to write a plugin for the analysis server, but the docs caution:
Note: The plugin support is not currently available for general use.
Just in case you want to ignore that, look at the analyzer docs at: https://pub.dev/packages/analyzer_plugin and the linter docs at: https://github.com/dart-lang/linter/blob/master/doc/WritingLints.MD