flutter_application_1/lib/utils.dart

19 lines
536 B
Dart

import 'package:flutter/material.dart';
void roundToInteger(TextEditingController controller) {
double? parsedValue = double.tryParse(controller.text.replaceAll(',', '.'));
if (parsedValue != null) {
String roundedValue = parsedValue.toStringAsFixed(0);
controller.text = roundedValue;
}
}
bool isNumeric(String value) {
return double.tryParse(value.replaceAll(',', '.')) != null;
}
void restoreDefaultValuesIfEmpty(TextEditingController controller) {
if (controller.text.isEmpty) {
controller.text = '0';
}
}