Skip to content

Commit

Permalink
Fix Snackbar
Browse files Browse the repository at this point in the history
  • Loading branch information
n1ved committed Jun 2, 2023
1 parent 3f0bb6e commit 4d44015
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions lib/screens/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ class _HomeScreenState extends State<HomeScreen> {
onTap: () {
showDialog(
context: context,
builder: (BuildContext context) => AlertDialog(
builder: (BuildContext dialogueContext) =>
AlertDialog(
title: const Text("Search City"),
content: TextField(
controller: inputController,
Expand All @@ -146,25 +147,32 @@ class _HomeScreenState extends State<HomeScreen> {
actions: [
TextButton(
onPressed: () {
Navigator.pop(context);
Navigator.pop(dialogueContext);
},
child: const Text("Cancel"),
),
TextButton(
onPressed: () async {
GetData getData = GetData();
// Navigator.pop(context);
Navigator.pop(dialogueContext);
if (context.mounted) {
ScaffoldMessenger.of(context)
.showSnackBar(const SnackBar(
content: Text("Loading....")));
}
dynamic returnData =
await getData.getAllDataByName(
cityName: cityNameInput);
if (returnData != 'error') {
updateScreen(returnData);
cityNameInput = '';
} else {
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(
content: Text(
"Error Finding City ...")));
if (context.mounted) {
ScaffoldMessenger.of(context)
.showSnackBar(const SnackBar(
content: Text(
"Error Finding City")));
}
}
},
child: const Text("Search"),
Expand Down

0 comments on commit 4d44015

Please sign in to comment.