fix datepicker
This commit is contained in:
parent
c12a957099
commit
ac566053b1
@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:ffi';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
@ -54,10 +56,8 @@ class _EditEventState extends State<EditEvent>
|
|||||||
TextEditingController endTimepicker = TextEditingController();
|
TextEditingController endTimepicker = TextEditingController();
|
||||||
final _stringTagController = StringTagController();
|
final _stringTagController = StringTagController();
|
||||||
|
|
||||||
var dateS = null;
|
DateTime startDate = DateTime.now();
|
||||||
var timeS = null;
|
DateTime endDate = DateTime.now();
|
||||||
var dateE = null;
|
|
||||||
var timeE = null;
|
|
||||||
List<Map<String, dynamic>> suggestions = [];
|
List<Map<String, dynamic>> suggestions = [];
|
||||||
String geographicalZone = "";
|
String geographicalZone = "";
|
||||||
String imgUrl = "";
|
String imgUrl = "";
|
||||||
@ -86,10 +86,10 @@ class _EditEventState extends State<EditEvent>
|
|||||||
lastDate: DateTime(2104));
|
lastDate: DateTime(2104));
|
||||||
if (pickedDate == null) return;
|
if (pickedDate == null) return;
|
||||||
if (position == "start") {
|
if (position == "start") {
|
||||||
startDatepicker.text = DateFormat("dd-MM-yyyy").format(pickedDate);
|
startDatepicker.text = DateFormat("dd/MM/yyyy").format(pickedDate);
|
||||||
}
|
}
|
||||||
if (position == "end") {
|
if (position == "end") {
|
||||||
endDatepicker.text = DateFormat("dd-MM-yyyy").format(pickedDate);
|
endDatepicker.text = DateFormat("dd/MM/yyyy").format(pickedDate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,9 +100,16 @@ class _EditEventState extends State<EditEvent>
|
|||||||
if ((startTimepicker.text.isEmpty) || (endTimepicker.text.isEmpty)) {
|
if ((startTimepicker.text.isEmpty) || (endTimepicker.text.isEmpty)) {
|
||||||
time = TimeOfDay.now();
|
time = TimeOfDay.now();
|
||||||
} else {
|
} else {
|
||||||
time = TimeOfDay.fromDateTime(DateTime.parse(startTimepicker.text));
|
DateTime date = new DateTime.now();
|
||||||
|
date = date.copyWith(
|
||||||
|
hour: int.parse(startTimepicker.text.split(":")[0]),
|
||||||
|
minute: int.parse(startTimepicker.text.split(":")[1]));
|
||||||
|
time = TimeOfDay.fromDateTime(date);
|
||||||
if (position == "end") {
|
if (position == "end") {
|
||||||
time = TimeOfDay.fromDateTime(DateTime.parse(endTimepicker.text));
|
date = date.copyWith(
|
||||||
|
hour: int.parse(endTimepicker.text.split(":")[0]),
|
||||||
|
minute: int.parse(endTimepicker.text.split(":")[1]));
|
||||||
|
time = TimeOfDay.fromDateTime(date);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,7 +139,8 @@ class _EditEventState extends State<EditEvent>
|
|||||||
}
|
}
|
||||||
|
|
||||||
String formatDate(String date) {
|
String formatDate(String date) {
|
||||||
var splitedDate = date.split("-");
|
var splitedDate = date.split("/");
|
||||||
|
|
||||||
var day = splitedDate[0];
|
var day = splitedDate[0];
|
||||||
var month = splitedDate[1];
|
var month = splitedDate[1];
|
||||||
var year = splitedDate[2];
|
var year = splitedDate[2];
|
||||||
@ -164,14 +172,15 @@ class _EditEventState extends State<EditEvent>
|
|||||||
formerDesc = convertNulltoEmptyString(events["description"]);
|
formerDesc = convertNulltoEmptyString(events["description"]);
|
||||||
formerTags = List<String>.from(events['tags'] as List);
|
formerTags = List<String>.from(events['tags'] as List);
|
||||||
formerOrga = List<String>.from(events['organizers'] as List);
|
formerOrga = List<String>.from(events['organizers'] as List);
|
||||||
final startDate = DateTime.parse(events["start_date"]);
|
startDate = DateTime.parse(events["start_date"]);
|
||||||
dateS = DateFormat.yMd().format(startDate);
|
//dateS = DateFormat.yMd().format(startDate);
|
||||||
timeS = DateFormat.Hm().format(startDate);
|
//print("startdate : ${dateS}");
|
||||||
|
//timeS = DateFormat.Hm().format(startDate);
|
||||||
|
|
||||||
final endDate = DateTime.parse(events["end_date"]);
|
endDate = DateTime.parse(events["end_date"]);
|
||||||
|
|
||||||
dateE = DateFormat.yMd().format(endDate);
|
//dateE = DateFormat.yMd().format(endDate);
|
||||||
timeE = DateFormat.Hm().format(endDate);
|
//timeE = DateFormat.Hm().format(endDate);
|
||||||
if (events["imgUrl"] != null) {
|
if (events["imgUrl"] != null) {
|
||||||
formerImage = events["imgUrl"];
|
formerImage = events["imgUrl"];
|
||||||
}
|
}
|
||||||
@ -227,10 +236,11 @@ class _EditEventState extends State<EditEvent>
|
|||||||
// _counter without calling setState(), then the build method would not be
|
// _counter without calling setState(), then the build method would not be
|
||||||
// called again, and so nothing would appear to happen.
|
// called again, and so nothing would appear to happen.
|
||||||
inputName.text = formerName;
|
inputName.text = formerName;
|
||||||
startDatepicker.text = DateFormat("dd-MM-yyyy").format(dateS);
|
startDatepicker.text =
|
||||||
startTimepicker.text = timeS.toString();
|
DateFormat("dd/MM/yyyy").format(startDate).toString();
|
||||||
endDatepicker.text = DateFormat("dd-MM-yyyy").format(dateE);
|
startTimepicker.text = DateFormat("HH:mm").format(startDate).toString();
|
||||||
endTimepicker.text = timeE.toString();
|
endDatepicker.text = DateFormat("dd/MM/yyyy").format(endDate).toString();
|
||||||
|
endTimepicker.text = DateFormat("HH:mm").format(endDate).toString();
|
||||||
initialOrga = formerOrga;
|
initialOrga = formerOrga;
|
||||||
inputGeo.text = formerMap;
|
inputGeo.text = formerMap;
|
||||||
imgUrl = formerImage;
|
imgUrl = formerImage;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user