Skip to content

Commit 14f3471

Browse files
committed
Make title, body and mainImage properties not required and non-nullable
1 parent 090c866 commit 14f3471

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ You should then run `flutter packages get` in your terminal so as to get the pac
138138
| :-------------------- | :------------- | :-------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------: |
139139
| pageColor | Color? | Set color of the page. | Null |
140140
| pageBackground | Widget | Set a widget as a background of the whole page (pageColor has priority) | Null |
141-
| mainImage | Image? / Widget? | Set the main image of the page. | Null |
142-
| title | Text? / Widget? | Set the title text of the page. If null, then the widget is omitted. | Null |
143-
| body | Text? / Widget? | Set the body text of the page. If null, then the widget is omitted. | Null |
141+
| mainImage | Image / Widget | Set the main image of the page. If null, then the widget is omitted. | Null |
142+
| title | Text / Widget | Set the title text of the page. If null, then the widget is omitted. | Null |
143+
| body | Text / Widget | Set the body text of the page. If null, then the widget is omitted. | Null |
144144
| iconImageAssetPath | String? | Set the icon image asset path that would be displayed in page bubble. | Null |
145145
| iconColor | Color? | Set the page bubble icon color. | Null |
146146
| bubbleBackgroundColor | Color | Set the page bubble background color. | Colors.white / Color(0x88FFFFFF) |

lib/src/models/page_view_model.dart

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ class PageViewModel {
88
this.iconImageAssetPath,
99
this.bubbleBackgroundColor = const Color(0x88FFFFFF),
1010
this.iconColor,
11-
required this.title,
12-
required this.body,
13-
required this.mainImage,
11+
this.title = const SizedBox(),
12+
this.body = const SizedBox(),
13+
this.mainImage = const SizedBox(),
1414
this.bubble,
1515
this.textStyle,
1616
this.titleTextStyle = const TextStyle(color: Colors.white, fontSize: 50.0),
@@ -44,15 +44,15 @@ class PageViewModel {
4444
///
4545
/// _Typically a [Text] widget_.
4646
///
47-
/// If null, then the widget is omitted.
48-
final Widget? title;
47+
/// Omitted by default.
48+
final Widget title;
4949

5050
/// Widget for the body.
5151
///
5252
/// _Typically a [Text] widget_.
5353
///
54-
/// If null, then the widget is omitted.
55-
final Widget? body;
54+
/// Omitted by default.
55+
final Widget body;
5656

5757
/// Sets TextStyle for [titleTextStyle] and [bodyTextStyle].
5858
///
@@ -75,9 +75,8 @@ class PageViewModel {
7575
///
7676
/// _Typically an [Image] widget_.
7777
///
78-
///
79-
/// If null, then the widget is omitted.
80-
final Widget? mainImage;
78+
/// Omitted by default.
79+
final Widget mainImage;
8180

8281
/// Inner bubble widget.
8382
///

lib/src/ui/page.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class _BodyPageTransform extends StatelessWidget {
142142
child: DefaultTextStyle.merge(
143143
textAlign: TextAlign.center,
144144
style: pageViewModel.mergedBodyTextStyle,
145-
child: pageViewModel.body ?? const SizedBox(),
145+
child: pageViewModel.body,
146146
),
147147
),
148148
);
@@ -173,7 +173,7 @@ class _ImagePageTransform extends StatelessWidget {
173173
bottom: 40.0,
174174
),
175175
child: Container(
176-
child: pageViewModel.mainImage, // Loading main
176+
child: pageViewModel.mainImage,
177177
),
178178
),
179179
);
@@ -207,7 +207,7 @@ class _TitlePageTransform extends StatelessWidget {
207207
),
208208
child: DefaultTextStyle.merge(
209209
style: pageViewModel.mergedTitleTextStyle,
210-
child: pageViewModel.title ?? const SizedBox(),
210+
child: pageViewModel.title,
211211
),
212212
),
213213
);

0 commit comments

Comments
 (0)