Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,31 @@ class OnBoardingPageState extends State<OnBoardingPage> {
decoration: pageDecoration,
),
PageViewModel(
title: "Full Screen Page",
title: "Full Screen Page with backgroundImage",
body:
"Pages can be full screen as well.\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc id euismod lectus, non tempor felis. Nam rutrum rhoncus est ac venenatis.",
backgroundImage: backgroundImage,
decoration: pageDecoration.copyWith(
contentMargin: const EdgeInsets.symmetric(horizontal: 16),
bodyFlex: 2,
bodyFlex: 4,
imageFlex: 3,
safeArea: 100,
),
),
PageViewModel(
title: "Full Screen Page with backgroundImageWidget",
body:
"Pages can be full screen as well.\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc id euismod lectus, non tempor felis. Nam rutrum rhoncus est ac venenatis.",
backgroundImageWidget: Image.asset(
backgroundImage,
fit: BoxFit.cover,
height: double.infinity,
width: double.infinity,
alignment: Alignment.center,
),
decoration: pageDecoration.copyWith(
contentMargin: const EdgeInsets.symmetric(horizontal: 16),
bodyFlex: 4,
imageFlex: 3,
safeArea: 100,
),
Expand Down
13 changes: 12 additions & 1 deletion lib/src/model/page_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ class PageViewModel {
/// Tips: can be used alone or as a background image together with the "image" parameter.
final String? backgroundImage;

/// Background image widget of a page.
/// Spans all over the screen.
///
/// Tips: can be used alone or as a background image together with the "image" parameter. Use this instead of backgroundImage for more flexibility
final Widget? backgroundImageWidget;

/// Footer widget, you can add a button for example
final Widget? footer;

Expand All @@ -52,6 +58,7 @@ class PageViewModel {
this.bodyWidget,
this.image,
this.backgroundImage,
this.backgroundImageWidget,
this.footer,
this.reverse = false,
this.decoration = const PageDecoration(),
Expand All @@ -78,5 +85,9 @@ class PageViewModel {
assert(
backgroundImage == null ||
isBackgroundImageAssetPathValid(backgroundImage),
"You must provide a valid image asset path");
"You must provide a valid image asset path"),
assert(
backgroundImageWidget == null || backgroundImage == null,
"You can not provide both backgroundImage and backgroundImageWidget.",
);
}
32 changes: 23 additions & 9 deletions lib/src/ui/intro_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,33 @@ class _IntroPageState extends State<IntroPage>
@override
bool get wantKeepAlive => true;

Widget? _buildBackgroundImage() {
final page = widget.page;

if (page.backgroundImageWidget != null) {
return page.backgroundImageWidget!;
}

if (page.backgroundImage != null) {
return Image.asset(
page.backgroundImage!,
fit: BoxFit.cover,
height: double.infinity,
width: double.infinity,
alignment: Alignment.center,
);
}

return null;
}

Widget _buildStack() {
final PageViewModel page = widget.page;
final content = IntroContent(page: page, isFullScreen: true);

return Stack(
children: [
if (page.backgroundImage != null)
Image.asset(
page.backgroundImage!,
fit: BoxFit.cover,
height: double.infinity,
width: double.infinity,
alignment: Alignment.center,
),
if (_buildBackgroundImage() != null) _buildBackgroundImage()!,
if (page.image != null) page.image!,
Positioned.fill(
child: Column(
Expand Down Expand Up @@ -136,7 +149,8 @@ class _IntroPageState extends State<IntroPage>
super.build(context);

if (widget.page.decoration.fullScreen ||
widget.page.backgroundImage != null) {
widget.page.backgroundImage != null ||
widget.page.backgroundImageWidget != null) {
return _buildStack();
}
return _buildFlex(context);
Expand Down