1- import 'package:connectivity_wrapper/connectivity_wrapper.dart' ;
2- import 'package:connectivity_wrapper/src/utils/constants.dart' ;
1+ // Flutter imports:
32import 'package:flutter/material.dart' ;
3+
4+ // Package imports:
45import 'package:provider/provider.dart' ;
56
7+ // Project imports:
8+ import 'package:connectivity_wrapper/connectivity_wrapper.dart' ;
9+ import 'package:connectivity_wrapper/src/utils/constants.dart' ;
10+
611enum PositionOnScreen {
712 TOP ,
813 BOTTOM ,
@@ -39,6 +44,9 @@ class ConnectivityScreenWrapper extends StatelessWidget {
3944 /// Disable the user interaction with child widget
4045 final Widget ? disableWidget;
4146
47+ /// How the text should be aligned horizontally.
48+ final TextAlign ? textAlign;
49+
4250 const ConnectivityScreenWrapper ({
4351 Key ? key,
4452 this .child,
@@ -47,6 +55,7 @@ class ConnectivityScreenWrapper extends StatelessWidget {
4755 this .message,
4856 this .messageStyle,
4957 this .height,
58+ this .textAlign,
5059 this .duration,
5160 this .positionOnScreen = PositionOnScreen .BOTTOM ,
5261 this .disableInteraction = false ,
@@ -64,7 +73,7 @@ class ConnectivityScreenWrapper extends StatelessWidget {
6473
6574 double _height = height ?? defaultHeight;
6675
67- final Widget offlineWidget = AnimatedPositioned (
76+ final Widget _offlineWidget = AnimatedPositioned (
6877 top: positionOnScreen.top (_height, isOffline),
6978 bottom: positionOnScreen.bottom (_height, isOffline),
7079 child: AnimatedContainer (
@@ -76,6 +85,7 @@ class ConnectivityScreenWrapper extends StatelessWidget {
7685 child: Text (
7786 message ?? disconnectedMessage,
7887 style: messageStyle ?? defaultMessageStyle,
88+ textAlign: textAlign,
7989 ),
8090 ),
8191 duration: duration ?? Duration (milliseconds: 300 ),
@@ -87,10 +97,10 @@ class ConnectivityScreenWrapper extends StatelessWidget {
8797 absorbing: (disableInteraction && isOffline),
8898 child: Stack (
8999 children: (< Widget ? > [
90- child,
100+ if (child != null ) child,
91101 if (disableInteraction && isOffline)
92102 if (disableWidget != null ) disableWidget,
93- offlineWidget ,
103+ _offlineWidget ,
94104 ]) as List <Widget >,
95105 ),
96106 );
0 commit comments