NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

update
import 'dart:io';

import 'package:dio/dio.dart';
import 'package:dogppl/constants/export.dart';
import 'package:dogppl/model/request_model/services_reuest_model.dart';
import 'package:dogppl/model/response_model/services_response_model/add_event_response_model.dart';
import 'package:dogppl/ui/home/staff/staff_home_screen.dart';
import 'package:dogppl/utility/validator.dart';
import 'package:dogppl/widgets/Input_Text_Field.dart';
import 'package:dogppl/widgets/appBar.dart';
import 'package:dogppl/widgets/my_button.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
import 'package:geocoder/geocoder.dart';
import 'package:geolocator/geolocator.dart';

import 'package:intl/intl.dart';


class StaffUpdateScreen extends StatefulWidget {
final Map arguments;
StaffUpdateScreen(this.arguments);


@override
_StaffUpdateScreenState createState() => _StaffUpdateScreenState();
}

class _StaffUpdateScreenState extends State<StaffUpdateScreen> {


var _key = GlobalKey<FormState>();
CustomLoader _customLoader;
String qrCodeResult = "";
DateTime selectedDate = DateTime.now();
var myFormat = DateFormat('yyyy-MM-dd HH:mm:ss');
var selectImage = "Select Image";
AddEventResponseModel _addEventResponseModel;
TextEditingController eventNameController;
FocusNode eventNameFocusNode;
TextEditingController eventLocationController;
FocusNode eventLocationFocusNode;
TextEditingController eventDescController;
FocusNode eventDescFocusNode;
TextEditingController otherController;
TextEditingController totalNumberofSeatsController;
TextEditingController dateController;
TextEditingController imageController;
FocusNode otherFocusNode;
FocusNode dateFocusNode;
FocusNode imageFocusNode;
FocusNode totalNumberofSeatsFocusNode;
LocationPermission permission;
Position _position;
Address _addressfromLocation;
var latitude = 0.0;
var longitude = 0.0;
File image;
EventDataModel _eventDetailDataModel;

// var kInitialPosition = Lat(-33.8567844, 151.213108);

@override
void initState() {
_eventDetailDataModel = EventDataModel();
_eventDetailDataModel = widget.arguments['id'];
super.initState();
_customLoader = CustomLoader();
_addEventResponseModel = AddEventResponseModel();
eventNameController = TextEditingController();
eventNameFocusNode = FocusNode();
eventLocationController = TextEditingController();
dateController = TextEditingController();
eventLocationFocusNode = FocusNode();
eventDescController = TextEditingController();
eventDescFocusNode = FocusNode();
otherController = TextEditingController();
imageController = TextEditingController();
totalNumberofSeatsController = TextEditingController();
otherFocusNode = FocusNode();
imageFocusNode = FocusNode();
dateFocusNode = FocusNode();
totalNumberofSeatsFocusNode = FocusNode();
dateController.text = myFormat.format(DateTime.now()).toString();

_getLocation();

}

_getLocation() async {
Geolocator.requestPermission().then((value) {
permission = value;
});
if (permission == LocationPermission.denied ||
permission == LocationPermission.deniedForever) {
HelperWidget.toast(
message:
Strings.permissonDenied);
await Geolocator.openAppSettings();
} else {
_position = await Geolocator.getCurrentPosition(
desiredAccuracy: LocationAccuracy.bestForNavigation);
debugPrint('latitude: ${_position.latitude}'
'longitude: ${_position.longitude}');

latitude = _position.latitude;
longitude = _position.longitude;
final coordinates =
new Coordinates(_position.latitude, _position.longitude);

var addresses =
await Geocoder.local.findAddressesFromCoordinates(coordinates);
if(mounted)setState(() {
_addressfromLocation = addresses.first;
eventLocationController.text = addresses.first.addressLine;
});

}
}

@override
Widget build(BuildContext context) {
return SafeArea(bottom: true,
child: Scaffold(
appBar: KAppBar(
title: Strings.addevent,
backnav: true,
),
body: SingleChildScrollView(
physics: BouncingScrollPhysics(),
child: Container(
padding: EdgeInsets.only(left: 20, right: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_form(),
SizedBox(height: 50),
CustomMaterialButton(
onPressed: () {
if (_key.currentState.validate()) {
addEvent();
}
},
height: Dimens.height_50,
isIcon: false,
width: HelperUtility.fullWidthScreen(context: context),
fontsize: Dimens.font_16,
textColor: Colors.white,
borderColor: greenColor,
buttonText: Strings.save,
buttonColor: greenColor,
),
SizedBox(height: 10),
],
),
),
),
),
);
}

