import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: LoginPage(),
);
}
}
class LoginPage extends StatelessWidget {
final TextEditingController usernameController = TextEditingController();
final TextEditingController passwordController = TextEditingController();
void login(BuildContext context) {
String username = usernameController.text.trim();
String password = passwordController.text.trim();
if (username.isEmpty || password.isEmpty) {
// Show error message if username or password is empty
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text('Error'),
content: Text('Please enter both username and password.'),
actions: [
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: Text('OK'),
),
],
);
},
);
} else {
// Perform login logic here (e.g., validate credentials)
// For simplicity, just show success message here
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text('Login Successful'),
content: Text('Welcome, $username!'),
actions: [
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: Text('OK'),
),
],
);
},
);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Login Page'),
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextField(
controller: usernameController,
decoration: InputDecoration(
labelText: 'Username',
border: OutlineInputBorder(),
),
),
SizedBox(height: 16.0),
TextField(
controller: passwordController,
decoration: InputDecoration(
labelText: 'Password',
border: OutlineInputBorder(),
),
obscureText: true,
),
SizedBox(height: 16.0),
ElevatedButton(
onPressed: () {
login(context);
},
child: Text('Login'),
),
],
),
),
);
}
}
- Home
- Services
- Academic Support
- Specialized Professionals
- Professional Support
- Technology and IT Support
- Creative Services
- Educational Tutoring and Classes
- Personal Development
- Exam Preparation
- Arts and Literature
- Research and Analysis
- Custom Solutions
- Resources
Our Resource Bank
- All Academic Support
- Get Ready for Exams
- Technology & IT Support
- Graphic Design Guide
- Online Classes Help
- Exam Preparation Guide
- Become an Affiliate
- Assignments & Quizzes
- How we Help
- Career Tutoring
Free Tools and Actions
- Free Plagrism Report
- Free Word Counter
- Free Grammar Checker
- Free Reference Generator
- Customer Testimonials
- Customer Reviews
- Live Chat Support
- Interactive Quizzes
- E-book & Resource Library
- Personalized Study Plans
Guaranteed Assistance
ValueMotiveValueWe are dedicated to delivering exceptional quality in every service we provide ensuring Integrity and Transparency in a Client-Centered Approach
MotiveWe pride ourselves on commitment to excellence & customer satisfaction. By choosing us, you are partnering with elite team that values your success.
- More
- Contact