cleanup code
This commit is contained in:
@@ -1,14 +1,13 @@
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/localization/app_translations.dart';
|
||||
import 'package:fcs/pages/main/model/language_model.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class InputDate extends StatelessWidget {
|
||||
final String labelTextKey;
|
||||
final IconData iconData;
|
||||
final String? labelTextKey;
|
||||
final IconData? iconData;
|
||||
final TextEditingController controller;
|
||||
final FormFieldValidator<String>? validator;
|
||||
final int maxLines;
|
||||
@@ -44,7 +43,7 @@ class InputDate extends StatelessWidget {
|
||||
var dateFormatter = new DateFormat(dateFormatString);
|
||||
FocusScope.of(context).unfocus();
|
||||
var initialDate = DateTime.now();
|
||||
if (controller != null) {
|
||||
if (controller.text != "") {
|
||||
try {
|
||||
initialDate = dateFormatter.parse(controller.text);
|
||||
} catch (e) {} // ignore error
|
||||
@@ -55,7 +54,7 @@ class InputDate extends StatelessWidget {
|
||||
lastDate: DateTime(2025),
|
||||
initialDate: initialDate,
|
||||
);
|
||||
if (d != null && controller != null) {
|
||||
if (d != null && controller.text != "") {
|
||||
controller.text = dateFormatter.format(d);
|
||||
}
|
||||
},
|
||||
@@ -72,7 +71,7 @@ class InputDate extends StatelessWidget {
|
||||
),
|
||||
labelText: labelTextKey == null
|
||||
? null
|
||||
: AppTranslations.of(context)!.text(labelTextKey),
|
||||
: AppTranslations.of(context)!.text(labelTextKey!),
|
||||
labelStyle: languageModel.isEng
|
||||
? newLabelStyle(color: Colors.black54, fontSize: 20)
|
||||
: newLabelStyleMM(color: Colors.black54, fontSize: 20),
|
||||
|
||||
Reference in New Issue
Block a user