title: How to listen for change within a list using flutter provider?
body: <p>I have a provider that is listening for changes to a <code>playerList</code> class:</p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'package:scam_artist/constants/PlayerColors.dart';
  import 'package:scam_artist/models/Player.dart';
  
  class PlayerList with ChangeNotifier {
    List&lt;Player&gt; _players = [];
  
    List&lt;Player&gt; get players {
      return [..._players];
    }
  
    void addPlayer(Key key, String name, int index) {
      _players.add(
          new Player(key: key, color: PlayerColors.colors[index], name: name));
      notifyListeners();
    }
  
    void editPlayerName(String newName, int index) {
      _players[index].name = newName;
      notifyListeners();
    }
  
    void editPlayerColor(Color newColor, int index) {
      _players[index].color = newColor;
      notifyListeners();
    }
  }
  </code></pre>
  
  <p>However, when I call a function to change a value to one of the <code>Player</code> objects (change name for example), the list doesn't update the object with new data.</p>
  
  <p><strong>Do I need another provider for the <code>Player</code> class? If so, how do I make the <code>PlayerList</code> provider listen for changes in the <code>Player</code> provider?</strong></p>
  
  <p>Doing a little research, I'm thinking ProxyProvider might be what I'm looking for, but I'm not sure how to implement it.</p>
  
  <p>Here's my <code>Player</code> class if that is helpful:</p>
  
  <pre><code>import 'package:flutter/material.dart';
  
  class Player {
    // id will be for database if implemented
    String uid;
    Key key;
    String name;
  
    //position is the order where the player plays
    int position;
    Color color;
    bool isTurn;
    bool isFakeArtist;
    bool isWinner;
  
    Player({this.key, this.name, this.color});
  }
  </code></pre>
  
  <p>And this is where I create the <code>ChangeNotifierProvider</code>:</p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'package:scam_artist/UserListener.dart';
  import 'package:scam_artist/models/user.dart';
  import 'package:scam_artist/providers/PlayerList.dart';
  import 'package:scam_artist/services/AuthService.dart';
  import 'package:provider/provider.dart';
  import 'package:scam_artist/views/Lobby.dart';
  
  void main() {
    runApp(MyApp());
  }
  
  class MyApp extends StatelessWidget {
    // This widget is the root of your application.
    @override
    Widget build(BuildContext context) {
      return MultiProvider(
        providers: [
          StreamProvider&lt;User&gt;.value(value: AuthService().user),
          ChangeNotifierProvider(create: (context) =&gt; PlayerList())
        ],
        child: MaterialApp(
          title: 'Flutter Demo',
          theme: ThemeData(
            primarySwatch: Colors.blue,
            visualDensity: VisualDensity.adaptivePlatformDensity,
          ),
          home: UserListener(),
          routes: {Lobby.routeName: (ctx) =&gt; Lobby()},
        ),
      );
    }
  }
  </code></pre>