Skip to content

Commit dc353e2

Browse files
authored
Merge pull request #2022 from jonataslaw/4.5.1
bump to 4.5.1
2 parents 4ef7589 + bc6a9e4 commit dc353e2

File tree

4 files changed

+40
-6
lines changed

4 files changed

+40
-6
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## [4.5.1] - Big Update
2+
Fix Snackbar when it have action and icon the same time
3+
14
## [4.5.0] - Big Update
25
To have a context-free, page-agnostic snackbar, we used OverlayRoute to display a partial route.
36
However this had several problems:

lib/get_navigation/src/snackbar/snackbar.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ You need to either use message[String], or messageText[Widget] or define a userI
560560
mainAxisSize: MainAxisSize.max,
561561
children: [
562562
_buildLeftBarIndicator(),
563-
if (_rowStyle == RowStyle.icon)
563+
if (_rowStyle == RowStyle.icon || _rowStyle == RowStyle.all)
564564
ConstrainedBox(
565565
constraints:
566566
BoxConstraints.tightFor(width: 42.0 + iconPadding),
@@ -608,7 +608,7 @@ You need to either use message[String], or messageText[Widget] or define a userI
608608
],
609609
),
610610
),
611-
if (_rowStyle == RowStyle.action)
611+
if (_rowStyle == RowStyle.action || _rowStyle == RowStyle.all)
612612
Padding(
613613
padding: EdgeInsets.only(right: buttonPadding),
614614
child: widget.mainButton,

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: get
22
description: Open screens/snackbars/dialogs without context, manage states and inject dependencies easily with GetX.
3-
version: 4.5.0
3+
version: 4.5.1
44
homepage: https://github.com/jonataslaw/getx
55

66
environment:

test/navigation/snackbar_test.dart

+34-3
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,6 @@ void main() {
115115
onTap: () {
116116
getBar = GetSnackBar(
117117
message: 'bar1',
118-
icon: Icon(Icons.alarm),
119-
mainButton:
120-
TextButton(onPressed: () {}, child: Text('button')),
121118
duration: const Duration(seconds: 2),
122119
isDismissible: true,
123120
dismissDirection: dismissDirection,
@@ -212,4 +209,38 @@ void main() {
212209
await tester.pump(const Duration(milliseconds: 3000));
213210
await getBarController.close(withAnimations: false);
214211
});
212+
213+
testWidgets("Get test actions and icon", (tester) async {
214+
final icon = Icon(Icons.alarm);
215+
final action = TextButton(onPressed: () {}, child: Text('button'));
216+
217+
late final GetSnackBar getBar;
218+
219+
await tester.pumpWidget(GetMaterialApp(home: Scaffold()));
220+
221+
expect(Get.isSnackbarOpen, false);
222+
expect(find.text('bar1'), findsNothing);
223+
224+
getBar = GetSnackBar(
225+
message: 'bar1',
226+
icon: icon,
227+
mainButton: action,
228+
leftBarIndicatorColor: Colors.yellow,
229+
showProgressIndicator: true,
230+
// maxWidth: 100,
231+
borderColor: Colors.red,
232+
duration: const Duration(seconds: 1),
233+
isDismissible: false,
234+
);
235+
Get.showSnackbar(getBar);
236+
237+
expect(Get.isSnackbarOpen, true);
238+
await tester.pump(const Duration(milliseconds: 500));
239+
expect(find.byWidget(getBar), findsOneWidget);
240+
expect(find.byWidget(icon), findsOneWidget);
241+
expect(find.byWidget(action), findsOneWidget);
242+
await tester.pump(const Duration(milliseconds: 500));
243+
244+
expect(Get.isSnackbarOpen, false);
245+
});
215246
}

0 commit comments

Comments
 (0)