add driver code
add driver code
dart';
import 'package:intl/intl.dart';
import
'package:list_of_projects/yaantrac/new_module/Screens/view_TripDetailsScreen.dart';
import '../Widgets/Custom_TextField.dart';
import '../Widgets/dateTimeComponent.dart';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Add New Trip"),
leading: IconButton(
icon: Icon(Icons.arrow_back),
onPressed: () {
},
),
backgroundColor: Colors.blue,
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: SingleChildScrollView(
child: Form(
key: formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Center(
child: Text(
"Driver Details",
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
),
const SizedBox(height: 10),
DateComponent(
Controller:startTimeController ,
placholder: "Select Date and Time",
name: "dateTime",
firtstDate: DateTime.now(),
//dateFormat: DateFormat('dd/MM/yyyy HH:mm'), // Custom format
for DD/MM/YYYY HH:mm
// initialDate: DateTime.now(),
labelName: "Start Time",
onchange: (selectedDate) {
print(selectedDate); // Do something with the selected date
},
),
AutoCustomTextField(
name: "select_vehicle",
placeHolder: "Select Vehicle",
labelName: "Select Vehicle",
suffixIcon: const Icon(Icons.arrow_drop_down),
textEditingController: selectVehicleController,
suffixClick: () {
print('object');
},
validators: [
(value) {
if (value == null || value.isEmpty) {
return "Vehicle is required";
}
return null;
},
],
),
AutoCustomTextField(
name: "source_address",
placeHolder: "Search Location",
labelName: "Source Address",
suffixIcon: const Icon(Icons.search),
textEditingController: sourceAddressController,
onTap: () {
},
validators: [
(value) {
if (value == null || value.isEmpty) {
return "Source Address is required";
}
return null;
},
],
),
AutoCustomTextField(
name: "driver_id",
placeHolder: "Driver ID",
labelName: "Driver ID",
textEditingController: driverIdController,
validators: [
(value) {
if (value == null || value.isEmpty) {
return "Driver ID is required";
}
return null;
},
],
),
if (result != null ) {
PopUpFunction(result);
print(result.toString());
print("result.toString()");
print(result.toString().length);
}
}
},
child: const Text("Submit"),
),
),
],
),
),
),
),
);
}
PopUpFunction(result)
{
startTimeController.text = result["start_time"] ?? "";
selectVehicleController.text =
result["select_vehicle"] ?? "";
sourceAddressController.text =
result["source_address"] ?? "";
driverIdController.text = result["driver_id"] ?? "";
}
}