Skip to content

Commit

Permalink
feat:removed warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
avinashkranjan committed Oct 18, 2023
1 parent ba63f6b commit adc886c
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 44 deletions.
12 changes: 6 additions & 6 deletions lib/feedback.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class FeedbackPage extends StatefulWidget {

class _FeedbackPageState extends State<FeedbackPage> {
TextEditingController _commentController = TextEditingController();
double _rating = 0.0;
bool _alreadyRated = false;
double rating = 0.0;
bool alreadyRated = false;

@override
void initState() {
Expand All @@ -21,13 +21,13 @@ class _FeedbackPageState extends State<FeedbackPage> {
SharedPreferences prefs = await SharedPreferences.getInstance();
bool alreadyRated = prefs.getBool('already_rated') ?? false;
setState(() {
_alreadyRated = alreadyRated;
alreadyRated = alreadyRated;
});
}

void _submitFeedback() {
// Submit the feedback to your backend service or database
String comment = _commentController.text;
// String comment = _commentController.text;
// Store the feedback and rating

// Update the alreadyRated flag
Expand Down Expand Up @@ -71,7 +71,7 @@ class _FeedbackPageState extends State<FeedbackPage> {
RatingBar(
onRatingChanged: (rating) {
setState(() {
_rating = rating;
rating = rating;
});
},
),
Expand Down Expand Up @@ -118,4 +118,4 @@ class _RatingBarState extends State<RatingBar> {
children: List.generate(5, (index) => _buildStar(index + 1)),
);
}
}
}
1 change: 1 addition & 0 deletions lib/screens/contact_us_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class _ContactUsScreenState extends State<ContactUsScreen> {
physics: AlwaysScrollableScrollPhysics(parent: BouncingScrollPhysics()),
child: Consumer<UserInfoServices>(
builder: (context, userInfo, _) {
// ignore: unused_local_variable
Users user;
if (userInfo.hasData) user = userInfo.user!;
return Stack(alignment: Alignment.center, children: [
Expand Down
1 change: 1 addition & 0 deletions lib/screens/faqs_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class FAQScreen extends StatelessWidget {
physics: AlwaysScrollableScrollPhysics(parent: BouncingScrollPhysics()),
child: Consumer<UserInfoServices>(
builder: (context, userInfo, _) {
// ignore: unused_local_variable
Users _user;
if (userInfo.hasData) _user = userInfo.user!;
return Stack(alignment: Alignment.center, children: [
Expand Down
1 change: 1 addition & 0 deletions lib/screens/help_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class HelpScreen extends StatelessWidget {
physics: AlwaysScrollableScrollPhysics(parent: BouncingScrollPhysics()),
child: Consumer<UserInfoServices>(
builder: (context, userInfo, _) {
// ignore: unused_local_variable
Users _user;
if (userInfo.hasData) _user = userInfo.user!;
return Stack(alignment: Alignment.center, children: [
Expand Down
1 change: 1 addition & 0 deletions lib/screens/profile_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
physics: AlwaysScrollableScrollPhysics(parent: BouncingScrollPhysics()),
child: Consumer<UserInfoServices>(
builder: (context, userInfo, _) {
// ignore: unused_local_variable
Users _user;
if (userInfo.hasData) _user = userInfo.user!;
return Stack(
Expand Down
9 changes: 4 additions & 5 deletions lib/screens/settings_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,20 @@ class _SettingsScreenState extends State<SettingsScreen> {
bool modeval = false;

late bool? notification;
ThemeData? _currentTheme;
ThemeData? currentTheme;

void _setTheme(ThemeData? theme) {
if (theme != null) {
setState(() {
_currentTheme = theme;
currentTheme = theme;
});
}
}

@override
void initState() {
// TODO: implement initState
checknotify();
_currentTheme =
ThemeMode.system == ThemeMode.light ? lightTheme : darkTheme;
currentTheme = ThemeMode.system == ThemeMode.light ? lightTheme : darkTheme;
super.initState();
}

Expand Down Expand Up @@ -86,6 +84,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
physics: AlwaysScrollableScrollPhysics(parent: BouncingScrollPhysics()),
child: Consumer<UserInfoServices>(
builder: (context, userInfo, _) {
// ignore: unused_local_variable
Users _user;
if (userInfo.hasData) _user = userInfo.user!;
return Stack(
Expand Down
1 change: 1 addition & 0 deletions lib/services/auth_error_msg_toast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';

void showErrToast(String errorMsg, FToast errToast) {
// ignore: unnecessary_null_comparison
if (errorMsg == null) return;
Widget toast = Container(
padding: const EdgeInsets.symmetric(horizontal: 15.0, vertical: 10.0),
Expand Down
17 changes: 8 additions & 9 deletions lib/services/authentication.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ class AuthenticationService {
return OnboardingPage();
} else {
return AuthHandlingWidget(
key: UniqueKey(),
name: _currUser.displayName ?? '',
email: _currUser.email?? '',
);
key: UniqueKey(),
name: _currUser.displayName ?? '',
email: _currUser.email ?? '',
);
}
}
}

/// Handles Authentication Login
static Future<String> handleLogin(
Expand All @@ -41,6 +41,7 @@ class AuthenticationService {
final User? currentUser = auth.currentUser;

if (user!.emailVerified) {
// ignore: unnecessary_null_comparison
if ((user != null) &&
(currentUser != null) &&
(user.uid == currentUser.uid)) {
Expand Down Expand Up @@ -177,10 +178,7 @@ class AuthenticationService {
.signOut(); // Without that, If User Sign-Up, then close and reopen the app, can navigate to the
//bottom_navigation screen

Navigator.push(
context,
MaterialPageRoute(builder: (_) => LoginPage())
);
Navigator.push(context, MaterialPageRoute(builder: (_) => LoginPage()));
} else {
print("SignUp Error: Undefined Error!");
errorMsg = "Undefined Error Occurred";
Expand All @@ -201,6 +199,7 @@ class AuthenticationService {
final FirebaseAuth auth = FirebaseAuth.instance;
User? _currUser = auth.currentUser;
print("Signing Out: " + _currUser!.uid);
// ignore: unnecessary_null_comparison
if (_currUser != null) {
await auth.signOut();
// Navigate to Onboarding Page
Expand Down
4 changes: 2 additions & 2 deletions lib/services/chats_db.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ Future<void> searchUsersByIdAndPerformActions(
.get();

if (snapshot.docs.isNotEmpty) {
DocumentSnapshot userSnapshot = snapshot.docs.first;
String userName = userSnapshot['name'];
// DocumentSnapshot userSnapshot = snapshot.docs.first;
// String userName = userSnapshot['name'];

// Create a new group
createGroup(groupId, userId).then((groupId) {
Expand Down
15 changes: 8 additions & 7 deletions lib/services/phone_number_verification_db.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import 'package:firebase_auth/firebase_auth.dart';

class PhoneNumberVerificationDb {
final FirebaseAuth _auth = FirebaseAuth.instance;

var verificationCallback;

PhoneNumberVerificationDb({required this.verificationCallback});

Future<void> verifyPhoneNumber(String phoneNumber, verifyCodeScreenCallback) async {
Future<void> verifyPhoneNumber(
String phoneNumber, verifyCodeScreenCallback) async {
await _auth.verifyPhoneNumber(
phoneNumber: phoneNumber,
verificationCompleted: (PhoneAuthCredential credential) async {
Expand All @@ -18,10 +19,9 @@ class PhoneNumberVerificationDb {
},
codeSent: (String verificationId, int? resendToken) {
print('Verification Code Sent to $phoneNumber');
// Call a function in VerifyCodeScreen to pass the verification ID
// and navigate to the VerifyCodeScreen.
codeSent: (String verificationId, int? resendToken) {
print('Verification Code Sent to $phoneNumber');
// ignore: unnecessary_statements
(String verificationId, int? resendToken) {
print('Verification Code Sent to $phoneNumber');
};
},
codeAutoRetrievalTimeout: (String verificationId) {
Expand All @@ -41,7 +41,8 @@ class PhoneNumberVerificationDb {

Future<void> _signInWithCredential(PhoneAuthCredential credential) async {
try {
final UserCredential userCredential = await _auth.signInWithCredential(credential);
final UserCredential userCredential =
await _auth.signInWithCredential(credential);
final User? user = userCredential.user;
if (user != null) {
print('Phone Number Verified: ${user.phoneNumber}');
Expand Down
11 changes: 6 additions & 5 deletions lib/widgets/bottom_navigation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class BottomNavigation extends StatefulWidget {

class _BottomNavigationState extends State<BottomNavigation> {
int selectedTab = 0;
late Widget _currentPage;
late Widget currentPage;
late List<Widget> _pages;
late HomeScreen _homeScreen;
late HomeworkScreen _homeworkScreen;
Expand All @@ -40,7 +40,8 @@ class _BottomNavigationState extends State<BottomNavigation> {
void initState() {
super.initState();
_homeScreen = HomeScreen(
openHomeworkPage: openHomeworkPage, openSettingsPage: () { },
openHomeworkPage: openHomeworkPage,
openSettingsPage: () {},
);
_classesScreen = ClassesScreen();
_homeworkScreen = HomeworkScreen();
Expand All @@ -55,13 +56,13 @@ class _BottomNavigationState extends State<BottomNavigation> {
_profileScreen,
_settingsScreen
];
_currentPage = _homeScreen;
currentPage = _homeScreen;
}

void openHomeworkPage() {
setState(() {
selectedTab = 2;
_currentPage = _pages[2];
currentPage = _pages[2];
});
}

Expand Down Expand Up @@ -91,7 +92,7 @@ class _BottomNavigationState extends State<BottomNavigation> {
selectedTab: selectedTab,
onPressed: (int idx) {
_setCurrentPage(index: idx);
_currentPage = _pages[idx];
currentPage = _pages[idx];
print(selectedTab);
// _selectedTab = idx;
},
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/recents_homeworks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ class _RecentHomeworksState extends State<RecentHomeworks> {
},
);
}
return Text('NULL');
}

_todoButton(Homework homework) {
Expand All @@ -117,7 +116,8 @@ class _RecentHomeworksState extends State<RecentHomeworks> {
style: ElevatedButton.styleFrom(
shape: CircleBorder(
side: BorderSide(color: Theme.of(context).colorScheme.secondary),
), backgroundColor: homework.isDone
),
backgroundColor: homework.isDone
? Theme.of(context).colorScheme.secondary
: Colors.transparent,
),
Expand Down
17 changes: 9 additions & 8 deletions lib/widgets/signup_form_essential_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ class _SignUpFormEssentialDetailsState
ElevatedButton(
style: ElevatedButton.styleFrom(
padding:
EdgeInsets.symmetric(vertical: 13, horizontal: 20), backgroundColor: kAuthThemeColor,
EdgeInsets.symmetric(vertical: 13, horizontal: 20),
backgroundColor: kAuthThemeColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadiusDirectional.circular(30),
),
Expand All @@ -226,7 +227,7 @@ class _SignUpFormEssentialDetailsState
),
),
onPressed: () async {
if (_formKey.currentState?.validate() ?? false) {
if (_formKey.currentState?.validate() ?? false) {
_formKey.currentState!.save();
print(
"Validated: Name: ${_name.text} \n email: ${_email.text}");
Expand All @@ -239,16 +240,16 @@ class _SignUpFormEssentialDetailsState
});
// Authenticate user
errorMsg = await AuthenticationService.handleSignUp(
email: _email.text,
name: _name.text,
password: _pswd.text,
context: context,
);
email: _email.text,
name: _name.text,
password: _pswd.text,
context: context,
);
setState(() {
isProcessing = false;
_formKey.currentState?.reset();
//show error msg
errorMsg != null
errorMsg != ""
? showErrToast(errorMsg, errToast)
: print("User Authenticated");
});
Expand Down

0 comments on commit adc886c

Please sign in to comment.