title: How properly use the ObjectBox flutter store opening and closing?
body: <p>I am looking to define best development practices with Flutter and ObjectBox (1.1.1 -&gt; Flutter).</p>
  <p>I would like to set up an architecture composed of Repository to implement my query functions on objects stored in the database. Here is an example for an Object Person. Repositories will mainly be called from viewModels.</p>
  <pre><code>import 'package:flutter_app_best_practice/data/person_repository_interface.dart';
  import 'package:flutter_app_best_practice/model/person.dart';
  import 'package:flutter_app_best_practice/objectbox.g.dart';
  import 'package:objectbox/objectbox.dart';
  
  class PersonRepository implements IPersonRepository{
    var _store;
    late Box _box;
  
    @override
    Future&lt;List&lt;Person&gt;&gt;? getPeople() {
      List&lt;Person&gt; list = _box.getAll() as List&lt;Person&gt;;
      return Future.value(list);
    }
  
    @override
    Future&lt;void&gt;? addPerson(String name, int age) async {
      Person person = new Person();
      person.name = name;
      person.age = age;
      _box.put(person);  // Add
      return;
    }
  
    @override
    Future&lt;void&gt;? initialize() async {
      // Future&lt;Store&gt; openStore() {...} is defined in the generated objectbox.g.dart
      openStore().then((Store store) {
        _store = store;
      });
  
      _box = _store.box&lt;Person&gt;();
  
      return;
    }
  }
  </code></pre>
  <p>Here are my questions:</p>
  <ul>
  <li>Or call _store.close with this architecture ?</li>
  <li>Instead of having an Initialize function, would it be better to open the store before each transaction and then close it after the transaction is complete?</li>
  <li>Are there examples of a similar structure using this latest version of objectBox (using openStore (). Then ((Store store))</li>
  </ul>
  <p>How do you think about this implementation :</p>
  <pre><code>
  class PersonRepository implements IPersonRepository {
  
    @override
    Future&lt;List&lt;Person&gt;&gt;? getPeople() async {
      late List&lt;Person&gt; persons;
  
      await openStore().then((Store store) {
        var _box = store.box&lt;Person&gt;();
        persons = _box.getAll();
        store.close();
      });
  
      return Future.value(persons);
    }
  
    @override
    Future&lt;void&gt;? addPerson(String name, int age) async {
  
      await openStore().then((Store store) {
        var _box = store.box&lt;Person&gt;();
        Person person = new Person();
        person.name = name;
        person.age = age;
        _box.put(person);  // Add
        store.close();
      });
      
      return;
    }
  }
  
  </code></pre>