Skip to content

Commit 8fdc612

Browse files
committed
code optimised in gf-alert
1 parent 15debf4 commit 8fdc612

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

lib/components/alert/gf_alert.dart

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,15 @@ class GFAlert extends StatefulWidget {
1616
this.contentChild,
1717
this.title,
1818
this.bottombar,
19-
this.animationDuration = const Duration(milliseconds: 300),
20-
this.textStyle = const TextStyle(color: Colors.black87),
19+
this.contentTextStyle = const TextStyle(color: Colors.black87),
2120
this.titleTextStyle = const TextStyle(
2221
color: Colors.black87, fontSize: 17, fontWeight: FontWeight.w500)})
2322
: super(key: key);
2423

25-
/// child of type [Widget]is alternative to text key. text will get priority over child
24+
/// child of type [Widget]is alternative to title key. title will get priority over child
2625
final Widget child;
2726

28-
/// title of type [String] used to descripe the title of the [GFAlert]
27+
/// title of type [String] used to describe the title of the [GFAlert]
2928
final String title;
3029

3130
/// child of type [Widget]is alternative to title key. title will get priority over contentchild
@@ -34,24 +33,22 @@ class GFAlert extends StatefulWidget {
3433
/// title of type [String] used to describe the content of the [GFAlert]
3534
final String content;
3635

36+
///type of [TextStyle] to change the style of the title not for the child
3737
final TextStyle titleTextStyle;
3838

3939
///pass color of type [Color] or [GFColor] for background of [GFAlert]
4040
final dynamic backgroundColor;
4141

42-
/// textStyle of type [textStyle] will be applicable to text only and not for the child
43-
final TextStyle textStyle;
42+
///type of [TextStyle] to change the style of the content not for the contentchild
43+
final TextStyle contentTextStyle;
4444

4545
/// width of type [double] used to control the width of the [GFAlert]
4646
final double width;
4747

4848
///type of [GFAlertType] which takes the type ie, basic, rounded and fullWidth for the [GFAlert]
4949
final GFAlertType type;
5050

51-
///type of [Duration] which takes the duration of the fade in animation
52-
final Duration animationDuration;
53-
54-
/// type of [Alignment] used to align the text inside the toast
51+
/// type of [Alignment] used to align the text inside the [GFAlert]
5552
final Alignment alignment;
5653

5754
///type of [Widget] used for the buttons ie, OK, Cancel for the action in [GFAlert]
@@ -113,9 +110,13 @@ class _GFAlertState extends State<GFAlert> with TickerProviderStateMixin {
113110
child: Column(
114111
crossAxisAlignment: CrossAxisAlignment.start,
115112
children: <Widget>[
116-
widget.title != null
117-
? Text(widget.title, style: widget.titleTextStyle)
118-
: (widget.child ?? Container()),
113+
Align(
114+
alignment: widget.alignment!=null? widget.alignment:Alignment.topLeft,
115+
child: widget.title != null
116+
? Text(widget.title, style: widget.titleTextStyle)
117+
: (widget.child ?? Container()),
118+
),
119+
119120
SizedBox(
120121
height: 10,
121122
),
@@ -124,7 +125,7 @@ class _GFAlertState extends State<GFAlert> with TickerProviderStateMixin {
124125
? widget.alignment
125126
: Alignment.topLeft,
126127
child: widget.content != null
127-
? Text(widget.content, style: widget.textStyle)
128+
? Text(widget.content, style: widget.contentTextStyle)
128129
: (widget.contentChild ?? Container()),
129130
),
130131
SizedBox(

0 commit comments

Comments
 (0)