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
class Student { | |
String? name; | |
String? id; | |
void method1() { | |
debugPrint('This is method 1. Name: $name'); | |
} | |
void method2() { | |
debugPrint('This is method 2. ID: $id'); |
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 '../../../../Data/Models/home_page_model.dart'; | |
import '../../../../Data/Repository/home_page_repo.dart'; | |
import 'package:flutter/material.dart'; | |
class MyHomePage extends StatefulWidget { | |
const MyHomePage({Key? key, required this.title}) : super(key: key); | |
final String title; |
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_dotenv/flutter_dotenv.dart'; | |
import '../API/base_client.dart'; | |
import '../Models/home_page_model.dart'; | |
abstract class DemoRepository { | |
Future<DemoModel> fetchData(); | |
} | |
class DemoRepo extends DemoRepository { |
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 'dart:async'; | |
import 'dart:io'; | |
class ExceptionHandlers { | |
getExceptionString(error) { | |
if (error is SocketException) { | |
return 'No internet connection.'; | |
} else if (error is HttpException) { | |
return 'HTTP error occured.'; | |
} else if (error is FormatException) { |
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 'dart:async'; | |
import 'dart:convert'; | |
import 'package:http/http.dart' as http; | |
import '../../Business_Logic/Exceptions/exception_handlers.dart'; | |
class BaseClient { | |
static const int timeOutDuration = 35; |
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
sendOTP(String phoneNumber) async { | |
this.phoneNumber = phoneNumber; | |
FirebaseAuth auth = FirebaseAuth.instance; | |
ConfirmationResult confirmationResult = await auth.signInWithPhoneNumber( | |
'+91 $phoneNumber', | |
); | |
printMessage("OTP Sent to +91 $phoneNumber"); | |
return confirmationResult; | |
} |
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
authenticateMe(ConfirmationResult confirmationResult, String otp) async { | |
UserCredential userCredential = await confirmationResult.confirm(otp); | |
userCredential.additionalUserInfo!.isNewUser | |
? printMessage("Successful Authentication") | |
: printMessage("User already exists"); | |
} |
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
Widget buildSendOTPBtn(String text) => ElevatedButton( | |
onPressed: () async { | |
temp = await FirebaseAuthentication().sendOTP(phoneNumber.text); | |
}, | |
child: Text(text), | |
); |
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
Widget buildSubmitBtn(String text) => ElevatedButton( | |
onPressed: () { | |
FirebaseAuthentication().authenticateMe(temp, otp.text); | |
}, | |
child: Text(text), | |
); |
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
signOut() async { | |
try { | |
await FirebaseAuth.instance.signOut(); | |
debugPrint("Logged out successfully!"); | |
} catch (e) { | |
debugPrint(e.toString()); | |
} | |
} |