I m creating my own app but I m using this video like a guide to teach me https://www.youtube.com/watch?v=B8Sx7wGiY-s&t=167s. The thing is that I have a drawerlist.dart:
ListTile(
leading: const Icon(Icons.help),
title: const Text('Sugestão'),
onTap: () {
Routemaster.of(context).push('/sugestoes');
},
),
This take me to the suggestion.dart, in this screen the user can do a suggestion and I save it in the firebase. So I have a suggestionRepository.dart, suggestionController.dart, in the suggestionController.dart, I have this function:
void createSugestao(String sugestaotexto, BuildContext context) async {
state = true;
final uidutilizador = _ref.read(userProvider)?.uid ?? '';
SugestaoModel sugestao = SugestaoModel(
uid: uidutilizador, sugestaousuario: sugestaotexto, likes: 0);
final res = await _sugestoesRepository.createSugestao(sugestao);
state = false;
res.fold((l) => showSnackBar(context, l.message), (r) {
showSnackBar(context, "Sugestão enviada com sucesso!");
//Routemaster.of(context).pop; // mandar para a pagina de mostrar sugestoes
});
}
"Routemaster.of(context).pop;"
-> this piece of code should take me back to the homescreen right?? I tried to mode this piece of code to the suggestion.dart after the fuction is call and nothing happens. I did a print on the function and this was the output:
I/flutter ( 2687): Closure: ([Y0?]) => Future from Function 'pop':.
Other thing is I have a button on suggestion.dart that takes me to the Routemaster.of(context).push('/visualizar_sugestoes');
. When I m in the VisualizarSugestao.dart and I use the button on the appbar to go back I go straight to the homescreen.dart and I wanted to fo back to the suggestion.dart.