pharmacy_mobile/lib/widgets/page_background_widget.dart
2025-02-26 18:00:41 +08:00

51 lines
1.7 KiB
Dart

import 'package:flutter/material.dart';
class PageBackgroundWidget extends StatelessWidget {
final Widget child;
final String? page;
final double? height;
final bool? dark;
const PageBackgroundWidget({super.key, required this.child, this.page, this.height, this.dark});
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Container(
alignment: Alignment.center,
height: height ?? MediaQuery.of(context).size.height + 200,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
page == 'login'
? 'assets/login_background.webp'
: page == 'register'
? 'assets/register_background.webp'
: page == 'menu'
? 'assets/menu_background.webp'
: 'assets/background.webp',
),
fit: BoxFit.cover, // Ensures the background covers the entire container
alignment: Alignment.center,
opacity: dark == true ? 0.1 : 0.3, // Adjusts the opacity as needed
),
gradient: RadialGradient(
tileMode: TileMode.clamp,
colors: dark == true
? [
Color.fromRGBO(19, 8, 26, 1),
Color.fromRGBO(43, 22, 60, 1),
]
: [
Color.fromRGBO(26, 8, 25, 1),
Color.fromRGBO(60, 22, 57, 1),
],
),
),
child: Center(
child: child,
)),
);
}
}