build method
- BuildContext context
override
Builds the UI for the welcome screen.
Displays a background image with a darkened overlay, app branding, and buttons to navigate to LoginScreen or RegisterScreen.
Parameters:
- context: The BuildContext for building the widget.
Returns: A Widget representing the welcome screen UI.
Implementation
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: [
Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage(
'assets/welcome_screen_background.jpg'), // Add background image
fit: BoxFit.cover,
colorFilter: ColorFilter.mode(
Colors.black26,
BlendMode.darken,
),
),
),
),
SafeArea(
child: Padding(
padding: const EdgeInsets.all(24.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const Spacer(),
const Text(
'Welcome to\nFarm Fresh',
style: TextStyle(
fontSize: 40,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
const SizedBox(height: 16),
const Text(
'Connect directly with local farmers and get fresh vegetables delivered to your doorstep',
style: TextStyle(
fontSize: 16,
color: Colors.white70,
),
),
const SizedBox(height: 48),
ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const LoginScreen()),
);
},
style: ElevatedButton.styleFrom(
backgroundColor: Colors.green,
padding: const EdgeInsets.symmetric(vertical: 16),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
child: const Text(
'Login',
style: TextStyle(
fontSize: 18,
color: Colors.white,
),
),
),
const SizedBox(height: 16),
OutlinedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const RegisterScreen()),
);
},
style: OutlinedButton.styleFrom(
side: const BorderSide(color: Colors.white),
padding: const EdgeInsets.symmetric(vertical: 16),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
child: const Text(
'Register',
style: TextStyle(
fontSize: 18,
color: Colors.white,
),
),
),
const SizedBox(height: 48),
],
),
),
),
],
),
);
}