Skip to content

Commit

Permalink
build: snackbar for showing message
Browse files Browse the repository at this point in the history
  • Loading branch information
reyyuuki committed Dec 1, 2024
1 parent e4ea768 commit b604abb
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions lib/components/Common/snackbar.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import 'dart:io';

import 'package:flutter/material.dart';

void showSnackBar(String message, BuildContext context) {
final snackBar = SnackBar(
behavior: SnackBarBehavior.floating,
width: Platform.isAndroid || Platform.isIOS ? MediaQuery.of(context).size.width : 500,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
backgroundColor: Theme.of(context).colorScheme.surfaceContainer,
duration: const Duration(seconds: 2),
content: Text(
message,
style: TextStyle(
fontSize: 16,
color: Theme.of(context).colorScheme.inverseSurface,
),
textAlign: TextAlign.center, // Center the text
),
);

// Show the SnackBar
ScaffoldMessenger.of(context).showSnackBar(snackBar);
}

0 comments on commit b604abb

Please sign in to comment.