Last active
October 18, 2021 13:47
-
-
Save aniekan12/ce9a5c2ba16b46c03bc67051152dcc16 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List list; | |
bool loading = true; | |
//get all the demands stored in the database | |
Future demandNoticeList() async { | |
list = await SqfliteDatabaseHelper.instance.readAllDemands(); | |
setState(() { | |
loading = false; | |
}); | |
print(list); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
backgroundColor: buttonColorOne, | |
), | |
body: Container( | |
height: MediaQuery.of(context).size.height, | |
width: MediaQuery.of(context).size.width, | |
child: Stack( | |
children: [ | |
Form( | |
child: _buildDemandNotice(context), | |
key: formKey, | |
), | |
], | |
), | |
), | |
); | |
} | |
_buildDemandNotice(BuildContext context) { | |
return SingleChildScrollView( | |
child: Padding( | |
padding: EdgeInsets.fromLTRB(24.0, 24, 24.0, 24.0), | |
child: Column( | |
crossAxisAlignment: CrossAxisAlignment.start, | |
children: [ | |
SizedBox(height: 40.0), | |
Text( | |
'Demand Notice', | |
textAlign: TextAlign.left, | |
style: TextStyle( | |
color: Colors.black, | |
fontSize: 24, | |
fontWeight: FontWeight.w700, | |
), | |
), | |
Divider( | |
height: 20, | |
endIndent: 140, | |
thickness: 5, | |
color: buttonColorOne, | |
), | |
SizedBox(height: 40.0), | |
textHeaders('Property Id'), | |
textSection('', _propertyIdController, 'Property Id'), | |
SizedBox(height: 20.0), | |
GestureDetector( | |
onTap: () async { | |
//call the model, populate the data | |
DemandNoticeModel demandNoticeModel = DemandNoticeModel( | |
propertyId: _propertyIdController.text.toString(), | |
); | |
print(demandNoticeModel.image); | |
//call the SQlite instance and send the data to the table created | |
await SqfliteDatabaseHelper.instance | |
.addDemand(demandNoticeModel) | |
.then((value) { | |
ScaffoldMessenger.of(context).showSnackBar( | |
SnackBar(content: Text("Saved succesfully!"))); | |
demandNoticeList(); | |
print("success"); | |
}); | |
}, | |
child: signButton( | |
_textFieldHeight, _textFieldShadow, _textSize, 'SEND')), | |
], | |
), | |
)); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment