I'm working on a form where you enter a patient's data such as name, age, gender, etc... and an image gallery, I'm working with Isar, this the model
import 'package:isar/isar.dart';
part 'paciente.g.dart';
@collection
class Paciente {
Id id = Isar.autoIncrement;
String namep = '';
String apellido1p = '';
String apellido2p = '';
int edadp = 0;
String sexop = '';
String numtelefp = '';
String examenesp = '';
String tratamientop = '';
List<String>? imagenesp = [];
}
I made the form with the flutter_form_builder package and in the case of the images to upload them I used form_builder_file_picker
FormBuilderFilePicker(
// controller: selcimgPcontroller,
name: 'selcimgP',
decoration: const InputDecoration(
labelText: "Adjuntar archivo",
border: OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(4.0),
),
),
),
maxFiles: null,
allowMultiple: true,
previewImages: true,
onChanged: (val) => debugPrint(val.toString()),
typeSelectors: const [
TypeSelector(
type: FileType.image,
selector: Row(
children: <Widget>[
Icon(Icons.file_upload),
Text('Subir archivos'),
],
),
)
],
),
and at the end of the form use a button to later publish a list of the names and other data, in this case the name will only be displayed on another screen
ElevatedButton(
onPressed: () async {
if (_formKey.currentState!.validate()) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Procesando Informacion'),
),
);
}
Paciente paciente = Paciente()
..namep = namePcontroller.text
..apellido1p = apellido1Pcontroller.text
..apellido2p = apellido2Pcontroller.text
..edadp = int.parse(edadPcontroller.text)
..sexop = _selectedValue
..numtelefp = numtelefPcontroller.text
..examenesp = examPcontroller.text
..tratamientop = tratamientoPcontroller.text;
final id = await dao.upsert(paciente);
paciente.id = id;
namePcontroller.clear();
setState(() {
pacientes.add(paciente);
});
},
child: const Text('Guardar'),
),
In the previous code, the images are missing, so it would be something like ..imagenesp:xxxxxxxxx
In this case it's what I don't know how to put it.
If you have any proposals I'm all ears, the tutorials and documents I've consulted work with List<Uint8List>
But every time I try to put that in, I get wrong
If you have any ideas on how to help me I would appreciate it