FoodBucketSchedule.dart 3.32 KB
Newer Older
ayodyabanuka's avatar
ayodyabanuka committed
1
import 'package:flutter/material.dart';
2 3 4
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
import 'package:ifarm/AB/Utils/Colors.dart';
import 'package:intl/intl.dart';
ayodyabanuka's avatar
ayodyabanuka committed
5 6 7 8 9 10 11 12

class FoodBucketSchedule extends StatefulWidget {
  FoodBucketSchedule({Key key}) : super(key: key);

  @override
  State<FoodBucketSchedule> createState() => _FoodBucketScheduleState();
}

13 14
TextEditingController dateandtime = TextEditingController();

ayodyabanuka's avatar
ayodyabanuka committed
15 16 17
class _FoodBucketScheduleState extends State<FoodBucketSchedule> {
  @override
  Widget build(BuildContext context) {
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
    return Padding(
      padding: const EdgeInsets.all(25),
      child: Column(
        children: [
          const Center(
              child: Text(
            "Schedule your Food dispense Here!",
            style: TextStyle(
                color: Colors.white, fontWeight: FontWeight.bold, fontSize: 20),
          )),
          const SizedBox(
            height: 40,
          ),
          Row(
            children: const [
              Text(
                "Pick Date and Time here",
                style: TextStyle(
                    color: Colors.white,
                    fontWeight: FontWeight.bold,
                    fontSize: 15),
              ),
            ],
          ),
          const SizedBox(
            height: 10,
          ),
          Container(
            decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(15), color: cardColor),
            child: Padding(
              padding: const EdgeInsets.symmetric(horizontal: 20),
              child: TextFormField(
                readOnly: true,
                onTap: () {
                  DatePicker.showDateTimePicker(context,
                      showTitleActions: true,
                      minTime: DateTime(2022, 11, 5),
                      maxTime: DateTime(2019, 6, 7), onChanged: (date) {
                    print(
                        'change ${DateFormat('yyyy-MM-dd kk:mm').format(date)}');
                  }, onConfirm: (date) {
                    print(
                        'confirm ${DateFormat('yyyy-MM-dd kk:mm').format(date)}');
                    setState(() {
                      dateandtime.text =
                          DateFormat('yyyy-MM-dd – kk:mm').format(date);
                    });
                  }, currentTime: DateTime.now(), locale: LocaleType.en);
                },
                controller: dateandtime,
                style:
                    const TextStyle(color: Color.fromARGB(255, 255, 255, 255)),
                cursorColor: const Color.fromARGB(255, 0, 0, 0),
                decoration: const InputDecoration(
                    hintText: "Pick Date and Time",
                    border: InputBorder.none,
                    hintStyle:
                        TextStyle(color: Color.fromARGB(255, 255, 255, 255))),
              ),
            ),
          ),
          Expanded(
              child: ListView.builder(
                  itemCount: 2,
                  itemBuilder: (context, index) {
                    return Container(
                      padding: const EdgeInsets.all(15),
                      decoration: BoxDecoration(
                          color: cardColor,
                          borderRadius: BorderRadius.circular(15)),
                    );
                  }))
        ],
      ),
    );
ayodyabanuka's avatar
ayodyabanuka committed
94 95
  }
}