Skip to content
This repository was archived by the owner on Dec 5, 2023. It is now read-only.

Commit 6914f34

Browse files
Merge pull request #13 from Iconica-Development/feat/background-decoration
add background decoration
2 parents 28b141a + bb9c5f2 commit 6914f34

File tree

6 files changed

+34
-7
lines changed

6 files changed

+34
-7
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
##[1.1.2] - 29 November 2022
2+
3+
* add custom background to introduction page
14
## [1.1.1] - 20 October 2022
25

36
* fix single button mode position and size

example/lib/main.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@ class MyApp extends StatelessWidget {
4040
),
4141
IntroductionPage(
4242
title: const Text('Layout Shift'),
43+
decoration: const BoxDecoration(
44+
gradient: LinearGradient(
45+
begin: Alignment.topRight,
46+
end: Alignment.bottomLeft,
47+
colors: [
48+
Colors.yellow,
49+
Colors.red,
50+
Colors.indigo,
51+
Colors.teal,
52+
],
53+
)),
4354
text: const Text(
4455
'You can change the layout of a page to mix things up.'),
4556
graphic: const FlutterLogo(size: 100),

lib/src/config/introduction.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class IntroductionPage {
2626
final Widget? text;
2727
final Widget? graphic;
2828
final ImageProvider? backgroundImage;
29+
final Decoration? decoration;
2930
final IntroductionLayoutStyle? layoutStyle;
3031

3132
/// Creates an introduction page with data used in the introduction screen for
@@ -41,6 +42,7 @@ class IntroductionPage {
4142
this.text,
4243
this.graphic,
4344
this.backgroundImage,
45+
this.decoration,
4446
this.layoutStyle,
4547
});
4648
}

lib/src/types/page_introduction.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ class ExplainerPage extends StatelessWidget {
214214
Widget build(BuildContext context) {
215215
var theme = Theme.of(context);
216216
return Background(
217+
background: page.decoration,
217218
backgroundImage: page.backgroundImage,
218219
child: SafeArea(
219220
child: Column(

lib/src/widgets/background.dart

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,30 @@ import 'package:flutter/material.dart';
66

77
class Background extends StatelessWidget {
88
const Background({
9+
this.background,
910
required this.child,
1011
this.backgroundImage,
1112
Key? key,
1213
}) : super(key: key);
1314

15+
final Decoration? background;
1416
final Widget child;
1517
final ImageProvider? backgroundImage;
1618

1719
@override
1820
Widget build(BuildContext context) {
1921
var theme = Theme.of(context);
22+
var background = this.background ??
23+
BoxDecoration(
24+
color: theme.backgroundColor,
25+
);
26+
var size = MediaQuery.of(context).size;
2027
var backgroundImage = this.backgroundImage;
2128
if (backgroundImage != null) {
22-
return Material(
23-
color: theme.backgroundColor,
29+
return Container(
30+
width: size.width,
31+
height: size.height,
32+
decoration: background,
2433
child: DecoratedBox(
2534
decoration: BoxDecoration(
2635
image: DecorationImage(
@@ -32,10 +41,11 @@ class Background extends StatelessWidget {
3241
),
3342
);
3443
} else {
35-
return Material(
36-
color: theme.backgroundColor,
37-
child: child,
38-
);
44+
return Container(
45+
width: size.width,
46+
height: size.height,
47+
decoration: background,
48+
child: child);
3949
}
4050
}
4151
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_introduction_widget
22
description: Flutter Introduction Widget for showing a list of introduction pages on a single scrollable page or horizontal pageview
3-
version: 1.1.1
3+
version: 1.1.2
44
homepage: https://github.com/Iconica-Development/flutter_introduction_widget
55

66
environment:

0 commit comments

Comments
 (0)