'Update list of data using REST api
hi am a beginner with flutter and am trying to build a app and in that app i want to let the user update a data that he can accede from a list so when he press on a one of the list item it takes him to a new page where he have more details and he can update some stuff there using REST Api i dont know how to do that exactly if anyone can help pls this is the detail page where i one the user to be able to update
import 'package:flutter/material.dart';
import '../Classes/demandes.dart';
class SrDetailsScreen extends StatelessWidget {
final Sr sr;
SrDetailsScreen({Key? key, required this.sr}) : super(key: key);
List<String> Status = ['En cours', 'done', 'cloturé'];
String? selecteditem = 'status';
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar(
title: Text(
"TICKET ID : ${sr.attributes.ticketid.content} ",
),
),
body: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Text(
'Ticket id:\n ${sr.attributes.ticketid.content}',
style: const TextStyle(fontSize: 25),
),
const Divider(),
Text(
'Reported by :\n ${sr.attributes.reportedby.content}',
style: const TextStyle(fontSize: 25),
),
const Divider(),
Text(
'status :\n ${sr.attributes.status.content}',
style: const TextStyle(fontSize: 25),
),
const Divider(),
Text(
'status date :\n ${sr.attributes.statusdate.content}',
style: const TextStyle(fontSize: 25),
),
const Divider(),
Text(
'Description:\n ${sr.attributes.description?.content}',
style: const TextStyle(fontSize: 25),
),
const Divider(),
Text(
""
'assetnum :\n ${sr.attributes.assetnum?.content}',
style: const TextStyle(fontSize: 25),
),
const Divider(),
Text(
'location :\n ${sr.attributes.location?.content}',
style: const TextStyle(fontSize: 25),
),
const Divider(),
Text(
'assetsiteid:\n ${sr.attributes.assetsiteid?.content}',
style: const TextStyle(fontSize: 25),
),
const Divider(),
Text(
'DESCRIPTION_LONGDESCRIPTION :\n ${sr.attributes.DESCRIPTION_LONGDESCRIPTION?.content}',
style: const TextStyle(fontSize: 25),
),
OutlinedButton.icon(
onPressed: () {},
icon: const Icon(
Icons.edit,
size: 18,
),
label: const Text("Save")),
])));
}
}
and thank you
Solution 1:[1]
Surround this with setstate(){}
setState(() {
icon: const Icon(
Icons.edit,
size: 18,
),
label: const Text("Save")),
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Anandh Krishnan |
