background 1.0.0
background: ^1.0.0 copied to clipboard
A Flutter package to display images or videos as backgrounds.
Background #
A Flutter package to display images or videos as backgrounds.
Features #
A flexible Flutter widget to display a customizable background—image or video—behind any child widget.
- Image Background: Automatically displays an image when an image file path is provided.
- Video Background: Plays a muted, looping video when a video file path is detected.
- Child Overlay: Seamlessly overlays your child widget on top of the background.
- Smart Media Detection: Automatically identifies the background type based on the file path.
- Perfect for splash screens, login pages, or any UI that needs a rich, dynamic background.
Preview #
Getting started #
- Add the latest version of package to your
pubspec.yaml(and runflutter pub get):
dependencies:
background:^1.0.0
OR
```console
flutter pub add background
- Import the package and use it in your Flutter App.
import 'package:background/background.dart';
Example usage #
Background Image #
@override
Widget build(BuildContext context) {
return Scaffold(
body: Background(
path: 'assets/png/image.png',
child: Center(
child: Text(
'Hello, Farhan!',
style: TextStyle(color: Colors.white, fontSize: 24),
),
),
)
);
}
Background Video #
@override
Widget build(BuildContext context) {
return Scaffold(
body: Background(
path: 'assets/video/background.mp4',
child: Center(
child: Text(
'Hello, Farhan!',
style: TextStyle(color: Colors.white, fontSize: 24),
),
),
)
);
}
Supported File Types #
| File Type | Supported |
|---|---|
| Image | PNG, JPG, JPEG, GIF, BMP, WEBP |
| Video | MP4, MOV, AVI, MKV, WEBM |