Enhance Flutter LMS Application
Budget: ₹12,500 – ₹37,500 INR
// main.dart
import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
// Make sure to configure Firebase for iOS, Android & Web
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(LMSApp());
}
class LMSApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'LMS MVP',
theme: ThemeData(
primarySwatch: Colors.blue,
brightness: Brightness.light,
),
home: AuthGate(),
debugShowCheckedModeBanner: false,
);
}
}
// Simple Authentication Gate
class AuthGate extends StatelessWidget {
@override
Widget build(BuildContext context) {
return StreamBuilder<User?>(
stream: FirebaseAuth.instance.authStateChanges(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return HomePage();
}
return SignInPage();
},
);
}
}
// Sign-in Page
class SignInPage extends StatefulWidget {
@override
_SignInPageState createState() => _SignInPageState();
}
class _SignInPageState extends State<SignInPage> {
final _emailController = TextEditingController();
final _passwordController = TextEditingController();
bool loading = false;
Future<void> signIn() async {
setState(() => loading = true);
try {
await FirebaseAuth.instance.signInWithEmailAndPassword(
email: _emailController.text,
password: _passwordController.text,
);
} catch (e) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('Error: $e')));
}
setState(() => loading = false);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextField(controller: _emailController, decoration: InputDecoration(labelText: 'Email')),
TextField(controller: _passwordController, decoration: InputDecoration(labelText: 'Password'), obscureText: true),
SizedBox(height: 20),
ElevatedButton(
onPressed: loading ? null : signIn,
child: loading ? CircularProgressIndicator() : Text('Sign In'),
),
],
),
),
),
);
}
}
// Home Page / Courses List
class HomePage extends StatelessWidget {
final courses = [
{'title': 'Flutter Basics', 'progress': 0.3, 'quizId': 'quiz1', 'liveLink': 'https://zoom.us'},
{'title': 'Firebase 101', 'progress': 0.6, 'quizId': 'quiz2', 'liveLink': 'https://meet.google.com'},
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Courses'),
actions: [
IconButton(
icon: Icon(Icons.logout),
onPressed: () => FirebaseAuth.instance.signOut(),
)
],
),
body: ListView.builder(
itemCount: courses.length,
itemBuilder: (context, index) {
final course = courses[index];
return Card(
margin: EdgeInsets.all(10),
child: ListTile(
title: Text(course['title']!),
subtitle: LinearProgressIndicator(value: course['progress']),
trailing: IconButton(
icon: Icon(Icons.play_circle_fill),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (_) => CoursePage(course: course)),
);
},
),
),
);
},
),
);
}
}
// Individual Course Page
class CoursePage extends StatelessWidget {
final Map course;
CoursePage({required this.course});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text(course['title'])),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: [
ElevatedButton.icon(
icon: Icon(Icons.quiz),
label: Text('Take Quiz'),
onPressed: () {
Navigator.push(context, MaterialPageRoute(builder: (_) => QuizPage(quizId: course['quizId'])));
},
),
SizedBox(height: 10),
ElevatedButton.icon(
icon: Icon(Icons.video_call),
label: Text('Join Live Class'),
onPressed: () {
// Open live link in browser
launchURL(course['liveLink']);
},
),
SizedBox(height: 20),
Expanded(child: MessagingPlaceholder()),
],
),
),
);
}
}
// Placeholder for Messaging
class MessagingPlaceholder extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Center(child: Text('Messaging coming soon...', style: TextStyle(color: Colors.grey)));
}
}
// Simple Quiz Page
class QuizPage extends StatelessWidget {
final String quizId;
QuizPage({required this.quizId});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Quiz')),
body: Center(
child: Text('Quiz content for $quizId coming soon...', style: TextStyle(fontSize: 18)),
),
);
}
}
// Helper to launch external URLs
import 'package:url_launcher/url_launcher.dart';
void launchURL(String url) async {
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}
import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
// Make sure to configure Firebase for iOS, Android & Web
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(LMSApp());
}
class LMSApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'LMS MVP',
theme: ThemeData(
primarySwatch: Colors.blue,
brightness: Brightness.light,
),
home: AuthGate(),
debugShowCheckedModeBanner: false,
);
}
}
// Simple Authentication Gate
class AuthGate extends StatelessWidget {
@override
Widget build(BuildContext context) {
return StreamBuilder<User?>(
stream: FirebaseAuth.instance.authStateChanges(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return HomePage();
}
return SignInPage();
},
);
}
}
// Sign-in Page
class SignInPage extends StatefulWidget {
@override
_SignInPageState createState() => _SignInPageState();
}
class _SignInPageState extends State<SignInPage> {
final _emailController = TextEditingController();
final _passwordController = TextEditingController();
bool loading = false;
Future<void> signIn() async {
setState(() => loading = true);
try {
await FirebaseAuth.instance.signInWithEmailAndPassword(
email: _emailController.text,
password: _passwordController.text,
);
} catch (e) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('Error: $e')));
}
setState(() => loading = false);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextField(controller: _emailController, decoration: InputDecoration(labelText: 'Email')),
TextField(controller: _passwordController, decoration: InputDecoration(labelText: 'Password'), obscureText: true),
SizedBox(height: 20),
ElevatedButton(
onPressed: loading ? null : signIn,
child: loading ? CircularProgressIndicator() : Text('Sign In'),
),
],
),
),
),
);
}
}
// Home Page / Courses List
class HomePage extends StatelessWidget {
final courses = [
{'title': 'Flutter Basics', 'progress': 0.3, 'quizId': 'quiz1', 'liveLink': 'https://zoom.us'},
{'title': 'Firebase 101', 'progress': 0.6, 'quizId': 'quiz2', 'liveLink': 'https://meet.google.com'},
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Courses'),
actions: [
IconButton(
icon: Icon(Icons.logout),
onPressed: () => FirebaseAuth.instance.signOut(),
)
],
),
body: ListView.builder(
itemCount: courses.length,
itemBuilder: (context, index) {
final course = courses[index];
return Card(
margin: EdgeInsets.all(10),
child: ListTile(
title: Text(course['title']!),
subtitle: LinearProgressIndicator(value: course['progress']),
trailing: IconButton(
icon: Icon(Icons.play_circle_fill),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (_) => CoursePage(course: course)),
);
},
),
),
);
},
),
);
}
}
// Individual Course Page
class CoursePage extends StatelessWidget {
final Map course;
CoursePage({required this.course});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text(course['title'])),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: [
ElevatedButton.icon(
icon: Icon(Icons.quiz),
label: Text('Take Quiz'),
onPressed: () {
Navigator.push(context, MaterialPageRoute(builder: (_) => QuizPage(quizId: course['quizId'])));
},
),
SizedBox(height: 10),
ElevatedButton.icon(
icon: Icon(Icons.video_call),
label: Text('Join Live Class'),
onPressed: () {
// Open live link in browser
launchURL(course['liveLink']);
},
),
SizedBox(height: 20),
Expanded(child: MessagingPlaceholder()),
],
),
),
);
}
}
// Placeholder for Messaging
class MessagingPlaceholder extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Center(child: Text('Messaging coming soon...', style: TextStyle(color: Colors.grey)));
}
}
// Simple Quiz Page
class QuizPage extends StatelessWidget {
final String quizId;
QuizPage({required this.quizId});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Quiz')),
body: Center(
child: Text('Quiz content for $quizId coming soon...', style: TextStyle(fontSize: 18)),
),
);
}
}
// Helper to launch external URLs
import 'package:url_launcher/url_launcher.dart';
void launchURL(String url) async {
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}