_form() => Form(
key: _key,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_textFieldLabel(Strings.eventname),
_eventName(),
HelperWidget.sizeBox(height: Dimens.elvation_5),
_textFieldLabel(Strings.event_location),
eventLocation(),
HelperWidget.sizeBox(height: Dimens.elvation_5),
_textFieldLabel(Strings.event_description),
_eventDescriptionEditText(),
HelperWidget.sizeBox(height: Dimens.elvation_5),
_textFieldLabel(Strings.date_and_time),
_dateTimePicker(),
HelperWidget.sizeBox(height: Dimens.elvation_5),
_textFieldLabel(Strings.other_general_desc),
_otherGeneralDescription(),
HelperWidget.sizeBox(height: Dimens.elvation_5),
_textFieldLabel(Strings.totalNoOfSeats),
_totalNumberofSets(),
SizedBox(
height: Dimens.margin_5,
),
_textFieldLabel(Strings.upload_img),
_imageUpload()
],
),
);

_eventName() => InputFieldWidget(
hint: Strings.hm123,
textController: eventNameController,
focusNode: eventNameFocusNode,
inputAction: TextInputAction.next,
inputType: TextInputType.name,
validate: (String val) {
return FieldChecker.fieldCheckerCharacter(
value: val, message: Strings.eventname);
},
);

eventLocation() => InputFieldWidget(
hint: Strings.hm123,
onChange: () async {},
textController: eventLocationController,
focusNode: eventLocationFocusNode,
inputAction: TextInputAction.next,
inputType: TextInputType.streetAddress,
validate: (String val) {
return FieldChecker.fieldChecker(
value: val, message: Strings.event_location);
},
);

_eventDescriptionEditText() => InputFieldWidget(
hint: Strings.write_abt_yr_event,
textController: eventDescController,
focusNode: eventDescFocusNode,
inputAction: TextInputAction.next,
validate: (String val) {
return FieldChecker.fieldChecker(
value: val, message: Strings.event_description);
},
);

_dateTimePicker() => InputFieldWidget(
hint: Strings.dateTime,
textController: dateController,
focusNode: dateFocusNode,
inputAction: TextInputAction.next,
readOnly: true,
inputType: TextInputType.number,
suffixIcon: IconButton(
onPressed: () {
_selectDate();
},
icon: Image.asset(
Assets.icCal,
height: 22.0,
width: 22.0,
),
),
onFieldSubmitted: (String data) {
HelperUtility.focusOnNextEditText(
context: context, nextFocus: otherFocusNode);
},
validate: (String val) {
return FieldChecker.fieldChecker(
value: val, message: Strings.date_and_time);
},
);

_otherGeneralDescription() => InputFieldWidget(
hint: Strings.write_abt_yr_event,
textController: otherController,
focusNode: otherFocusNode,
inputAction: TextInputAction.next,
validate: (String val) {
return FieldChecker.fieldChecker(
value: val, message: Strings.other_general_desc);
},
);

_totalNumberofSets() => InputFieldWidget(
hint: "10",
textController: totalNumberofSeatsController,
focusNode: totalNumberofSeatsFocusNode,
inputAction: TextInputAction.next,
inputType: TextInputType.number,
validate: (String val) {
return FieldChecker.fieldCheckerNumber(
value: val, message: Strings.totalNoOfSeats);
},
);

_imageUpload() => InputFieldWidget(
hint: Strings.upload_img,
textController: imageController,
focusNode: imageFocusNode,
inputAction: TextInputAction.next,
readOnly: true,
inputType: TextInputType.number,
suffixIcon: IconButton(
onPressed: () {
showDailog();
},
icon: Image.asset(
Assets.icUpload,
height: 22.0,
width: 22.0,
),
),
validate: (String val) {
return FieldChecker.fieldChecker(
value: val, message: Strings.upload_img);
},
);

Text _textFieldLabel(String label) {
return Text(label,
style: HelperUtility.textStyleBold(
color: grey50, fontsize: 15, height: 2));
}

Widget roundedContainer(
{Widget child, double height, double width, Color color}) {
return Container(
height: height,
width: width,
child: child,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: color,
// color: grey50.withOpacity(0.3),
),
);
}

