import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:manager_app/Components/pdf_file_input_container.dart'; import 'package:manager_app/Components/resource_input_container.dart'; import 'package:manager_api_new/api.dart'; import 'dart:convert'; import 'package:manager_app/constants.dart'; class PDFConfig extends StatefulWidget { final String? color; final String? label; final String initialValue; final ValueChanged onChanged; const PDFConfig({ Key? key, this.color, this.label, required this.initialValue, required this.onChanged, }) : super(key: key); @override _PDFConfigState createState() => _PDFConfigState(); } class _PDFConfigState extends State { late PdfDTO pdfDTO; @override void initState() { PdfDTO test = PdfDTO.fromJson(json.decode(widget.initialValue))!; pdfDTO = test; super.initState(); } @override Widget build(BuildContext context) { return Center( child: Container( height: 70, width: 425, child: PDFFileInputContainer( label: "Fichiers PDF :", initialValue: pdfDTO.pdfs != null ? pdfDTO.pdfs! : [], color: kPrimaryColor, onChanged: (List? value) { if(value != null) { pdfDTO.pdfs = value; widget.onChanged(jsonEncode(pdfDTO).toString()); } }, ), ), ); } }