Boa tarde,
Ao fazer a função registerJournal, o id parou de registrar valores aleatórios e está somento "id", quando eu dou o restart, ele vem o id certo, porém ao escrever e salvar a anotação, ele vem como "id":
import 'package:flutter/material.dart';
import 'package:flutter_webapi_first_course/helpers/weekday.dart';
import 'package:flutter_webapi_first_course/services/journal_service.dart';
import '../../../models/journal.dart';
class AddJournalScreen extends StatelessWidget {
final Journal journal;
AddJournalScreen({Key? key, required this.journal}) : super(key: key);
final TextEditingController _contentcontroller = TextEditingController();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
"${WeekDay(journal.createdAt.weekday).long}, ${journal.createdAt.day} | ${journal.createdAt.month} | ${journal.createdAt.year}"),
actions: [
IconButton(onPressed: (){
registerJournal(context);
}, icon: const Icon(Icons.check))
],
),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: TextField(
controller: _contentcontroller,
keyboardType: TextInputType.multiline,
style: const TextStyle(fontSize: 24),
expands: true,
minLines: null,
maxLines: null,
),
),
);
}
registerJournal(BuildContext context) async{
String content = _contentcontroller.text;
journal.content = content;
JournalService service = JournalService();
bool result = await service.register(journal);
Navigator.pop(context, result);
}
}
{
"learnhttp": {
"content": "Hello World"
},
"journals": [
{
"id": "b8763cb0-c6b9-11ee-8ee2-312410bf4b98",
"content": "",
"created_At": "2024-02-08 19:39:06.111290",
"updated_At": "2024-02-08 19:39:06.111301"
},
{
"id": "id",
"content": "Ola",
"created_At": "2024-02-08 19:39:11.649948",
"updated_At": "2024-02-08 19:39:11.649956"
}
]
}