mirror of
https://github.com/wger-project/flutter.git
synced 2026-11-29 01:18:35 +01:00
The translations are not stored in a synthetic package anymore, but the files are just copied to a specific folder so it can be more easily imported Also, flutter_barcode_scanner was replaced by simple_barcode_scanner since the first hasn't been updated in 3 years and was already causing problems for some time
37 lines
987 B
Dart
37 lines
987 B
Dart
import 'package:flutter/material.dart';
|
|
import 'package:wger/l10n/generated/app_localizations.dart';
|
|
|
|
/// The amount of characters an exercise description needs to have
|
|
const MIN_CHARS_DESCRIPTION = 40;
|
|
|
|
/// The amount of characters an exercise name needs to have
|
|
const MIN_CHARS_NAME = 5;
|
|
const MAX_CHARS_NAME = 40;
|
|
|
|
String? validateName(String? name, BuildContext context) {
|
|
if (name!.isEmpty) {
|
|
return AppLocalizations.of(context).enterValue;
|
|
}
|
|
|
|
if (name.length < MIN_CHARS_NAME || name.length > MAX_CHARS_NAME) {
|
|
return AppLocalizations.of(context).enterCharacters(
|
|
MIN_CHARS_NAME.toString(),
|
|
MAX_CHARS_NAME.toString(),
|
|
);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
String? validateDescription(String? name, BuildContext context) {
|
|
if (name!.isEmpty) {
|
|
return AppLocalizations.of(context).enterValue;
|
|
}
|
|
|
|
if (name.length < MIN_CHARS_DESCRIPTION) {
|
|
return AppLocalizations.of(context).enterMinCharacters(MIN_CHARS_DESCRIPTION.toString());
|
|
}
|
|
|
|
return null;
|
|
}
|