Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions task_manager_app/lib/home_page.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'student_registration_screen.dart';

class HomePage extends StatelessWidget {
const HomePage({super.key});
Expand Down Expand Up @@ -31,6 +32,22 @@ class HomePage extends StatelessWidget {
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),

const SizedBox(height: 30),

// Student Registration Button
ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
const StudentRegistrationScreen(),
),
);
},
child: const Text('Student Registration'),
),
],
),
),
Expand Down
2 changes: 2 additions & 0 deletions task_manager_app/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'student_registration_screen.dart';
import 'home_page.dart';

void main() {
Expand All @@ -17,6 +18,7 @@ class TaskManagerApp extends StatelessWidget {
useMaterial3: true,
),
home: const HomePage(),
// home: const StudentRegistrationScreen(),
);
}
}
106 changes: 106 additions & 0 deletions task_manager_app/lib/student_registration_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import 'package:flutter/material.dart';

class StudentRegistrationScreen extends StatefulWidget {
const StudentRegistrationScreen({super.key});

@override
State<StudentRegistrationScreen> createState() =>
_StudentRegistrationScreenState();
}

class _StudentRegistrationScreenState
extends State<StudentRegistrationScreen> {

final _formKey = GlobalKey<FormState>();

final nameController = TextEditingController();
final idController = TextEditingController();
final emailController = TextEditingController();
final courseController = TextEditingController();

void submitForm() {
if (_formKey.currentState!.validate()) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text("Student Registered Successfully")),
);
}
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Student Registration"),
),
body: Padding(
padding: const EdgeInsets.all(20),
child: Form(
key: _formKey,
child: Column(
children: [

TextFormField(
controller: nameController,
decoration: const InputDecoration(
labelText: "Student Name",
),
validator: (value) {
if (value == null || value.isEmpty) {
return "Enter student name";
}
return null;
},
),

TextFormField(
controller: idController,
decoration: const InputDecoration(
labelText: "Student ID",
),
validator: (value) {
if (value == null || value.isEmpty) {
return "Enter student ID";
}
return null;
},
),

TextFormField(
controller: emailController,
decoration: const InputDecoration(
labelText: "Email",
),
validator: (value) {
if (value == null || value.isEmpty) {
return "Enter email";
}
return null;
},
),

TextFormField(
controller: courseController,
decoration: const InputDecoration(
labelText: "Course",
),
validator: (value) {
if (value == null || value.isEmpty) {
return "Enter course";
}
return null;
},
),

const SizedBox(height: 20),

ElevatedButton(
onPressed: submitForm,
child: const Text("Submit"),
),
],
),
),
),
);
}
}
Loading