Screenshot of the below code,
The screen which you want your background image,
import 'package:flutter/material.dart';
class LoginScreen extends StatefulWidget {
const LoginScreen({super.key});
@override
State<LoginScreen> createState() => _LoginScreenState();
}
class _LoginScreenState extends State<LoginScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(children: [
Container(
// Set background
decoration: BoxDecoration(
image: const DecorationImage(
image: AssetImage("assets/images/log.jpg"),
fit: BoxFit.cover,
// not include on screenshot. Use this if you want to dark background
colorFilter: ColorFilter.mode(
Colors.black38,
BlendMode.darken,
),
),
),
),
// Text on your background
SafeArea(
// ignore: prefer_const_constructors
child: Text(
'Do it',
style: const TextStyle(fontSize: 40),
),
)
]),
);
}
}
}
if you want to
,
Comments
Post a Comment