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