null safety
This commit is contained in:
@@ -7,18 +7,18 @@ import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class InputTime extends StatelessWidget {
|
||||
final String labelTextKey;
|
||||
final IconData iconData;
|
||||
final TextEditingController controller;
|
||||
final FormFieldValidator<String> validator;
|
||||
final String? labelTextKey;
|
||||
final IconData? iconData;
|
||||
final TextEditingController? controller;
|
||||
final FormFieldValidator<String>? validator;
|
||||
final int maxLines;
|
||||
final bool withBorder;
|
||||
final Color borderColor;
|
||||
final TextInputType textInputType;
|
||||
final Color? borderColor;
|
||||
final TextInputType? textInputType;
|
||||
final bool autoFocus;
|
||||
|
||||
const InputTime(
|
||||
{Key key,
|
||||
{Key? key,
|
||||
this.labelTextKey,
|
||||
this.iconData,
|
||||
this.controller,
|
||||
@@ -45,14 +45,14 @@ class InputTime extends StatelessWidget {
|
||||
try {
|
||||
final format = DateFormat.jm(); //"6:00 AM"
|
||||
initialDate =
|
||||
TimeOfDay.fromDateTime(format.parse(controller.text));
|
||||
TimeOfDay.fromDateTime(format.parse(controller!.text));
|
||||
// var values = controller.text.split(":");
|
||||
// initialDate = TimeOfDay(
|
||||
// hour: int.parse(values[0]), minute: int.parse(values[1]));
|
||||
} catch (e) {} // ignore error
|
||||
}
|
||||
|
||||
TimeOfDay t = await showTimePicker(
|
||||
TimeOfDay? t = await showTimePicker(
|
||||
initialTime: initialDate,
|
||||
context: context,
|
||||
);
|
||||
@@ -61,7 +61,7 @@ class InputTime extends StatelessWidget {
|
||||
final now = new DateTime.now();
|
||||
final dt =
|
||||
DateTime(now.year, now.month, now.day, t.hour, t.minute);
|
||||
controller.text = "${format.format(dt)}";
|
||||
controller!.text = "${format.format(dt)}";
|
||||
}
|
||||
},
|
||||
controller: controller,
|
||||
@@ -77,7 +77,7 @@ class InputTime 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