title: How singleton works in Dart?
body: <p>I am new to Dart and Flutter. While I am going through tutorials, I got that we can make singleton using factory keyword. But after that, I got this code.</p>
  
  <pre><code>class AccountService {
    static final _instance = AccountService._internal();
  
    AccountService._internal();
  
    static AccountService getInstance() {
      return _instance;
    }
  }
  </code></pre>
  
  <p>My questions.</p>
  
  <ol>
  <li>How does the code work?  </li>
  <li>when <code>getInstance()</code> get called?</li>
  <li>is <code>AccountService._internal()</code> a constructor?</li>
  <li><code>static final _instance = AccountService._internal();</code> - When this get called?</li>
  </ol>
  
  <p>Please help me</p>