Added working edit transaction
This commit is contained in:
+58
-3
@@ -1,5 +1,8 @@
|
||||
import 'dart:ui';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:helpers/helpers/print.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
String formatDate(DateTime time) {
|
||||
@@ -8,10 +11,62 @@ String formatDate(DateTime time) {
|
||||
|
||||
DateTime dateFromJson(int value) => DateTime.fromMillisecondsSinceEpoch(value);
|
||||
|
||||
int dateToJson(DateTime? value) =>
|
||||
value == null ? 0 : value.millisecondsSinceEpoch;
|
||||
int? dateToJson(DateTime? value) => value?.millisecondsSinceEpoch;
|
||||
|
||||
bool boolFromJson(int value) => value == 1;
|
||||
|
||||
int boolToJson(bool hide) => hide ? 1 : 0;
|
||||
|
||||
String colorToJson(Color color) =>
|
||||
color.toString().split('(0x')[1].split(')')[0];
|
||||
|
||||
Color colorFromJson(String hex) => Color(int.parse(hex, radix: 16));
|
||||
|
||||
String? optionalColorToJson(Color? optionalColor) => optionalColor == null
|
||||
? null
|
||||
: optionalColor.toString().split('(0x')[1].split(')')[0];
|
||||
|
||||
Color? optionalColorFromJson(String? hex) =>
|
||||
hex == null ? null : Color(int.parse(hex, radix: 16));
|
||||
|
||||
Brightness getBrightness(Color color) =>
|
||||
ThemeData.estimateBrightnessForColor(color);
|
||||
|
||||
List<Color> generateColorList() {
|
||||
List<Color> colors = [];
|
||||
for (int i = 100; i <= 255; i += 30) {
|
||||
// Red value variations
|
||||
for (int j = 100; j <= 255; j += 30) {
|
||||
// Green value variations
|
||||
for (int k = 100; k <= 255; k += 30) {
|
||||
// Blue value variations
|
||||
final alpha = Random().nextInt(256) + 50 % 255;
|
||||
colors.add(Color.fromARGB(alpha, i, j, k));
|
||||
}
|
||||
}
|
||||
}
|
||||
colors.shuffle();
|
||||
return colors;
|
||||
}
|
||||
|
||||
extension MonetaryExtension on double {
|
||||
String currency() {
|
||||
final numStr = toStringAsFixed(2);
|
||||
final pieces = numStr.split(".");
|
||||
if (pieces.length == 1) {
|
||||
return "\$${pieces.first}.00";
|
||||
} else {
|
||||
if (pieces.length > 2) {
|
||||
printBlue(pieces);
|
||||
}
|
||||
return '\$${pieces[0]}.${pieces[1].padRight(2, "0")}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setDevicePortraitOrientation() {
|
||||
SystemChrome.setPreferredOrientations([
|
||||
DeviceOrientation.portraitUp,
|
||||
DeviceOrientation.portraitDown,
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user