flutter_application_1/lib/utils.dart

19 lines
536 B
Dart
Raw Normal View History

2024-05-06 17:28:10 +02:00
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';
}
}