title: Invalid value: Not in inclusive range 0..4: 5
body: <p>im getting strange error. I want to create a widget for every cell in a list, but when I write &quot;itemCount: RemindTitle.length&quot; I have that red screen.
  It appears even when I enter just 1, 2 or any Int number</p>
  <p>The second issue is that I have a Time Picker, but when I want to output numbers I've entered, it shows just random numbers, like 0 min, 30hrs</p>
  <pre><code>import 'dart:io';
  import 'package:flutter/material.dart';
      void main() {
    runApp(const MyApp());
  }
  
  class MyApp extends StatelessWidget {
    const MyApp({Key? key}) : super(key: key);
    @override
    Widget build(BuildContext context) {
      return MaterialApp(debugShowCheckedModeBanner: false,
          home: HomePage());
    }
  }
  
  class HomePage extends StatefulWidget {
    const HomePage({Key? key}) : super(key: key);
  
    @override
    State&lt;HomePage&gt; createState() =&gt; _HomePageState();
  }
  
  class _HomePageState extends State&lt;HomePage&gt; {
    @override
    var RemindTitle = [&quot;First&quot;, &quot;Second&quot;, &quot;Third&quot;, &quot;Fourth&quot;, &quot;sdf&quot;],
        RemindText = [&quot;TexttF&quot;, &quot;TextS&quot;, &quot;TextT&quot;, &quot;TextFr&quot;, &quot;sdf&quot;];
    var Counter = -1;
    DateTime? date;
    TimeOfDay _time = TimeOfDay.now();
    var DateText = &quot;Enter the date&quot;, ChosenTime = &quot; &quot;;
  
    bool AlreadyBuilt = false;
  
    Widget build(BuildContext context) {
      return Scaffold(
        body: ListView.builder(
            padding: EdgeInsets.all(20),
            itemCount: RemindTitle.length,
            itemBuilder: (BuildContext context, int index) {
              if(AlreadyBuilt == false) {
                AlreadyBuilt = true;
                return Row(
                  children: [
                  Expanded(
                  flex: 4,
                  child: Container(
                    height: 75,
                    child: ElevatedButton(
                      child: Center(
                        child: Text(&quot;Add Remind&quot;),
                      ),
                      onPressed: () {
                        showModalBottomSheet&lt;void&gt;(
                            context: context,
                            builder: (BuildContext context) {
                              return Container(
                                  child: Center(
                                    child: Column(children: [
                                      Row(
                                        children: [
                                          Padding(padding: EdgeInsets.all(10)),
                                          Expanded(
                                              child: ElevatedButton(
                                                  onPressed: () async {
                                                    date = await showDatePicker(
                                                      context: context,
                                                      initialDate:
                                                      new DateTime.now(),
                                                      firstDate:
                                                      new DateTime(2015),
                                                      lastDate:
                                                      new DateTime(2030),
                                                    );
                                                  },
                                                  child: Text(&quot;Enter the date&quot;))),
                                          Padding(padding: EdgeInsets.all(10)),
                                          Expanded(
                                              child: ElevatedButton(
                                                  onPressed: () async {
                                                    showTimePicker(
                                                        context: context,
                                                        initialTime:
                                                        TimeOfDay.now())
                                                        .then((value) {
                                                      setState(() {
                                                        _time = value!;
                                                      });
                                                    });
                                                    if (date != null) {
                                                      ChosenTime =
                                                          &quot;Chosen time: &quot; +
                                                              date!.day
                                                                  .toString() +
                                                              &quot;:&quot; +
                                                              date!.month
                                                                  .toString() +
                                                              &quot;:&quot; +
                                                              date!.year
                                                                  .toString() +
                                                              &quot;, time: &quot; + _time.minute.toString() +
                                                              &quot;:&quot; +
                                                              _time.hour
                                                                  .toString();
                                                    }
                                                  },
                                                  child: Text(&quot;Enter the time&quot;))),
                                          Padding(padding: EdgeInsets.all(10)),
                                        ],
                                      ),
                                      Padding(padding: EdgeInsets.all(10)),
                                      Text(ChosenTime)
                                    ]),
                                  ));
                            });
                      },
                    ),
                  ),
                ),
              Padding(padding: EdgeInsets.fromLTRB(10, 0, 0, 0)),
              Expanded(
              flex: 4,
              child: Container(
              height: 75,
              child: ElevatedButton(
              onPressed: () {},
              child: Center(
              child: Text(&quot;Delete Remind&quot;),
              )),
              ),
              )
              ],
              );
              }
  
              if(Counter &lt; RemindTitle.length){
                Counter++;
              }
                return Container(
                  height: 130,
                  width: 175,
                  child: ElevatedButton(
                      onPressed: () {},
                      child: Center(
                        child: Column(
                          children: [
                            Padding(padding: EdgeInsets.fromLTRB(0, 10, 0, 10)),
                            Text(
                              RemindTitle[Counter],
                              style: TextStyle(fontSize: 20),
                            ),
                            Padding(padding: EdgeInsets.fromLTRB(0, 10, 0, 10)),
                            Text(RemindText[Counter])
                          ],
                        ),
                      )),
                  padding: EdgeInsets.fromLTRB(0, 20, 0, 0),
                );
            }),
        appBar: AppBar(
          title: (Text(&quot;Reminder :)&quot;)),
          centerTitle: true,
        ),
      );
    }
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/Jvxwj.png" rel="nofollow noreferrer">Red Screen</a></p>