title: ChangeNotifier - How to Update or Rebuild a constructor List Dynamically?
body: <p>Below is my code which is mostly working as intended (please copy paste all in 1 dart page then run).</p>
  <p>I have 3 variables of a value to display (rankOne, rankTwo and rankThree). I want to change these values depending on the user's input.</p>
  <p>I was able to implement it, but I am struggling with updating the List to display the new values on screen.
  I would appreciate your time to help me fix or re-implement this.</p>
  <p><a href="https://i.stack.imgur.com/nFRDw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nFRDw.png" alt="enter image description here" /></a></p>
  <pre><code>import 'package:flutter/material.dart';
  import 'package:provider/provider.dart';
  
  void main() {
    runApp(MyApp());
  }
  
  class MyApp extends StatelessWidget {
    // This widget is the root of your application.
    @override
    Widget build(BuildContext context) {
      return ChangeNotifierProvider(
        create: (context) {
          return MyStore();
        },
        child: MaterialApp(
          debugShowCheckedModeBanner: false,
          title: 'ChangeNotifier Practice4',
          theme: ThemeData.dark(),
          home: TimeSheetPage(title: 'Time Sheet'),
        ),
      );
    }
  }
  
  class TimeSheet {
    int id;
    String name;
    double timeValue;
    TimeSheet({this.id, this.name, this.timeValue});
  }
  
  class MyStore extends ChangeNotifier {
    List&lt;TimeSheet&gt; _timeSheet = [];
    int _people = 3;
    double rankOne = 20.98;
    double rankTwo = 15.62;
    double rankThree = 10.43;
  
    MyStore() {
      _timeSheet = [
        TimeSheet(
          id: 0,
          name: &quot;Task Type A&quot;,
          timeValue: rankOne,
        ),
        TimeSheet(
          id: 1,
          name: &quot;Task Type B&quot;,
          timeValue: rankTwo,
        ),
        TimeSheet(
          id: 2,
          name: &quot;Task Type C&quot;,
          timeValue: rankThree,
        ),
      ];
      notifyListeners();
    }
  
    List&lt;TimeSheet&gt; get timeSheet =&gt; _timeSheet;
    int get people =&gt; _people;
  
    setNumberOfPeople(peoples) {
      _people = peoples;
      switch (peoples) {
        case 0:
          double rankOne = 0.0;
          double rankTwo = 0.0;
          double rankThree = 0.0;
          print(&quot;setNumberOfPeople = 0&quot;);
          print('$rankOne, $rankTwo, $rankThree');
          notifyListeners();
          break;
        case 1:
          double rankOne = 15.98;
          double rankTwo = 13.21;
          double rankThree = 7.92;
          print(&quot;setNumberOfPeople = 1&quot;);
          print('$rankOne, $rankTwo, $rankThree');
          notifyListeners();
          break;
        case 2:
          double rankOne = 18.64;
          double rankTwo = 12.32;
          double rankThree = 8.76;
          print(&quot;setNumberOfPeople = 2&quot;);
          print('$rankOne, $rankTwo, $rankThree');
          notifyListeners();
          break;
        case 3:
          double rankOne = 20.98;
          double rankTwo = 15.62;
          double rankThree = 10.43;
          print(&quot;setNumberOfPeople = 3&quot;);
          print('$rankOne, $rankTwo, $rankThree');
          notifyListeners();
          break;
      }
    }
  }
  
  class TimeSheetPage extends StatefulWidget {
    TimeSheetPage({Key key, this.title}) : super(key: key);
    final String title;
    @override
    _TimeSheetPageState createState() =&gt; _TimeSheetPageState();
  }
  
  class _TimeSheetPageState extends State&lt;TimeSheetPage&gt; {
    List&lt;int&gt; peopleNumbers = [
      0,
      1,
      2,
      3,
    ];
  
    @override
    Widget build(BuildContext context) {
      var store = Provider.of&lt;MyStore&gt;(context);
      return Scaffold(
          appBar: AppBar(
            title: Text(widget.title),
          ),
          body: Column(
            children: [
              Row(
                crossAxisAlignment: CrossAxisAlignment.center,
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Text(
                    'Number of People: ',
                    style: TextStyle(
                      color: Colors.black,
                      fontSize: 18,
                      fontWeight: FontWeight.w500,
                    ),
                  ),
                  DropdownButton&lt;int&gt;(
                    value: store.people,
                    onChanged: (int value) {
                      store.setNumberOfPeople(peopleNumbers[value]);
                    },
                    items: peopleNumbers.map((int num) {
                      return DropdownMenuItem&lt;int&gt;(
                        value: num,
                        child: Row(
                          children: &lt;Widget&gt;[
                            Icon(
                              Icons.people,
                            ),
                            SizedBox(
                              width: 10,
                            ),
                            Text(
                              num.toString(),
                              style: TextStyle(color: Colors.black),
                            ),
                          ],
                        ),
                      );
                    }).toList(),
                  ),
                ],
              ),
              ListView.builder(
                shrinkWrap: true,
                itemCount: store.timeSheet.length,
                itemBuilder: (context, index) {
                  return Container(
                    decoration: BoxDecoration(
                      border: Border(
                        top: BorderSide(
                          color: Colors.black,
                          width: 0.2,
                        ),
                        bottom: BorderSide(
                          color: Colors.black,
                          width: 0.2,
                        ),
                      ),
                    ),
                    child: ListTile(
                      title: Text(
                        store.timeSheet[index].name,
                      ),
                      trailing: Row(
                        mainAxisSize: MainAxisSize.min,
                        mainAxisAlignment: MainAxisAlignment.end,
                        crossAxisAlignment: CrossAxisAlignment.end,
                        children: [
                          Icon(Icons.timer),
                          Text(
                            '${store.timeSheet[index].timeValue}',
                          ),
                        ],
                      ),
                      onTap: () {
                        print(store.timeSheet[index].timeValue);
                      },
                    ),
                  );
                },
              ),
            ],
          ));
    }
  }
  </code></pre>