sdk upgrade changes.
parent
d5ee12abbb
commit
7d0a2eb65c
@ -1,5 +1,5 @@
|
|||||||
class Base {
|
class Base {
|
||||||
String name, identifier;
|
String? name, identifier;
|
||||||
|
|
||||||
Base({this.name, this.identifier});
|
Base({this.name, this.identifier});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,75 +1,92 @@
|
|||||||
class SystemNotificationModel {
|
class SystemNotificationModel {
|
||||||
String userId;
|
String? userId;
|
||||||
String userName;
|
String? userName;
|
||||||
String title;
|
String? title;
|
||||||
String text;
|
String? text;
|
||||||
int referenceId;
|
int? referenceId;
|
||||||
int sourceId;
|
int? sourceId;
|
||||||
String sourceName;
|
String? sourceName;
|
||||||
bool readed;
|
bool? readed;
|
||||||
String readingDate;
|
String? readingDate;
|
||||||
int id;
|
int? id;
|
||||||
String createdOn;
|
String? createdOn;
|
||||||
String modifiedOn;
|
String? modifiedOn;
|
||||||
String priorityName;
|
String? priorityName;
|
||||||
String statusName;
|
String? statusName;
|
||||||
|
|
||||||
SystemNotificationModel(
|
SystemNotificationModel(
|
||||||
{this.userId, this.userName, this.title, this.text, this.referenceId, this.sourceId, this.sourceName, this.readed, this.readingDate, this.id, this.createdOn, this.modifiedOn, this.priorityName, this.statusName});
|
{this.userId,
|
||||||
|
this.userName,
|
||||||
|
this.title,
|
||||||
|
this.text,
|
||||||
|
this.referenceId,
|
||||||
|
this.sourceId,
|
||||||
|
this.sourceName,
|
||||||
|
this.readed,
|
||||||
|
this.readingDate,
|
||||||
|
this.id,
|
||||||
|
this.createdOn,
|
||||||
|
this.modifiedOn,
|
||||||
|
this.priorityName,
|
||||||
|
this.statusName});
|
||||||
|
|
||||||
SystemNotificationModel.fromJson(Map<String, dynamic> json) {
|
SystemNotificationModel.fromJson(Map<String, dynamic>? json) {
|
||||||
userId = json['userId'];
|
// Allow json to be null
|
||||||
userName = json['userName'];
|
if (json != null) {
|
||||||
title = json['title'];
|
// Add null check
|
||||||
text = json['text'];
|
userId = json['userId'];
|
||||||
referenceId = json['referenceId'];
|
userName = json['userName'];
|
||||||
sourceId = json['sourceId'];
|
title = json['title'];
|
||||||
sourceName = json['sourceName'];
|
text = json['text'];
|
||||||
readed = json['readed'];
|
referenceId = json['referenceId'];
|
||||||
readingDate = json['readingDate'];
|
sourceId = json['sourceId'];
|
||||||
id = json['id'];
|
sourceName = json['sourceName'];
|
||||||
createdOn = json['createdOn'];
|
readed = json['readed'];
|
||||||
modifiedOn = json['modifiedOn'];
|
readingDate = json['readingDate'];
|
||||||
priorityName = json['priorityName'];
|
id = json['id'];
|
||||||
statusName = json['statusName'];
|
createdOn = json['createdOn'];
|
||||||
|
modifiedOn = json['modifiedOn'];
|
||||||
|
priorityName = json['priorityName'];
|
||||||
|
statusName = json['statusName'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, dynamic> toNotificationJson() {
|
Map<String, dynamic> toNotificationJson() {
|
||||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
final Map<String, dynamic> data = <String, dynamic>{}; // Use <String, dynamic> for type safety
|
||||||
data['userId'] = this.userId;
|
data['userId'] = userId;
|
||||||
data['userName'] = this.userName;
|
data['userName'] = userName;
|
||||||
data['title'] = this.title;
|
data['title'] = title;
|
||||||
data['text'] = this.text;
|
data['text'] = text;
|
||||||
data['requestNumber'] = this.referenceId;
|
data['requestNumber'] = referenceId;
|
||||||
data['sourceId'] = this.sourceId;
|
data['sourceId'] = sourceId;
|
||||||
data['requestType'] = this.sourceName;
|
data['requestType'] = sourceName;
|
||||||
data['readed'] = this.readed;
|
data['readed'] = readed;
|
||||||
data['readingDate'] = this.readingDate;
|
data['readingDate'] = readingDate;
|
||||||
data['id'] = this.id;
|
data['id'] = id;
|
||||||
data['createdOn'] = this.createdOn;
|
data['createdOn'] = createdOn;
|
||||||
data['modifiedOn'] = this.modifiedOn;
|
data['modifiedOn'] = modifiedOn;
|
||||||
data['priorityName'] = this.priorityName;
|
data['priorityName'] = priorityName;
|
||||||
data['priority'] = this.priorityName;
|
data['priority'] = priorityName;
|
||||||
data['statusName'] = this.statusName;
|
data['statusName'] = statusName;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
final Map<String, dynamic> data = <String, dynamic>{}; // Use <String, dynamic> for type safety
|
||||||
data['userId'] = this.userId;
|
data['userId'] = userId;
|
||||||
data['userName'] = this.userName;
|
data['userName'] = userName;
|
||||||
data['title'] = this.title;
|
data['title'] = title;
|
||||||
data['text'] = this.text;
|
data['text'] = text;
|
||||||
data['referenceId'] = this.referenceId;
|
data['referenceId'] = referenceId;
|
||||||
data['sourceId'] = this.sourceId;
|
data['sourceId'] = sourceId;
|
||||||
data['sourceName'] = this.sourceName;
|
data['sourceName'] = sourceName;
|
||||||
data['readed'] = this.readed;
|
data['readed'] = readed;
|
||||||
data['readingDate'] = this.readingDate;
|
data['readingDate'] = readingDate;
|
||||||
data['id'] = this.id;
|
data['id'] = id;
|
||||||
data['createdOn'] = this.createdOn;
|
data['createdOn'] = createdOn;
|
||||||
data['modifiedOn'] = this.modifiedOn;
|
data['modifiedOn'] = modifiedOn;
|
||||||
data['priorityName'] = this.priorityName;
|
data['priorityName'] = priorityName;
|
||||||
data['statusName'] = this.statusName;
|
data['statusName'] = statusName;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,139 +1,130 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:test_sa/extensions/context_extension.dart';
|
import 'package:test_sa/extensions/context_extension.dart';
|
||||||
import 'package:test_sa/extensions/int_extensions.dart';
|
import'package:test_sa/extensions/int_extensions.dart';
|
||||||
|
|
||||||
import '../../../models/new_models/assistant_employee.dart';
|
import '../../../models/new_models/assistant_employee.dart';
|
||||||
import '../../../new_views/app_style/app_color.dart';
|
import '../../../new_views/app_style/app_color.dart';
|
||||||
|
|
||||||
class AssistantEmployeeMenu extends StatefulWidget {
|
class AssistantEmployeeMenu extends StatefulWidget {
|
||||||
final List<AssistantEmployees> statuses;
|
final List<AssistantEmployees> statuses;
|
||||||
final AssistantEmployees initialStatus;
|
final AssistantEmployees? initialStatus; // Now nullable
|
||||||
final Function(AssistantEmployees) onSelect;
|
final Function(AssistantEmployees?) onSelect; // Now accepts nullable values
|
||||||
final String title;
|
final String? title; // Now nullable
|
||||||
final bool enable;
|
final bool enable;
|
||||||
|
|
||||||
const AssistantEmployeeMenu({Key key, this.statuses, this.title, this.onSelect, this.initialStatus, this.enable = true}) : super(key: key);
|
const AssistantEmployeeMenu({Key? key, required this.statuses, this.title, required this.onSelect, this.initialStatus, this.enable = true}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_SingleAssistantEmployeeMenuState createState() => _SingleAssistantEmployeeMenuState();
|
_SingleAssistantEmployeeMenuState createState() => _SingleAssistantEmployeeMenuState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _SingleAssistantEmployeeMenuState extends State<AssistantEmployeeMenu> {
|
class _SingleAssistantEmployeeMenuState extends State<AssistantEmployeeMenu> {AssistantEmployees? _selectedStatus; // Now nullable
|
||||||
AssistantEmployees _selectedStatus;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void setState(VoidCallback fn) {
|
void setState(VoidCallback fn) {
|
||||||
if (mounted) super.setState(fn);
|
if (mounted) super.setState(fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void didUpdateWidget(covariant AssistantEmployeeMenu oldWidget) {
|
void didUpdateWidget(covariant AssistantEmployeeMenu oldWidget) {
|
||||||
if (widget.initialStatus != null) {
|
if (widget.initialStatus != null) {
|
||||||
final result = widget.statuses?.where((element) {
|
final result = widget.statuses.where((element) => element.user?.id == widget.initialStatus?.user?.id);
|
||||||
return element?.user?.id == widget.initialStatus?.user?.id;
|
if (result.isNotEmpty) {
|
||||||
});
|
_selectedStatus = result.first;
|
||||||
if (result.isNotEmpty) {
|
|
||||||
_selectedStatus = result.first;
|
|
||||||
} else {
|
|
||||||
_selectedStatus = null;
|
|
||||||
}
|
|
||||||
if ((widget.initialStatus?.user?.id ?? "") != (_selectedStatus?.user?.id ?? "")) {
|
|
||||||
widget.onSelect(_selectedStatus);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
_selectedStatus = null;
|
_selectedStatus = null;
|
||||||
}
|
}
|
||||||
super.didUpdateWidget(oldWidget);
|
if (widget.initialStatus?.user?.id != _selectedStatus?.user?.id) {
|
||||||
|
widget.onSelect(_selectedStatus);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_selectedStatus = null;
|
||||||
}
|
}
|
||||||
|
super.didUpdateWidget(oldWidget);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
if (widget.initialStatus != null) {
|
if (widget.initialStatus != null) {
|
||||||
final result = widget.statuses?.where((element) {
|
final result = widget.statuses.where((element) => element.user?.id == widget.initialStatus?.user?.id);
|
||||||
return element?.user?.id == widget.initialStatus?.user?.id;
|
if (result.isNotEmpty) {
|
||||||
});
|
_selectedStatus = result.first;
|
||||||
if (result.isNotEmpty) _selectedStatus = result.first;
|
}
|
||||||
if (widget.initialStatus?.user?.id != _selectedStatus?.user?.id) {
|
if (widget.initialStatus?.user?.id != _selectedStatus?.user?.id) {
|
||||||
widget.onSelect(_selectedStatus);
|
widget.onSelect(_selectedStatus);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
super.initState();
|
|
||||||
}
|
}
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
height: 60.toScreenHeight,
|
height: 60.toScreenHeight,
|
||||||
padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth),
|
padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: context.isDark ? AppColor.neutral50 : Colors.white,
|
color: context.isDark ? AppColor.neutral50 : Colors.white,
|
||||||
borderRadius: BorderRadius.circular(10),
|
borderRadius: BorderRadius.circular(10),
|
||||||
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)],
|
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)],
|
||||||
),
|
),
|
||||||
child: Stack(
|
child: Stack(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
children: [
|
children: [
|
||||||
PositionedDirectional(
|
PositionedDirectional(
|
||||||
end: 0,
|
end: 0,
|
||||||
child: Icon(
|
child: Icon(
|
||||||
Icons.keyboard_arrow_down_rounded,
|
Icons.keyboard_arrow_down_rounded,
|
||||||
color: widget.enable ? null : Colors.grey,
|
color: widget.enable ? null : Colors.grey,
|
||||||
)),
|
),
|
||||||
Column(
|
),
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
if (widget.title != null)
|
children: [
|
||||||
Text(
|
if (widget.title != null)
|
||||||
widget.title,
|
Text(
|
||||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(color: context.isDark ? null : AppColor.neutral20, fontWeight: FontWeight.w500),
|
widget.title!, // Non-null assertion after null check
|
||||||
),
|
style: Theme.of(context).textTheme.bodySmall?.copyWith(color: context.isDark ? null : AppColor.neutral20, fontWeight: FontWeight.w500),
|
||||||
DropdownButton<AssistantEmployees>(
|
),
|
||||||
value: _selectedStatus,
|
DropdownButton<AssistantEmployees>(
|
||||||
iconSize: 24,
|
value: _selectedStatus,
|
||||||
isDense: true,
|
iconSize: 24,
|
||||||
icon: const SizedBox.shrink(),
|
isDense: true,
|
||||||
elevation: 0,
|
icon: const SizedBox.shrink(),
|
||||||
isExpanded: true,
|
elevation: 0,
|
||||||
hint: Text(
|
isExpanded: true,
|
||||||
context.translation.select,
|
hint: Text(
|
||||||
style: Theme.of(context).textTheme.bodyLarge,
|
context.translation.select,
|
||||||
),
|
style: Theme.of(context).textTheme.bodyLarge,
|
||||||
style: TextStyle(color: Theme.of(context).primaryColor),
|
),
|
||||||
underline: const SizedBox.shrink(),
|
style: TextStyle(color: Theme.of(context).primaryColor),
|
||||||
|
underline: const SizedBox.shrink(),
|
||||||
onChanged: widget.enable
|
onChanged: widget.enable
|
||||||
? (AssistantEmployees newValue) {
|
? (AssistantEmployees? newValue) { // Now accepts nullable values
|
||||||
setState(() {
|
setState(() {
|
||||||
_selectedStatus = newValue;
|
_selectedStatus = newValue;
|
||||||
});
|
});
|
||||||
widget.onSelect(newValue);
|
widget.onSelect(newValue);
|
||||||
}
|
}
|
||||||
: null,
|
:null,
|
||||||
|
items: widget.statuses.map<DropdownMenuItem<AssistantEmployees>>(
|
||||||
// onChanged: (AssistantEmployees newValue) {
|
(AssistantEmployees value) {
|
||||||
// setState(() {
|
|
||||||
// _selectedStatus = newValue;
|
|
||||||
// });
|
|
||||||
// widget.onSelect(newValue);
|
|
||||||
// },
|
|
||||||
items: widget.statuses.map<DropdownMenuItem<AssistantEmployees>>((AssistantEmployees value) {
|
|
||||||
return DropdownMenuItem<AssistantEmployees>(
|
return DropdownMenuItem<AssistantEmployees>(
|
||||||
value: value,
|
value: value,
|
||||||
child: Text(
|
child: Text(
|
||||||
value.user?.name ?? "NULL",
|
value.user?.name ?? "NULL", // Use null-aware operator for user.name
|
||||||
style: Theme.of(context).textTheme.bodyLarge.copyWith(
|
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
|
||||||
color: widget.enable ? Theme.of(context).primaryColor : Colors.grey,
|
color: widget.enable ? Theme.of(context).primaryColor : Colors.grey,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}).toList(),
|
},
|
||||||
),
|
).toList(),
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
);
|
),
|
||||||
}
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -1,26 +1,26 @@
|
|||||||
import 'package:flutter/material.dart';
|
// import 'package:flutter/material.dart';
|
||||||
import 'package:test_sa/views/app_style/sizing.dart';
|
// import 'package:test_sa/views/app_style/sizing.dart';
|
||||||
|
//
|
||||||
class ASubTitle extends StatelessWidget {
|
// class ASubTitle extends StatelessWidget {
|
||||||
final String text;
|
// final String text;
|
||||||
final EdgeInsets padding;
|
// final EdgeInsets padding;
|
||||||
final Color color;
|
// final Color color;
|
||||||
final double font;
|
// final double font;
|
||||||
|
//
|
||||||
const ASubTitle(this.text, {Key key, this.padding, this.color, this.font}) : super(key: key);
|
// const ASubTitle(this.text, {Key key, this.padding, this.color, this.font}) : super(key: key);
|
||||||
|
//
|
||||||
@override
|
// @override
|
||||||
Widget build(BuildContext context) {
|
// Widget build(BuildContext context) {
|
||||||
return Padding(
|
// return Padding(
|
||||||
padding: padding ?? EdgeInsets.zero,
|
// padding: padding ?? EdgeInsets.zero,
|
||||||
child: Text(
|
// child: Text(
|
||||||
text,
|
// text,
|
||||||
style: Theme.of(context).textTheme.bodyText1.copyWith(
|
// style: Theme.of(context).textTheme.bodyLarge?.copyWith(
|
||||||
// fontWeight: FontWeight.bold,
|
// // fontWeight: FontWeight.bold,
|
||||||
fontSize: font,
|
// fontSize: font,
|
||||||
color: color),
|
// color: color),
|
||||||
textScaleFactor: AppStyle.getScaleFactor(context),
|
// textScaleFactor: AppStyle.getScaleFactor(context),
|
||||||
),
|
// ),
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|||||||
Loading…
Reference in New Issue