title: Dart immutability
body: <pre><code>AuthState copy({
      FirebaseUser firebaseUser,
      String token,
  
      List&lt;Map&gt; contracts,
      bool loadingContracts,
      String contractsError,
  
      List&lt;Map&gt; searchModules,
      bool loadingSearchModules,
      String searchModulesError
    }) {
      AuthState state = new AuthState(
          firebaseUser ??= this.firebaseUser,
  
          token ??= this.token,
  
          contracts ??= this.contracts,
          loadingContracts ??= this.loadingContracts,
          contractsError ??= this.contractsError,
  
          searchModules ??= this.searchModules,
          loadingSearchModules ??= this.loadingSearchModules,
          searchModulesError ??= this.searchModulesError
      );
  </code></pre>
  
  <p>I am using Redux so every time a action is dispatched you need to create a new state.</p>
  
  <p>When I use <code>??</code> and not provide a parameter the value will be set to null, so that is not what I want.
  If I use <code>??=</code> it will assign object's property to the new value.
  But it is unable to set to value to null when I explicitly set the param to <code>null</code>.</p>
  
  <p>I am walking around with this problem for a few days now. Would be amazing if someone could help me.</p>
  
  <p>Btw I am building a Flutter app with <a href="https://github.com/alexeieleusis/greencat" rel="nofollow noreferrer">https://github.com/alexeieleusis/greencat</a> as Redux library.</p>