title: how to check function name in dart
body: <p>I found this answer, but this is not working because this is road syntax.
  I want to check if there is a function with the same name as the hash attribute in python.</p>
  <pre><code>import 'dart:mirrors';
  
  class Test {
    method1() =&gt; &quot;hello&quot;;
  }
  
  main() {
    print(existsFunction(&quot;main&quot;)); // true
    print(existsFunction(&quot;main1&quot;)); // false
    print(existsMethodOnObject(new Test(), &quot;method1&quot;)); // true
    print(existsMethodOnObject(new Test(), &quot;method2&quot;)); // false
  }
  
  bool existsFunction(String functionName) =&gt; currentMirrorSystem().isolate
      .rootLibrary.functions.containsKey(functionName);
  
  bool existsMethodOnObject(Object o, String method) =&gt; reflect(o).type.methods
      .containsKey(method); 
  </code></pre>