Home > Blockchain >  How to add a class in another one or an alternative
How to add a class in another one or an alternative

Time:10-18

Hello I explain my problem I have a list of patients with their coordinates all that is registered in a class by clicking on one of the patient a life opens with the information of the patient in question.

I want to add the possibility to add notes (an unlimited number of notes per patient) so I need another list but I do not know how to link the two

I would like that when I click on a patient it loads the information of this patient from the list of notes

Here is the list of my patients

class Patients {
  final String name;

  final String firstname;
  final String dateofbirth;
  final String email;
  final String numero;
  final String id;
  final DateTime date;

  Patients(
      {required this.name,
      required this.firstname,
      required this.dateofbirth,
      required this.email,
      required this.numero,
      required this.id,
      required this.date});
}

Here is the list of patient notes

class ListNote {
  final String? title;
  final String? note;
  final String? conclusion;

  ListNote({
    this.title,
    this.note,
    this.conclusion,
  });
}

My patient screen list

In the red frame is the information of my first list of patients.

In the blue boxes you will find the notes linked to the patient

Patient page with more info

Thank you for your help

CodePudding user response:

What I got from your point is you want to add List of Notes in Patient class. If that's the case you can simply add that in Patient class like this:

class Patients {
  final String name;
  final List<ListNote> listOfNotes;
  final String firstname;
  final String dateofbirth;
  final String email;
  final String numero;
  final String id;
  final DateTime date;

  Patients({
      required this.name,
      required this.listOfNotes,
      required this.firstname,
      required this.dateofbirth,
      required this.email,
      required this.numero,
      required this.id,
      required this.date
  });
}


class ListNote {
  final String? title;
  final String? note;
  final String? conclusion;

  ListNote({
    this.title,
    this.note,
    this.conclusion,
  });
}

CodePudding user response:

Yes I think it must be that however I don't know how to implement it in one of my list and how to read this list can you help me?

Expanded(
      child: ListView.builder(
        itemCount: patients.listOfNotes?.length,
        itemBuilder: (context, index) {
          return Card(child: Text(patients.listOfNotes)); // <---- This line
        },
      ),
    ),
    final List<Patients> patientList = [
  Patients(
    name: 'Halleux',
    firstname: 'Arnaud',
    dateofbirth: '***********',
    email: '***********',
    numero: '***********',
    date: DateTime.now(),
    id: '080283820',
  ),
];
  • Related