title: Flutter/Dart - Unhandled Exception: type 'String' is not a subtype of type 'int' of 'index'
body: <p>I'm a beginner at Flutter and I'm currently following along with a tutorial to built a task planner (<a href="https://www.youtube.com/watch?v=xJSestoFlJ8&amp;list=PLF9bFmu3NqWqchwS3DO9MDSl15IiHQWcr&amp;index=9" rel="nofollow noreferrer">https://www.youtube.com/watch?v=xJSestoFlJ8&amp;list=PLF9bFmu3NqWqchwS3DO9MDSl15IiHQWcr&amp;index=9</a>)</p>
  
  <p>After rewriting the code by hand (the database, etc), when I restarted to app to show the items I saved into the database in the debug console, I got an error saying while working with initstate and setstate</p>
  
  <pre><code>Unhandled Exception: type 'String' is not a subtype of type 'int' of 'index'
  </code></pre>
  
  <p>Here is the code related to the error</p>
  
  <pre><code>final TextEditingController _textEditingController = TextEditingController();
    var db = DatabaseHelper();
  
    @override
    void initState() {
      super.initState();
  
      _readTaskList();
    }
  
    void _handleSubmitted(String text) async {
      _textEditingController.clear();
  
      Tasks tasksItem = Tasks(text, DateTime.now().toIso8601String());
      int savedItemId = await db.saveItem(tasksItem);
  
      print("Item saved ID: $savedItemId");
  
    }
  
  _readTaskList() async {
      List items = await db.getItems();
      items.forEach((item) {
        Tasks tasksItem = Tasks.map(items);
        print("DB Items: ${tasksItem.itemName}");
      });
    }
  </code></pre>
  
  <p>and here is the full debug console log</p>
  
  <pre><code>E/flutter ( 8249): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: type 'String' is not a subtype of type 'int' of 'index'
  E/flutter ( 8249): #0      new Tasks.map 
  package:gatorblocks_rbt/models/tasks.dart:12
  E/flutter ( 8249): #1      _TaskPlannerState._readTaskList.&lt;anonymous closure&gt; 
  package:gatorblocks_rbt/pages/taskPlanner.dart:105
  E/flutter ( 8249): #2      List.forEach  (dart:core-patch/growable_array.dart:285:8)
  E/flutter ( 8249): #3      _TaskPlannerState._readTaskList 
  package:gatorblocks_rbt/pages/taskPlanner.dart:104
  E/flutter ( 8249): &lt;asynchronous suspension&gt;
  E/flutter ( 8249): #4      _TaskPlannerState.initState 
  package:gatorblocks_rbt/pages/taskPlanner.dart:24
  E/flutter ( 8249): #5      StatefulElement._firstBuild 
  package:flutter/…/widgets/framework.dart:4355
  E/flutter ( 8249): #6      ComponentElement.mount 
  package:flutter/…/widgets/framework.dart:4201
  E/flutter ( 8249): #7      Element.inflateWidget 
  package:flutter/…/widgets/framework.dart:3194
  E/flutter ( 8249): #8      Element.updateChild 
  package:flutter/…/widgets/framework.dart:2988
  E/flutter ( 8249): #9      SingleChildRenderObjectElement.mount 
  package:flutter/…/widgets/framework.dart:5445
  E/flutter ( 8249): #10     Element.inflateWidget 
  package:flutter/…/widgets/framework.dart:3194
  E/flutter ( 8249): #11     Element.updateChild 
  package:flutter/…/widgets/framework.dart:2988
  E/flutter ( 8249): #12     ComponentElement.performRebuild 
  package:flutter/…/widgets/framework.dart:4243
  E/flutter ( 8249): #13     Element.rebuild 
  package:flutter/…/widgets/framework.dart:3947
  E/flutter ( 8249): #14     ComponentElement._firstBuild 
  package:flutter/…/widgets/framework.dart:4206
  E/flutter ( 8249): #15     ComponentElement.mount 
  package:flutter/…/widgets/framework.dart:4201
  E/flutter ( 8249): #16     Element.inflateWidget 
  package:flutter/…/widgets/framework.dart:3194
  E/flutter ( 8249): #17     Element.updateChild 
  package:flutter/…/widgets/framework.dart:2988
  E/flutter ( 8249): #18     SingleChildRenderObjectElement.mount 
  package:flutter/…/widgets/framework.dart:5445
  E/flutter ( 8249): #19     Element.inflateWidget 
  package:flutter/…/widgets/framework.dart:3194
  E/flutter ( 8249): #20     Element.updateChild 
  package:flutter/…/widgets/framework.dart:2988
  E/flutter ( 8249): #21     SingleChildRenderObjectElement.mount 
  package:flutter/…/widgets/framework.dart:5445
  E/flutter ( 8249): #22     Element.inflateWidget 
  package:flutter/…/widgets/framework.dart:3194
  E/flutter ( 8249): #23     Element.updateChild 
  package:flutter/…/widgets/framework.dart:2988
  E/flutter ( 8249): #24     ComponentElement.performRebuild 
  package:flutter/…/widgets/framework.dart:4243
  E/flutter ( 8249): #25     Element.rebuild 
  package:flutter/…/widgets/framework.dart:3947
  E/flutter ( 8249): #26     ComponentElement._firstBuild 
  package:flutter/…/widgets/framework.dart:4206
  E/flutter ( 8249): #27     StatefulElement._firstBuild 
  package:flutter/…/widgets/framework.dart:4381
  E/flutter ( 8249): #28     ComponentElement.mount 
  package:flutter/…/widgets/framework.dart:4201
  E/flutter ( 8249): #29     Element.inflateWidget 
  package:flutter/…/widgets/framework.dart:3194
  E/flutter ( 8249): #30     Element.updateChild 
  package:flutter/…/widgets/framework.dart:2988
  E/flutter ( 8249): #31     SingleChildRenderObjectElement.mount 
  package:flutter/…/widgets/framework.dart:5445
  E/flutter ( 8249): #32     Element.inflateWidget 
  package:flutter/…/widgets/framework.dart:3194
  E/flutter ( 8249): #33     Element.updateChild 
  package:flutter/…/widgets/framework.dart:2988
  E/flutter ( 8249): #34     SingleChildRenderObjectElement.mount 
  package:flutter/…/widgets/framework.dart:5445
  E/flutter ( 8249): #35     Element.inflateWidget 
  package:flutter/…/widgets/framework.dart:3194
  E/flutter ( 8249): #36     Element.updateChild 
  package:flutter/…/widgets/framework.dart:2988
  E/flutter ( 8249): #37     ComponentElement.performRebuild 
  package:flutter/…/widgets/framework.dart:4243
  E/flutter ( 8249): #38     Element.rebuild 
  package:flutter/…/widgets/framework.dart:3947
  E/flutter ( 8249): #39     ComponentElement._firstBuild 
  package:flutter/…/widgets/framework.dart:4206
  E/flutter ( 8249): #40     StatefulElement._firstBuild 
  package:flutter/…/widgets/framework.dart:4381
  E/flutter ( 8249): #41     ComponentElement.mount 
  package:flutter/…/widgets/framework.dart:4201
  E/flutter ( 8249): #42     Element.inflateWidget 
  package:flutter/…/widgets/framework.dart:3194
  E/flutter ( 8249): #43     Element.updateChild 
  package:flutter/…/widgets/framework.dart:2988
  E/flutter ( 8249): #44     ComponentElement.performRebuild 
  package:flutter/…/widgets/framework.dart:4243
  E/flutter ( 8249): #45     Element.rebuild (package:flutte
  </code></pre>
  
  <p><a href="https://prnt.sc/sb4kb3" rel="nofollow noreferrer">Here is a screenshot</a></p>
  
  <p>The app works perfectly fine, it doesn't crash or anything, just fails to properly show the items that I've saved into the database.</p>