Advertisement
Guest User

Untitled

a guest
Feb 15th, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. void submitMobileNo(context) async {
  2. if (_mobileController.text.isEmpty) {
  3. Toast.show("Please Enter Mobile Number", context);
  4. return;
  5. }
  6. try {
  7. final result = await http.post(
  8. MyUrl.login,
  9. headers: {HttpHeaders.contentTypeHeader: "application/json"},
  10. body: json.encode(
  11. {"mobile": _mobileController.text}),
  12. );
  13. if (result.statusCode == 404) {
  14. Toast.show("User registered Found", context);
  15. } else {
  16. final List<dynamic> busInfo = json.decode(result.body);
  17. SharedPreferences preferences = await SharedPreferences.getInstance();
  18. preferences.setString("isLogin", _mobileController.text);
  19. Navigator.of(context).pushReplacement(
  20. MaterialPageRoute(
  21. builder: (context) => BottomNavigationPage(),
  22. ),
  23. );
  24. }
  25. } on SocketException catch (e) {
  26. Scaffold.of(context).showSnackBar(
  27. SnackBar(
  28. content: Text("No Internet Connection!!"),
  29. ),
  30. );
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement