Initial commit
This commit is contained in:
12
lib/core/extension/build_context_extension.dart
Normal file
12
lib/core/extension/build_context_extension.dart
Normal file
@@ -0,0 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../theme/colors/app_colors.dart';
|
||||
import '../theme/theme_text_style.dart';
|
||||
|
||||
extension BuildContextExt on BuildContext {
|
||||
ThemeTextStyles get text => Theme.of(this).extension<ThemeTextStyles>()!;
|
||||
|
||||
AppThemeColors get color => Theme.of(this).extension<AppThemeColors>()!;
|
||||
|
||||
bool get isDarkMode => Theme.of(this).brightness == Brightness.dark;
|
||||
}
|
||||
11
lib/core/extension/color_extension.dart
Normal file
11
lib/core/extension/color_extension.dart
Normal file
@@ -0,0 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
extension HexColor on Color {
|
||||
/// String is in the format "aabbcc" or "ffaabbcc" with an optional leading "#".
|
||||
static Color fromHex(String hexString) {
|
||||
final buffer = StringBuffer();
|
||||
if (hexString.length == 6 || hexString.length == 7) buffer.write('ff');
|
||||
buffer.write(hexString.replaceFirst('#', ''));
|
||||
return Color(int.parse(buffer.toString(), radix: 16));
|
||||
}
|
||||
}
|
||||
13
lib/core/extension/extension.dart
Normal file
13
lib/core/extension/extension.dart
Normal file
@@ -0,0 +1,13 @@
|
||||
extension SliverCountExtension on int {
|
||||
int get doubleTheListCount => (this * 2) - 1;
|
||||
|
||||
int get exactIndex => (this ~/ 2);
|
||||
|
||||
int get lastIndex => (this * 2) - 2;
|
||||
}
|
||||
|
||||
extension VersionParsing on String {
|
||||
int toVersion() {
|
||||
return int.tryParse(replaceAll(".", "")) ?? 0;
|
||||
}
|
||||
}
|
||||
12
lib/core/extension/size_extentione.dart
Normal file
12
lib/core/extension/size_extentione.dart
Normal file
@@ -0,0 +1,12 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import '../../router/app_routes.dart';
|
||||
|
||||
extension ScreenSize on double {
|
||||
double get w {
|
||||
return this / 375 * MediaQuery.sizeOf(rootNavigatorKey.currentContext!).width;
|
||||
}
|
||||
|
||||
double get h {
|
||||
return this / 812 * MediaQuery.sizeOf(rootNavigatorKey.currentContext!).height;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user