mercredi 8 juin 2022

type 'Null' is not a subtype of type 'List

I am trying to create a checkbox feature but i receiving the following error : type 'Null' is not a subtype of type 'List' particularly for children:generateItems()), Tried to solve with different options available but no any resolution.

 Step(
            isActive: currentStep >= 3,
            title: Text('What service do you want?'),
            content: Obx(() {
              return Column(
                children: [
                  Column(
                      mainAxisSize: MainAxisSize.min,
                      children: generateItems()),
                ],
              );
            }))



final dataList=<Item>[
  Item("Brake"),
  Item("Tyre"),
  Item("Wheel"),
  Item("Steering"),
  Item("Windshield"),
  Item("Ignition"),
].obs;


generateItems() {
  final result = <Widget>[];

  for (int i = 0; i < dataList.length; i++) {
    result.add(CheckboxListTile(value: dataList[i].selected,title: Text(dataList[i].title), onChanged: (val){

      dataList[i].selected =val ??false;
      dataList.refresh();
    }
    )
    );
  }

}



Aucun commentaire:

Enregistrer un commentaire