summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/main.dart8
-rw-r--r--lib/userpage/Scoreboardpage.dart8
-rw-r--r--lib/userpage/adminpage.dart18
-rw-r--r--lib/userpage/bloc/quiz_bloc.dart2
-rw-r--r--lib/userpage/loginpage.dart14
-rw-r--r--lib/userpage/quizpage.dart20
-rw-r--r--lib/userpage/quizpagestate.dart4
-rw-r--r--lib/userpage/userverificationpage.dart14
-rw-r--r--pubspec.lock30
9 files changed, 62 insertions, 56 deletions
diff --git a/lib/main.dart b/lib/main.dart
index 666386d..0df017a 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -11,7 +11,7 @@ import 'package:provider/provider.dart'; // Import ScoreboardPage
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
- options: FirebaseOptions(
+ options: const FirebaseOptions(
apiKey: "AIzaSyAT9nOFo3DuDMksnTBtdKCgwS7LCLXwk4I",
appId: "1:475088015638:web:ab5aa1ad2800104627c037",
messagingSenderId: "475088015638",
@@ -20,7 +20,7 @@ void main() async {
),
);
- runApp(MyApp());
+ runApp(const MyApp());
}
class MyApp extends StatefulWidget {
@@ -68,13 +68,13 @@ class _MyAppState extends State<MyApp> {
Widget _buildHomePage() {
switch (gameState) {
case 'login':
- return LoginPage(); // Show LoginPage
+ return const LoginPage(); // Show LoginPage
case 'start':
return UserVerificationPage(); // Show UserVerificationPage
case 'end':
return ScoreboardPage(); // Show ScoreboardPage
default:
- return Center(
+ return const Center(
child:
CircularProgressIndicator()); // Loading indicator if state is unknown
}
diff --git a/lib/userpage/Scoreboardpage.dart b/lib/userpage/Scoreboardpage.dart
index 9f238a5..c72a04f 100644
--- a/lib/userpage/Scoreboardpage.dart
+++ b/lib/userpage/Scoreboardpage.dart
@@ -2,6 +2,8 @@ import 'package:firebase_database/firebase_database.dart';
import 'package:flutter/material.dart';
class ScoreboardPage extends StatefulWidget {
+ const ScoreboardPage({super.key});
+
@override
_ScoreboardPageState createState() => _ScoreboardPageState();
}
@@ -42,13 +44,13 @@ class _ScoreboardPageState extends State<ScoreboardPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
- appBar: AppBar(title: Text("Scoreboard")),
+ appBar: AppBar(title: const Text("Scoreboard")),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: isLoading
- ? Center(child: CircularProgressIndicator())
+ ? const Center(child: CircularProgressIndicator())
: users.isEmpty
- ? Center(child: Text("No users found"))
+ ? const Center(child: Text("No users found"))
: ListView.builder(
itemCount: users.length,
itemBuilder: (context, index) {
diff --git a/lib/userpage/adminpage.dart b/lib/userpage/adminpage.dart
index c3d533d..942ea98 100644
--- a/lib/userpage/adminpage.dart
+++ b/lib/userpage/adminpage.dart
@@ -2,6 +2,8 @@ import 'package:firebase_database/firebase_database.dart';
import 'package:flutter/material.dart';
class AdminPage extends StatefulWidget {
+ const AdminPage({super.key});
+
@override
_AdminPageState createState() => _AdminPageState();
}
@@ -76,7 +78,7 @@ class _AdminPageState extends State<AdminPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
- appBar: AppBar(title: Text("Admin Page")),
+ appBar: AppBar(title: const Text("Admin Page")),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
@@ -86,26 +88,26 @@ class _AdminPageState extends State<AdminPage> {
children: [
ElevatedButton(
onPressed: () => _updateGameState('login'),
- child: Text("Login"),
+ child: const Text("Login"),
),
ElevatedButton(
onPressed: () => _updateGameState('start'),
- child: Text("Start"),
+ child: const Text("Start"),
),
ElevatedButton(
onPressed: () => _updateGameState('end'),
- child: Text("End"),
+ child: const Text("End"),
),
],
),
- SizedBox(height: 20),
+ const SizedBox(height: 20),
Text("Current Game State: $gameState",
- style: TextStyle(fontSize: 18)),
- SizedBox(height: 20),
+ style: const TextStyle(fontSize: 18)),
+ const SizedBox(height: 20),
// Show scoreboard if game state is 'start' or 'end'
if (gameState == 'start' || gameState == 'end')
isLoading
- ? CircularProgressIndicator()
+ ? const CircularProgressIndicator()
: Expanded(
child: ListView.builder(
itemCount: users.length,
diff --git a/lib/userpage/bloc/quiz_bloc.dart b/lib/userpage/bloc/quiz_bloc.dart
index 37213b4..61ccf1b 100644
--- a/lib/userpage/bloc/quiz_bloc.dart
+++ b/lib/userpage/bloc/quiz_bloc.dart
@@ -9,7 +9,7 @@ import 'package:firebase_database/firebase_database.dart';
class QuizBloc extends Bloc<QuizEvent, QuizState> {
final DatabaseReference database = FirebaseDatabase.instance.ref();
List<Map> questions = [];
- Set<String> answeredQuestions = Set();
+ Set<String> answeredQuestions = {};
int score = 0;
QuizBloc() : super(QuizInitial());
diff --git a/lib/userpage/loginpage.dart b/lib/userpage/loginpage.dart
index 7bbd3b4..0fdda98 100644
--- a/lib/userpage/loginpage.dart
+++ b/lib/userpage/loginpage.dart
@@ -74,7 +74,7 @@ class _LoginPageState extends State<LoginPage> {
// Show a success message
ScaffoldMessenger.of(context).showSnackBar(
- SnackBar(content: Text('User created successfully')),
+ const SnackBar(content: Text('User created successfully')),
);
setState(() {
_iswaiting = true;
@@ -96,13 +96,13 @@ class _LoginPageState extends State<LoginPage> {
Widget build(BuildContext context) {
return Scaffold(
body: _iswaiting
- ? Text(
+ ? const Text(
"Waiting page.....",
style: TextStyle(color: Colors.red, fontSize: 30),
)
: SingleChildScrollView(
child: Padding(
- padding: EdgeInsets.all(16.0),
+ padding: const EdgeInsets.all(16.0),
child: Form(
key: _formKey,
child: Column(
@@ -126,13 +126,13 @@ class _LoginPageState extends State<LoginPage> {
labelText: 'Option 2', controller: option2Controller),
CustomTextField(
labelText: 'Option 3', controller: option3Controller),
- SizedBox(height: 20),
+ const SizedBox(height: 20),
_isLoading
- ? CircularProgressIndicator() // Show loader if loading
+ ? const CircularProgressIndicator() // Show loader if loading
: ElevatedButton(
onPressed:
_submitData, // Call _submitData function
- child: Text('Submit'),
+ child: const Text('Submit'),
),
],
),
@@ -147,7 +147,7 @@ class CustomTextField extends StatelessWidget {
final String labelText;
final TextEditingController controller;
- CustomTextField({required this.labelText, required this.controller});
+ const CustomTextField({super.key, required this.labelText, required this.controller});
@override
Widget build(BuildContext context) {
diff --git a/lib/userpage/quizpage.dart b/lib/userpage/quizpage.dart
index bfc5073..62ac74d 100644
--- a/lib/userpage/quizpage.dart
+++ b/lib/userpage/quizpage.dart
@@ -7,7 +7,7 @@ class QuizPage extends StatefulWidget {
final String email;
final String userId; // Pass user ID along with email
- QuizPage({required this.email, required this.userId});
+ const QuizPage({super.key, required this.email, required this.userId});
@override
_QuizPageState createState() => _QuizPageState();
@@ -20,7 +20,7 @@ class _QuizPageState extends State<QuizPage> {
bool isLoading = true;
List<Map> questions = [];
int currentQuestionIndex = 0;
- Set<String> answeredQuestions = Set<String>(); // Track answered questions
+ Set<String> answeredQuestions = <String>{}; // Track answered questions
@override
void initState() {
@@ -145,25 +145,25 @@ class _QuizPageState extends State<QuizPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
- appBar: AppBar(title: Text("Quiz")),
+ appBar: AppBar(title: const Text("Quiz")),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: StreamBuilder<Map>(
stream: _questionController.stream,
builder: (context, snapshot) {
if (isLoading) {
- return Center(child: CircularProgressIndicator());
+ return const Center(child: CircularProgressIndicator());
}
// Handle loading state
if (snapshot.connectionState == ConnectionState.waiting) {
- return Center(child: CircularProgressIndicator());
+ return const Center(child: CircularProgressIndicator());
}
// Handle the case when no more questions are available
if (snapshot.hasData &&
snapshot.data!['no_more_questions'] == true) {
- return Center(child: Text("No more questions available."));
+ return const Center(child: Text("No more questions available."));
}
// Handle the state when data is available (quiz ongoing)
@@ -174,23 +174,23 @@ class _QuizPageState extends State<QuizPage> {
children: [
Text(
question['question'],
- style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
+ style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
- SizedBox(height: 20),
+ const SizedBox(height: 20),
...question['options'].map<Widget>((option) {
return ListTile(
title: Text(option),
onTap: () => _checkAnswer(option, question),
);
}).toList(),
- SizedBox(height: 20),
+ const SizedBox(height: 20),
Text("Score: $score"),
],
);
}
// Default case (shouldn't hit unless there's an issue)
- return Center(child: Text("An error occurred."));
+ return const Center(child: Text("An error occurred."));
},
),
),
diff --git a/lib/userpage/quizpagestate.dart b/lib/userpage/quizpagestate.dart
index 3736128..f7b1278 100644
--- a/lib/userpage/quizpagestate.dart
+++ b/lib/userpage/quizpagestate.dart
@@ -6,7 +6,7 @@ import 'package:flutter/foundation.dart';
class QuizState with ChangeNotifier {
List<Map> questions = [];
- Set<String> answeredQuestions = Set();
+ Set<String> answeredQuestions = {};
int score = 0;
bool isLoading = true;
@@ -34,7 +34,7 @@ Future<void> checkAnswer(String selectedAnswer, Map question, DatabaseReference
// Cancel previous debounce
_debounceTimer?.cancel();
- _debounceTimer = Timer(Duration(milliseconds: 200), () async {
+ _debounceTimer = Timer(const Duration(milliseconds: 200), () async {
if (selectedAnswer == question['answer']) {
score += 4;
} else {
diff --git a/lib/userpage/userverificationpage.dart b/lib/userpage/userverificationpage.dart
index 0937f92..3c163ed 100644
--- a/lib/userpage/userverificationpage.dart
+++ b/lib/userpage/userverificationpage.dart
@@ -3,6 +3,8 @@ import 'package:flutter/material.dart';
import 'package:freshers/userpage/quizpage.dart';
class UserVerificationPage extends StatefulWidget {
+ const UserVerificationPage({super.key});
+
@override
_UserVerificationPageState createState() => _UserVerificationPageState();
}
@@ -59,7 +61,7 @@ class _UserVerificationPageState extends State<UserVerificationPage> {
} else {
// If userId is not found, show an error
ScaffoldMessenger.of(context).showSnackBar(
- SnackBar(content: Text("User not found. Please register.")),
+ const SnackBar(content: Text("User not found. Please register.")),
);
}
}
@@ -67,7 +69,7 @@ class _UserVerificationPageState extends State<UserVerificationPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
- appBar: AppBar(title: Text("User Verification")),
+ appBar: AppBar(title: const Text("User Verification")),
backgroundColor: Colors.white,
body: Padding(
padding: const EdgeInsets.all(16.0),
@@ -75,16 +77,16 @@ class _UserVerificationPageState extends State<UserVerificationPage> {
children: [
TextField(
controller: nameController,
- decoration: InputDecoration(labelText: "Name"),
+ decoration: const InputDecoration(labelText: "Name"),
),
TextField(
controller: emailController,
- decoration: InputDecoration(labelText: "Email"),
+ decoration: const InputDecoration(labelText: "Email"),
),
- SizedBox(height: 20),
+ const SizedBox(height: 20),
ElevatedButton(
onPressed: _verifyUser, // Call _verifyUser on button press
- child: Text("Continue..."),
+ child: const Text("Continue..."),
),
],
),
diff --git a/pubspec.lock b/pubspec.lock
index ee3ecd0..eecdcc3 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -164,26 +164,26 @@ packages:
dependency: transitive
description:
name: leak_tracker
- sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
+ sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
url: "https://pub.dev"
source: hosted
- version: "10.0.0"
+ version: "10.0.5"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
- sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
+ sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
url: "https://pub.dev"
source: hosted
- version: "2.0.1"
+ version: "3.0.5"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
- sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
+ sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
url: "https://pub.dev"
source: hosted
- version: "2.0.1"
+ version: "3.0.1"
lints:
dependency: transitive
description:
@@ -204,18 +204,18 @@ packages:
dependency: transitive
description:
name: material_color_utilities
- sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
+ sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
url: "https://pub.dev"
source: hosted
- version: "0.8.0"
+ version: "0.11.1"
meta:
dependency: transitive
description:
name: meta
- sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
+ sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
url: "https://pub.dev"
source: hosted
- version: "1.11.0"
+ version: "1.15.0"
nested:
dependency: transitive
description:
@@ -297,10 +297,10 @@ packages:
dependency: transitive
description:
name: test_api
- sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
+ sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
url: "https://pub.dev"
source: hosted
- version: "0.6.1"
+ version: "0.7.2"
vector_math:
dependency: transitive
description:
@@ -313,10 +313,10 @@ packages:
dependency: transitive
description:
name: vm_service
- sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
+ sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
url: "https://pub.dev"
source: hosted
- version: "13.0.0"
+ version: "14.2.5"
web:
dependency: transitive
description:
@@ -327,4 +327,4 @@ packages:
version: "0.5.1"
sdks:
dart: ">=3.3.0 <4.0.0"
- flutter: ">=3.16.0"
+ flutter: ">=3.18.0-18.0.pre.54"