1
- import 'package:connectivity_wrapper/connectivity_wrapper.dart' ;
2
- import 'package:connectivity_wrapper/src/utils/constants.dart' ;
1
+ // Flutter imports:
3
2
import 'package:flutter/material.dart' ;
3
+
4
+ // Package imports:
4
5
import 'package:provider/provider.dart' ;
5
6
7
+ // Project imports:
8
+ import 'package:connectivity_wrapper/connectivity_wrapper.dart' ;
9
+ import 'package:connectivity_wrapper/src/utils/constants.dart' ;
10
+
6
11
enum PositionOnScreen {
7
12
TOP ,
8
13
BOTTOM ,
@@ -39,6 +44,9 @@ class ConnectivityScreenWrapper extends StatelessWidget {
39
44
/// Disable the user interaction with child widget
40
45
final Widget ? disableWidget;
41
46
47
+ /// How the text should be aligned horizontally.
48
+ final TextAlign ? textAlign;
49
+
42
50
const ConnectivityScreenWrapper ({
43
51
Key ? key,
44
52
this .child,
@@ -47,6 +55,7 @@ class ConnectivityScreenWrapper extends StatelessWidget {
47
55
this .message,
48
56
this .messageStyle,
49
57
this .height,
58
+ this .textAlign,
50
59
this .duration,
51
60
this .positionOnScreen = PositionOnScreen .BOTTOM ,
52
61
this .disableInteraction = false ,
@@ -64,7 +73,7 @@ class ConnectivityScreenWrapper extends StatelessWidget {
64
73
65
74
double _height = height ?? defaultHeight;
66
75
67
- final Widget offlineWidget = AnimatedPositioned (
76
+ final Widget _offlineWidget = AnimatedPositioned (
68
77
top: positionOnScreen.top (_height, isOffline),
69
78
bottom: positionOnScreen.bottom (_height, isOffline),
70
79
child: AnimatedContainer (
@@ -76,6 +85,7 @@ class ConnectivityScreenWrapper extends StatelessWidget {
76
85
child: Text (
77
86
message ?? disconnectedMessage,
78
87
style: messageStyle ?? defaultMessageStyle,
88
+ textAlign: textAlign,
79
89
),
80
90
),
81
91
duration: duration ?? Duration (milliseconds: 300 ),
@@ -87,10 +97,10 @@ class ConnectivityScreenWrapper extends StatelessWidget {
87
97
absorbing: (disableInteraction && isOffline),
88
98
child: Stack (
89
99
children: (< Widget ? > [
90
- child,
100
+ if (child != null ) child,
91
101
if (disableInteraction && isOffline)
92
102
if (disableWidget != null ) disableWidget,
93
- offlineWidget ,
103
+ _offlineWidget ,
94
104
]) as List <Widget >,
95
105
),
96
106
);
0 commit comments