36 lines
1.1 KiB
Dart
36 lines
1.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:trainhub_flutter/core/theme/app_colors.dart';
|
|
|
|
extension BuildContextExtensions on BuildContext {
|
|
ThemeData get theme => Theme.of(this);
|
|
ColorScheme get colors => theme.colorScheme;
|
|
TextTheme get textTheme => theme.textTheme;
|
|
MediaQueryData get mediaQuery => MediaQuery.of(this);
|
|
double get screenWidth => mediaQuery.size.width;
|
|
double get screenHeight => mediaQuery.size.height;
|
|
|
|
void showSnackBar(String message, {bool isError = false}) {
|
|
ScaffoldMessenger.of(this).showSnackBar(
|
|
SnackBar(
|
|
content: Text(message),
|
|
backgroundColor:
|
|
isError ? AppColors.destructive : AppColors.surfaceContainer,
|
|
),
|
|
);
|
|
}
|
|
|
|
void showSuccessSnackBar(String message) {
|
|
ScaffoldMessenger.of(this).showSnackBar(
|
|
SnackBar(
|
|
content: Row(
|
|
children: [
|
|
const Icon(Icons.check_circle, color: AppColors.success, size: 18),
|
|
const SizedBox(width: 8),
|
|
Expanded(child: Text(message)),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|