i want to fetch data from api and set it as text field initial value, then after user changes it i will post it to another api, but after changing textfield value, future builder rebuilds and textfield gets back to initial value, here is my code:
services.dart
Future<Data> getdata() async {
final response = await http
.get(url);
if (response.statusCode == 200) {
print(response.body);
final parsed = jsonDecode(response.body);
var data = Data.fromMap(parsed);
return data;
} else {
throw Exception('failed to load profile Details');
}
}
homePage.dart
TextEditingController Controller = TExtEDitingController;
late Future<Data> futureData;
@override
void initState() {
// TODO: implement initState
super.initState();
futureData = getdata();
}
.
.
.
FutureBuilder<Details>(
builder: (context, snapshot) {
if (snapshot.hasData) {
Controller.text= snapshot.data;
return TextField(
controller: Controller,
.
.
.
),