Skip to content

Commit

Permalink
fix: fix warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
JackJonson committed Aug 27, 2023
1 parent ce08071 commit 60373b4
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 43 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Beautify toast with a series of animations and make toast more beautiful.
## Null safety
```yaml
dependencies:
flutter_styled_toast: ^2.1.3
flutter_styled_toast: ^2.2.1
```

## Getting Started
Expand Down
3 changes: 2 additions & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,8 @@ class _MyHomePageState extends State<MyHomePage>
setState(() {
dismissRemind = '';
});
showToast('This is normal toast with onDismissed',
showToast(
'This is normal toast with onDismissed',
context: context,
animation: StyledToastAnimation.fade,
duration: Duration(seconds: 2),
Expand Down
4 changes: 2 additions & 2 deletions lib/src/custom_size_transition.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ class CustomSizeTransition extends AnimatedWidget {
@override
Widget build(BuildContext context) {
final alignmentDirect = axis == Axis.vertical
? AlignmentDirectional(-1.0, axisAlignment)
: AlignmentDirectional(axisAlignment, -1.0);
? AlignmentDirectional(-1.0, axisAlignment)
: AlignmentDirectional(axisAlignment, -1.0);
return ClipRect(
child: Align(
alignment: alignment ?? alignmentDirect,
Expand Down
54 changes: 26 additions & 28 deletions lib/src/styled_toast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,19 @@ ToastFuture showToast(

position ??= toastTheme?.toastPositions ?? StyledToastPosition.bottom;

textStyle ??= toastTheme?.textStyle
?? const TextStyle(fontSize: 16.0, color: Colors.white);
textStyle ??= toastTheme?.textStyle ??
const TextStyle(fontSize: 16.0, color: Colors.white);

textPadding ??= toastTheme?.textPadding
?? const EdgeInsets.symmetric(horizontal: 17.0, vertical: 10.0);
textPadding ??= toastTheme?.textPadding ??
const EdgeInsets.symmetric(horizontal: 17.0, vertical: 10.0);

backgroundColor ??= toastTheme?.backgroundColor ?? const Color(0x99000000);
borderRadius ??= toastTheme?.borderRadius ?? BorderRadius.circular(5.0);

shapeBorder ??= toastTheme?.shapeBorder ?? RoundedRectangleBorder(
borderRadius: borderRadius,
);
shapeBorder ??= toastTheme?.shapeBorder ??
RoundedRectangleBorder(
borderRadius: borderRadius,
);

textDirection ??= toastTheme?.textDirection ?? TextDirection.ltr;

Expand Down Expand Up @@ -402,11 +403,9 @@ class StyledToast extends StatefulWidget {
}
}

class _StyledToastState extends State<StyledToast>
{
class _StyledToastState extends State<StyledToast> {
@override
Widget build(final BuildContext context)
{
Widget build(final BuildContext context) {
final overlay = Overlay(
initialEntries: <OverlayEntry>[
OverlayEntry(builder: (context) {
Expand All @@ -427,23 +426,23 @@ class _StyledToastState extends State<StyledToast>
),
);

final textStyle = widget.textStyle ?? const TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.normal,
color: Colors.white,
);
final textStyle = widget.textStyle ??
const TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.normal,
color: Colors.white,
);

final backgroundColor = widget.backgroundColor
?? const Color(0x99000000);
final backgroundColor = widget.backgroundColor ?? const Color(0x99000000);

final borderRadius = widget.borderRadius
?? BorderRadius.circular(5.0);
final borderRadius = widget.borderRadius ?? BorderRadius.circular(5.0);

final textAlign = widget.textAlign ?? TextAlign.center;
final textPadding = widget.textPadding ?? const EdgeInsets.symmetric(
horizontal: 17.0,
vertical: 8.0,
);
final textPadding = widget.textPadding ??
const EdgeInsets.symmetric(
horizontal: 17.0,
vertical: 8.0,
);

return Localizations(
delegates: const [
Expand Down Expand Up @@ -559,7 +558,7 @@ class _StyledToastWidget extends StatefulWidget {
this.animationBuilder,
this.reverseAnimBuilder,
this.onInitState,
}) : assert(animDuration * 2 <= duration || duration == Duration.zero);
}) : assert(animDuration * 2 <= duration || duration == Duration.zero);

@override
State<StatefulWidget> createState() {
Expand Down Expand Up @@ -1497,9 +1496,8 @@ class StyledToastWidgetState extends State<_StyledToastWidget>
}
_toastTimer?.cancel();
try {
if (widget.animation != widget.reverseAnimation
|| widget.reverseAnimBuilder != null
) {
if (widget.animation != widget.reverseAnimation ||
widget.reverseAnimBuilder != null) {
await _reverseAnimController.forward().orCancel;
} else {
await _animationController.reverse().orCancel;
Expand Down
1 change: 0 additions & 1 deletion lib/src/styled_toast_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import 'styled_toast_enum.dart';
///
/// If you have specified a custom content widget, [ToastTheme] will not be working.
class StyledToastTheme extends InheritedWidget {

/// Text align.
final TextAlign? textAlign;

Expand Down
2 changes: 1 addition & 1 deletion test/custom_animation_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void main() {
}

class CustomAnimationTestAppWidget extends StatefulWidget {
const CustomAnimationTestAppWidget({ super.key });
const CustomAnimationTestAppWidget({super.key});

@override
CustomAnimationTestAppWidgetState createState() =>
Expand Down
2 changes: 1 addition & 1 deletion test/custom_size_transition_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void main() {
class TestWidget extends StatefulWidget {
final Function(AnimationStatus value) valueCallback;

const TestWidget(this.valueCallback, { super.key });
const TestWidget(this.valueCallback, {super.key});

@override
State<TestWidget> createState() => _TestWidgetState();
Expand Down
8 changes: 4 additions & 4 deletions test/styled_toast_manage_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ void main() {
final testAppWidget = TestAppWidget(overlayEntry: entry, key: key);
await tester.pumpWidget(testAppWidget);

ToastFuture toastFuture = ToastFuture.create(const Duration(seconds: 4), entry,
() {}, GlobalKey(debugLabel: 'toast future global key'));
ToastFuture toastFuture = ToastFuture.create(const Duration(seconds: 4),
entry, () {}, GlobalKey(debugLabel: 'toast future global key'));
final toastManager = ToastManager();
toastManager.addFuture(toastFuture);

Expand Down Expand Up @@ -46,8 +46,8 @@ void main() {
final testAppWidget = TestAppWidget(overlayEntry: entry, key: key);
await tester.pumpWidget(testAppWidget);

ToastFuture toastFuture = ToastFuture.create(const Duration(seconds: 4), entry,
() {}, GlobalKey(debugLabel: 'toast future global key'));
ToastFuture toastFuture = ToastFuture.create(const Duration(seconds: 4),
entry, () {}, GlobalKey(debugLabel: 'toast future global key'));

key.currentState?.insertEntry();
toastFuture.dismiss(showAnim: true);
Expand Down
7 changes: 4 additions & 3 deletions test/styled_toast_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ void main() {
testWidgets('Create StyleToastWidget', (WidgetTester tester) async {
const textStyle = TextStyle(fontSize: 16.0, color: Colors.white);
const backgroundColor = Color(0x99000000);
const borderRadius = BorderRadius.all(Radius.circular(5.0));
const textPadding = EdgeInsets.symmetric(horizontal: 17.0, vertical: 10.0);
const borderRadius = BorderRadius.all(Radius.circular(5.0));
const textPadding =
EdgeInsets.symmetric(horizontal: 17.0, vertical: 10.0);
const toastAnimation = StyledToastAnimation.size;
const reverseAnimation = StyledToastAnimation.size;
const startOffset = Offset(0.0, -1.0);
Expand Down Expand Up @@ -205,7 +206,7 @@ void main() {
class TestAppWidget extends StatefulWidget {
final OverlayEntry? overlayEntry;

const TestAppWidget({ super.key, this.overlayEntry });
const TestAppWidget({super.key, this.overlayEntry});

@override
TestAppWidgetState createState() => TestAppWidgetState();
Expand Down
3 changes: 2 additions & 1 deletion test/styled_toast_theme_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ void main() {
const textStyle = TextStyle(fontSize: 16.0, color: Colors.white);
const backgroundColor = Color(0x99000000);
final borderRadius = BorderRadius.circular(5.0);
const textPadding = EdgeInsets.symmetric(horizontal: 17.0, vertical: 10.0);
const textPadding =
EdgeInsets.symmetric(horizontal: 17.0, vertical: 10.0);
const toastAnimation = StyledToastAnimation.size;
const reverseAnimation = StyledToastAnimation.size;
const startOffset = Offset(0.0, -1.0);
Expand Down

0 comments on commit 60373b4

Please sign in to comment.