Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!
We spend hours on Instagram and YouTube and waste money on coffee and fast food, but wonβt spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!
Learn from Guru Rajesh Kumar and double your salary in just one year.

Step 1: Create a Forgot Password
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
Center( | |
child: Card( | |
elevation: 0, | |
color: Colors.blue, | |
child: TextButton( | |
onPressed: () { | |
Navigator.push( | |
context, | |
MaterialPageRoute( | |
builder: (BuildContext context) => HomeReset(), | |
), | |
); | |
_callApi(email); | |
}, | |
child: const SizedBox( | |
child: Center( | |
child: Text( | |
'Reset Password', | |
style: TextStyle( | |
fontSize: 20.0, | |
color: Colors.black, | |
), | |
), | |
), | |
), | |
), | |
), | |
), |
Step 2: Create a Forgot Password page

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
import 'package:flutter/material.dart'; | |
import 'login_screen.dart'; | |
void main() { | |
runApp(const HomeReset()); | |
} | |
class HomeReset extends StatelessWidget { | |
const HomeReset({Key key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
theme: ThemeData(colorSchemeSeed: const Color(0xff6750a4)), | |
home: Scaffold( | |
appBar: AppBar(title: const Text('Patient Reset Link Send')), | |
body: Column( | |
children: const <Widget>[ | |
ElevatedCardExample(), | |
FilledCardExample(), | |
], | |
), | |
), | |
); | |
} | |
} | |
class ElevatedCardExample extends StatelessWidget { | |
const ElevatedCardExample({Key key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return const Center( | |
child: Card( | |
child: SizedBox( | |
width: 300, | |
height: 100, | |
child: Center( | |
child: Text( | |
' Please check inbox of your email and follow the instructions given to reset your account Password', | |
style: TextStyle( | |
fontSize: 20.0, | |
color: Colors.black, | |
// backgroundColor: Colors.black, | |
))), | |
), | |
), | |
); | |
} | |
} | |
class FilledCardExample extends StatelessWidget { | |
const FilledCardExample({Key key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return Center( | |
child: Card( | |
elevation: 0, | |
color: Colors.blue, | |
child: TextButton( | |
onPressed: () { | |
Navigator.push( | |
context, | |
MaterialPageRoute( | |
builder: (BuildContext context) => LoginScreen(), | |
)); | |
}, | |
child: const SizedBox( | |
width: 250, | |
height: 50, | |
child: Center( | |
child: Text('After that click here to login again', | |
style: TextStyle( | |
fontSize: 15.0, | |
color: Colors.white, | |
// backgroundColor: Colors.black, | |
)), | |
), | |
), | |
), | |
), | |
); | |
} | |
} |
Step 3: Create API
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
Future<void> _callApi(String email) async { | |
try { | |
if (email.isNotEmpty) { | |
var response = await authServices.getUserResetPassword(email); | |
if (response.statusCode == 200) { | |
print('Password reset link sent successfully.'); | |
} else { | |
print('Failed to send reset link.'); | |
} | |
} else { | |
print('User email not found. Cannot reset password.'); | |
} | |
} catch (e) { | |
print('Error occurred: $e'); | |
} | |
} |
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
Future<http.Response> getUserResetPassword(String email) async { | |
final prefs = await SharedPreferences.getInstance(); | |
final token = prefs.getString('token'); | |
final pemail = prefs.getString('email'); | |
Map<String, dynamic> data = { | |
"email": email, | |
}; | |
var body = json.encode(data); | |
var url = Uri.parse(baseURL + 'password/reset'); | |
var response = await http.post( | |
url, | |
headers: { | |
'Accept': 'application/json', | |
'Authorization': 'Bearer $token', | |
'Content-Type': 'application/json', | |
}, | |
body: body, | |
); | |
return response; | |
} |
Step 4: Create a Route in the App.php in Laravel
Route::post('/password/reset', 'Auth\ResetPasswordController@resetApp');
Step 5: Create a function in Laravel
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
public function resetApp(Request $request) | |
{ | |
log::info('yaha tak aa raha hai'); | |
$request->validate([ | |
'email' => 'required|email', | |
]); | |
$response = $this->broker()->sendResetLink($request->only('email')); | |
return $response == Password::RESET_LINK_SENT | |
? response()->json(['message' => 'Reset link sent successfully'], 200) | |
: response()->json(['message' => 'Unable to send reset link'], 400); | |
} |