Improve back button function in all screens

This commit is contained in:
hanie.khodkari
2025-03-19 18:38:40 +03:30
parent d99ecb2783
commit 58cd3d9f3f
35 changed files with 4715 additions and 5007 deletions
+84 -96
View File
@@ -96,105 +96,93 @@ class _FormPageState extends State<FormPage> {
@override
Widget build(BuildContext context) {
return PopScope(
canPop: false,
onPopInvoked: (didPop) {
if (didPop) return;
Navigator.of(context).pushNamed(Routes.homePage);
// Navigator.pushReplacementNamed(
// context,
// Routes.testResultAddScreen,
// );
// return true;
},
child: SafeArea(
child: Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text(
'Add Test Result',
style: TextStyle(
color: Colors.white,
),
),
backgroundColor: Colors.black,
actions: <Widget>[
_isLoadingButton
? Center(
child: CircularProgressIndicator(
color: Colors.white,
),
)
: IconButton(
icon: Icon(
Icons.save,
color: Colors.white,
),
onPressed: () {
_saveForm();
},
)
],
leading: IconButton(
icon: Icon(
Icons.keyboard_arrow_left,
color: Colors.white,
size: 35,
),
onPressed: () {
Navigator.of(context).popAndPushNamed(Routes.testResultScreen);
},
return SafeArea(
child: Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text(
'Add Test Result',
style: TextStyle(
color: Colors.white,
),
),
body: SingleChildScrollView(
child: Column(
children: <Widget>[
_isLoading
? Center(
child: CircularProgressIndicator(
color: Colors.black,
),
)
: Form(
key: _form,
child: Consumer<Inputs>(
builder: (context, inputs, _) {
formInputs = inputs.inputItems;
print(formInputs);
return formInputs.length != 0
? FormCreator(
form: formInputs,
onChanged: (value) {
formInputs = value;
},
)
: Center(
child: Text('Something went wrong!!!'),
);
},
),
),
// https://www.cssd-doc.com/api/GetInfo
// InkWell(
// onTap: () {
// _saveForm();
// },
// child: Container(
// padding: EdgeInsets.symmetric(horizontal: 60, vertical: 15),
// margin: EdgeInsets.symmetric(vertical: 20, horizontal: 50),
// decoration: BoxDecoration(
// gradient: LinearGradient(colors: [Colors.blue, Colors.green]),
// borderRadius: BorderRadius.circular(10),
// ),
// child: Text(
// 'Save',
// style: TextStyle(color: Colors.white, fontSize: 17),
// textAlign: TextAlign.center,
// ),
// ),
// ),
],
backgroundColor: Colors.black,
actions: <Widget>[
_isLoadingButton
? Center(
child: CircularProgressIndicator(
color: Colors.white,
),
)
: IconButton(
icon: Icon(
Icons.save,
color: Colors.white,
),
onPressed: () {
_saveForm();
},
)
],
leading: IconButton(
icon: Icon(
Icons.keyboard_arrow_left,
color: Colors.white,
size: 35,
),
onPressed: () {
Navigator.of(context).popAndPushNamed(Routes.testResultScreen);
},
),
),
body: SingleChildScrollView(
child: Column(
children: <Widget>[
_isLoading
? Center(
child: CircularProgressIndicator(
color: Colors.black,
),
)
: Form(
key: _form,
child: Consumer<Inputs>(
builder: (context, inputs, _) {
formInputs = inputs.inputItems;
print(formInputs);
return formInputs.length != 0
? FormCreator(
form: formInputs,
onChanged: (value) {
formInputs = value;
},
)
: Center(
child: Text('Something went wrong!!!'),
);
},
),
),
// https://www.cssd-doc.com/api/GetInfo
// InkWell(
// onTap: () {
// _saveForm();
// },
// child: Container(
// padding: EdgeInsets.symmetric(horizontal: 60, vertical: 15),
// margin: EdgeInsets.symmetric(vertical: 20, horizontal: 50),
// decoration: BoxDecoration(
// gradient: LinearGradient(colors: [Colors.blue, Colors.green]),
// borderRadius: BorderRadius.circular(10),
// ),
// child: Text(
// 'Save',
// style: TextStyle(color: Colors.white, fontSize: 17),
// textAlign: TextAlign.center,
// ),
// ),
// ),
],
),
),
),