title: how to avoid safety null
body: <p>in this class while declaring the constructor Repository i get this error 'Non-nullable instance field '_database' must be initialized.
  Try adding an initializer expression, or add a field initializer in this constructor, or mark it 'late'' i added late but it doesn't work the same error while declaring the static Database _database .
  this is the class Repository</p>
  <pre><code>import 'package:sqflite/sqflite.dart';
  import 'package:todo/repositories/database_connection.dart';
  class Repository {
    DatabaseConnection _databaseConnection;
  
    Repository() {
      _databaseConnection = DatabaseConnection();
    }
  
    static Database _database;
  
    Future&lt;Database&gt; get database async {
      if (_database != null) return _database;
      _database = await _databaseConnection.setDatabase();
      return _database;
    }
  
    insertData(table, data) async {
      var connection = await database;
      return await connection.insert(table,data)
    }
  </code></pre>
  <p>and this is the DatabaseConnection</p>
  <pre><code>class DatabaseConnection {
    setDatabase() async {
      var directory = await getApplicationDocumentsDirectory();
      var path = join(directory.path, 'db_todo_sqflite');
      var database =
          await openDatabase(path, version: 1, onCreate: _onCreateDatabase);
      return database;
    }
  
    _onCreateDatabase(Database database, int version) async {
      await database.execute(
          &quot;CREATE TABLE categories(id INTEGER KEY , name TEXT , descrption TEXT&quot;);
    }
  }
  </code></pre>