flutter_introduction/packages/flutter_introduction_widget/lib/src/widgets/background.dart

38 lines
901 B
Dart
Raw Normal View History

// SPDX-FileCopyrightText: 2022 Iconica
//
// SPDX-License-Identifier: BSD-3-Clause
import 'package:flutter/material.dart';
2024-02-19 16:53:21 +01:00
/// Widget representing a background with optional decoration.
class Background extends StatelessWidget {
2024-02-19 16:53:21 +01:00
/// Constructs a Background widget.
const Background({
required this.child,
2023-11-29 11:54:25 +01:00
this.background,
super.key,
});
2024-02-19 16:53:21 +01:00
/// Optional decoration for the background.
final BoxDecoration? background;
2024-02-19 16:53:21 +01:00
/// The widget to be placed on the background.
final Widget child;
@override
Widget build(BuildContext context) {
var theme = Theme.of(context);
var background = this.background ??
BoxDecoration(
color: theme.colorScheme.background,
);
var size = MediaQuery.of(context).size;
return Container(
width: size.width,
height: size.height,
decoration: background,
child: child,
);
}
}