title: How to access arrayList values through getter in another class by using Bloc - Flutter
body: <p>I'm trying to get arrayList data into another class through getter with the help of <code>blocProvider</code> but here in another class it gives following error:</p>
  <pre><code>The getter 'value' isn't defined for the type 'BehaviorSubject&lt;List&lt;Medicine&gt;&gt;'.
  Try importing the library that defines 'value', correcting the name to the name of an existing getter, or defining a getter or field named 'value'
  </code></pre>
  <p><strong>Here is Bloc class where I defied <code>getter</code> to get arrayList values</strong></p>
  <pre><code>class GlobalBloc {
    BehaviorSubject&lt;List&lt;Medicine&gt;&gt; _medicineList$;
    BehaviorSubject&lt;List&lt;Medicine&gt;&gt; get medicineList$ =&gt; _medicineList$; //getter  &lt;--
  
  
    GlobalBloc() {
      _medicineList$ = BehaviorSubject&lt;List&lt;Medicine&gt;&gt;.seeded([]);
      makeMedicineList();
    }
  
  
    Future makeMedicineList() async {
      SharedPreferences sharedUser = await SharedPreferences.getInstance();
      List&lt;String&gt; jsonList = sharedUser.getStringList('medicines');
      List&lt;Medicine&gt; prefList = [];
      if (jsonList == null) {
        return;
      } else {
        for (String jsonMedicine in jsonList) {
          Map userMap = jsonDecode(jsonMedicine);
          Medicine tempMedicine = Medicine.fromJson(userMap);
          prefList.add(tempMedicine);
        }
        _medicineList$.add(prefList);
      }
    }
  
    void dispose() {
      _medicineList$.close();
    }
  }
  </code></pre>
  <p><strong>Here is my another class where I'm trying to get arrayList values</strong></p>
  <pre><code>@override
    Widget build(BuildContext context) {
      final GlobalBloc _globalBloc = Provider.of&lt;GlobalBloc&gt;(context);
  
  ... 
  
   for (var medicine in _globalBloc.medicineList$.value) { //ERROR &lt;--
          if (medicineName == medicine.medicineName) {
               return;
          }
   }
                       
  }
  </code></pre>
  <p><strong>ERROR looks like this</strong></p>
  <p><a href="https://i.stack.imgur.com/ihE84.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ihE84.png" alt="enter image description here" /></a></p>