Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void submitMobileNo(context) async {
- if (_mobileController.text.isEmpty) {
- Toast.show("Please Enter Mobile Number", context);
- return;
- }
- try {
- final result = await http.post(
- MyUrl.login,
- headers: {HttpHeaders.contentTypeHeader: "application/json"},
- body: json.encode(
- {"mobile": _mobileController.text}),
- );
- if (result.statusCode == 404) {
- Toast.show("User registered Found", context);
- } else {
- final List<dynamic> busInfo = json.decode(result.body);
- SharedPreferences preferences = await SharedPreferences.getInstance();
- preferences.setString("isLogin", _mobileController.text);
- Navigator.of(context).pushReplacement(
- MaterialPageRoute(
- builder: (context) => BottomNavigationPage(),
- ),
- );
- }
- } on SocketException catch (e) {
- Scaffold.of(context).showSnackBar(
- SnackBar(
- content: Text("No Internet Connection!!"),
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement