background 1.3.0
background: ^1.3.0 copied to clipboard
A Flutter package to display images or videos as backgrounds.
example/lib/main.dart
import 'package:background/background.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Background Example',
home: const MyHomePage(),
debugShowCheckedModeBanner: false,
);
}
}
class MyHomePage extends StatelessWidget {
const MyHomePage({super.key});
@override
Widget build(BuildContext context) {
return AnnotatedRegion<SystemUiOverlayStyle>(
value: const SystemUiOverlayStyle(
statusBarIconBrightness: Brightness.light, // white icons
),
child: Scaffold(
body: Background(
path: 'assets/bg3.mp4',
child: SafeArea(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
padding: const EdgeInsets.all(24),
margin: EdgeInsets.symmetric(horizontal: 20),
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.2),
borderRadius: BorderRadius.circular(16),
boxShadow: [
BoxShadow(
color: Colors.black26,
blurRadius: 8,
offset: Offset(0, 4),
),
],
),
child: Form(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
FlutterLogo(
size: 75,
),
const SizedBox(height: 24),
TextFormField(
decoration: InputDecoration(
hintText: 'Email',
filled: true,
fillColor: Colors.white.withOpacity(0.5),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
),
),
),
const SizedBox(height: 16),
TextFormField(
obscureText: true,
decoration: InputDecoration(
hintText: 'Password',
filled: true,
fillColor: Colors.white.withOpacity(0.5),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
),
),
),
const SizedBox(height: 24),
SizedBox(
width: 250,
height: 50, // Set your desired width
child: ElevatedButton(
onPressed: () {},
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blueAccent.shade700,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
child: const Padding(
padding: EdgeInsets.symmetric(
horizontal: 32,
vertical: 12,
),
child: Text(
'Login',
style: TextStyle(color: Colors.white),
),
),
),
),
],
),
),
),
const SizedBox(height: 125),
],
),
),
),
),
);
}
}