You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
HMG_Patient_App_New/lib/extensions/context_extensions.dart

47 lines
1.5 KiB
Dart

import 'package:flutter/material.dart';
extension ContextUtils on BuildContext {
double get screenHeight => MediaQuery.of(this).size.height;
double get screenWidth => MediaQuery.of(this).size.width;
EdgeInsets get padding => MediaQuery.of(this).padding;
bool get safeInsets => padding.top > 0 || padding.bottom > 0 || padding.left > 0 || padding.right > 0;
ThemeData get theme => Theme.of(this);
TextTheme get textTheme => theme.textTheme;
// TextStyle get headline1 => textTheme.headline1!;
// TextStyle get headline2 => textTheme.headline2!;
// TextStyle get headline3 => textTheme.headline3!;
// TextStyle get headline4 => textTheme.headline4!;
// TextStyle get headline5 => textTheme.headline5!;
// TextStyle get headline6 => textTheme.headline6!;
// TextStyle get bodyText1 => textTheme.bodyText1!;
// TextStyle get bodyText2 => textTheme.bodyText2!;
}
extension ShowBottomSheet on BuildContext {
Future<T?> showBottomSheet<T>({
isScrollControlled = true,
isDismissible = false,
required Widget child,
Color? backgroundColor,
enableDra = false,
useSafeArea = false,
BoxConstraints? constraints,
}) {
return showModalBottomSheet<T>(
context: this,
constraints: constraints,
isScrollControlled: isScrollControlled,
isDismissible: isDismissible,
enableDrag: enableDra,
useSafeArea: useSafeArea,
backgroundColor: backgroundColor ?? Colors.transparent,
builder: (_) => child,
);
}
}