void _selectDate() async {
DatePicker.showDateTimePicker(context, showTitleActions: true,
onChanged: (date) {
print('change $date in time zone ' +
date.timeZoneOffset.inHours.toString());
if(mounted)setState(() {
dateController.text = '${myFormat.format(date)}';
debugPrint("${myFormat.format(date)}");
});
}, onConfirm: (date) {
print('confirm $date');
}, currentTime: DateTime.now());
}

void addEvent() async {
_customLoader.show(context);

var mulipartImage =
await MultipartFile.fromFile(image.path, filename: image.path);

var requestData = ServicesRequestModel.updateEventReuestModel(
title: eventNameController.text.trim(),
id: _eventDetailDataModel.id,
address: _addressfromLocation.addressLine,
city: _addressfromLocation.locality,
description: eventDescController.text.trim(),dateTime: dateController.text,
latitude: latitude,
longitude: longitude,seats: int.parse(totalNumberofSeatsController.text),
image: mulipartImage,
);

await APIRepository.updateEventSatffApiCall(
requestData,context
).then((value) {
if (value != null) {
_customLoader.hide();
_addEventResponseModel = value;
HelperWidget.toast(message: _addEventResponseModel.success);
HelperUtility.pushAndRemoveUntil(
context: context, route: StaffHomeScreen(0));
} else {
_customLoader.hide();
}
});
}

@override
void dispose() {
super.dispose();
_customLoader.hide();
dateController.dispose();
dateFocusNode.dispose();
imageController.dispose();
imageFocusNode.dispose();
eventNameController.dispose();
eventNameFocusNode.dispose();
eventLocationController.dispose();
eventLocationFocusNode.dispose();
eventDescController.dispose();
eventDescFocusNode.dispose();
otherController.dispose();
otherFocusNode.dispose();
}

void showDailog() => AlertDialogs.showDialog(
context: context,
widget: Padding(
padding: EdgeInsets.only(
left: Dimens.margin_20,
right: Dimens.margin_20,
bottom: Dimens.margin_10,
top: Dimens.margin_10),
child: Card(
elevation: 10.0,
child: Container(
width: HelperUtility.fullWidthScreen(context: context),
decoration: HelperWidget.decorationBoxx(
borderWidth: Dimens.radius_1,
cornerRaduis: Dimens.margin_0,
borderColor: Colors.white,
backgroundColor: Colors.white),
padding: EdgeInsets.all(Dimens.margin_15),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Align(
alignment: Alignment.topRight,
child: HelperWidget.getInkwell(
onTap: () {
Navigator.pop(context);
},
widget: Icon(
Icons.cancel,
)),
),
Text(
Strings.choose,
style: HelperUtility.textStyleBold(
color: Colors.black, fontsize: Dimens.font_18),
),
HelperWidget.sizeBox(height: Dimens.width_20),
Row(
children: [
Expanded(
child: InkWell(
onTap: () {
_imagePickGromCamer();
},
child: Container(
child: Column(
children: [
Icon(Icons.camera_alt,size: 50.0,color: greenColor,),
Text(
Strings.camera,
style: HelperUtility.textStyle(
color: Colors.black,
fontsize: Dimens.font_14),
),
],
),
),
)),
Expanded(
child: InkWell(
onTap: () {
_imagePickGallery();
},
child: Container(
child: Column(
children: [
Icon(
Icons.file_copy_rounded,
size: 50.0,
color: greenColor,
),
Text(
Strings.gallery,
style: HelperUtility.textStyle(
color: Colors.black,
fontsize: Dimens.font_14),
),
],
),
),
)),
],
),
HelperWidget.sizeBox(height: Dimens.width_20),
],
),
),
),
));

void _imagePickGromCamer() async {
var pickedFile = await ImagePick.imgFromCamera();
File file = File(pickedFile.path);
if (file == null) {
HelperWidget.toast(message: "Image choose canceld");
} else {
Navigator.pop(context);
if (mounted)
if(mounted)setState(() {
image = file;
imageController.text = image.path;
});
}
}

void _imagePickGallery() async {
var pickedFile = await ImagePick.imgFromGallery();
File file = File(pickedFile.path);
if (file == null) {
HelperWidget.toast(message: "Image choose canceld");
} else {
Navigator.pop(context);
if (mounted)
if(mounted)setState(() {
image = file;
imageController.text = image.path;
});
}
}
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.