title: Generic getter/setter in Dart?
body: <p>I need a generic way to access an object's property/getter.</p>
  
  <p>In JavaScript this can be done via</p>
  
  <pre><code>const obj = {
      foo: 'Hello World',
      bar: 123
  };
  
  const propName = 'foo';
  console.log(o[propName]); // "Hello World"
  </code></pre>
  
  <p>So, if I had a class in Dart, like the one below, how would I access a property in a generic way? Maybe with operator overloading or something?</p>
  
  <pre><code>class MyFooClass with ChangeNotifier {
    String _someText = 'Hello World';
    int _someNumber = 123;
  
    get someText =&gt; _someText;
    set someText(value) =&gt; _someText = value;
  
    get someNumber =&gt; _someNumber;
    set someNumber(value) =&gt; _someNumber = value;
  }
  
  var myFoo = MyFooClass();
  print(myFoo['someText']); // The operator '[]' isn't defined for the class 'MyFooClass'
  </code></pre>