title: How to implement Singleton pattern in Dart using factory constructors?
body: <p>I'm trying to implement the singleton pattern in a database helper class, but, I can't seem to understand the purpose of a factory constructor and if there's an alternative method to using it. </p>
  
  <pre><code>class DbHelper {
  
           final String tblName ='';
           final String clmnName ='';
           final String clmnPass='';
  
           DbHelper._constr();
           static final DbHelper _db = new DbHelper._constr();
  
           factory DbHelper(){ return _db;}  
  
           Database _mydb;
           Future&lt;Database&gt; get mydb async{
  
           initDb() {
            if(_mydb != null)
            {
                return _mydb;
            }
            _mydb = await  initDb();
            return _mydb;
           }
  </code></pre>