Initial (redacted) commit.

This commit is contained in:
mustard 2024-08-26 00:34:20 +02:00
commit 655f8a036a
368 changed files with 20949 additions and 0 deletions

View file

@ -0,0 +1,5 @@
import 'package:riverpod/riverpod.dart';
import 'package:sembast/sembast.dart';
final databaseProvider =
Provider<Database>((_) => throw Exception('Database not initialized'));

View file

@ -0,0 +1,31 @@
import 'package:flutter/foundation.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'hydration.freezed.dart';
part 'hydration.g.dart';
@freezed
class Hydration with _$Hydration {
const factory Hydration({
required String widgetType,
required String name,
required int button1Amount,
required int button2Amount,
required int goal,
required int current,
required bool isExpanded,
required bool isVisible,
required String createdOn,
required String completedOn,
@Default(-1) int id,
}) = _Hydration;
factory Hydration.fromJson(Map<String, Object?> json) =>
_$HydrationFromJson(json);
}
extension JsonWithoutId on Hydration {
Map<String, dynamic> toJsonWithoutId() {
final map = toJson()..remove('id');
return map;
}
}

View file

@ -0,0 +1,392 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'hydration.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
Hydration _$HydrationFromJson(Map<String, dynamic> json) {
return _Hydration.fromJson(json);
}
/// @nodoc
mixin _$Hydration {
String get widgetType => throw _privateConstructorUsedError;
String get name => throw _privateConstructorUsedError;
int get button1Amount => throw _privateConstructorUsedError;
int get button2Amount => throw _privateConstructorUsedError;
int get goal => throw _privateConstructorUsedError;
int get current => throw _privateConstructorUsedError;
bool get isExpanded => throw _privateConstructorUsedError;
bool get isVisible => throw _privateConstructorUsedError;
String get createdOn => throw _privateConstructorUsedError;
String get completedOn => throw _privateConstructorUsedError;
int get id => throw _privateConstructorUsedError;
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$HydrationCopyWith<Hydration> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $HydrationCopyWith<$Res> {
factory $HydrationCopyWith(Hydration value, $Res Function(Hydration) then) =
_$HydrationCopyWithImpl<$Res, Hydration>;
@useResult
$Res call(
{String widgetType,
String name,
int button1Amount,
int button2Amount,
int goal,
int current,
bool isExpanded,
bool isVisible,
String createdOn,
String completedOn,
int id});
}
/// @nodoc
class _$HydrationCopyWithImpl<$Res, $Val extends Hydration>
implements $HydrationCopyWith<$Res> {
_$HydrationCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
@pragma('vm:prefer-inline')
@override
$Res call({
Object? widgetType = null,
Object? name = null,
Object? button1Amount = null,
Object? button2Amount = null,
Object? goal = null,
Object? current = null,
Object? isExpanded = null,
Object? isVisible = null,
Object? createdOn = null,
Object? completedOn = null,
Object? id = null,
}) {
return _then(_value.copyWith(
widgetType: null == widgetType
? _value.widgetType
: widgetType // ignore: cast_nullable_to_non_nullable
as String,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
button1Amount: null == button1Amount
? _value.button1Amount
: button1Amount // ignore: cast_nullable_to_non_nullable
as int,
button2Amount: null == button2Amount
? _value.button2Amount
: button2Amount // ignore: cast_nullable_to_non_nullable
as int,
goal: null == goal
? _value.goal
: goal // ignore: cast_nullable_to_non_nullable
as int,
current: null == current
? _value.current
: current // ignore: cast_nullable_to_non_nullable
as int,
isExpanded: null == isExpanded
? _value.isExpanded
: isExpanded // ignore: cast_nullable_to_non_nullable
as bool,
isVisible: null == isVisible
? _value.isVisible
: isVisible // ignore: cast_nullable_to_non_nullable
as bool,
createdOn: null == createdOn
? _value.createdOn
: createdOn // ignore: cast_nullable_to_non_nullable
as String,
completedOn: null == completedOn
? _value.completedOn
: completedOn // ignore: cast_nullable_to_non_nullable
as String,
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
) as $Val);
}
}
/// @nodoc
abstract class _$$HydrationImplCopyWith<$Res>
implements $HydrationCopyWith<$Res> {
factory _$$HydrationImplCopyWith(
_$HydrationImpl value, $Res Function(_$HydrationImpl) then) =
__$$HydrationImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{String widgetType,
String name,
int button1Amount,
int button2Amount,
int goal,
int current,
bool isExpanded,
bool isVisible,
String createdOn,
String completedOn,
int id});
}
/// @nodoc
class __$$HydrationImplCopyWithImpl<$Res>
extends _$HydrationCopyWithImpl<$Res, _$HydrationImpl>
implements _$$HydrationImplCopyWith<$Res> {
__$$HydrationImplCopyWithImpl(
_$HydrationImpl _value, $Res Function(_$HydrationImpl) _then)
: super(_value, _then);
@pragma('vm:prefer-inline')
@override
$Res call({
Object? widgetType = null,
Object? name = null,
Object? button1Amount = null,
Object? button2Amount = null,
Object? goal = null,
Object? current = null,
Object? isExpanded = null,
Object? isVisible = null,
Object? createdOn = null,
Object? completedOn = null,
Object? id = null,
}) {
return _then(_$HydrationImpl(
widgetType: null == widgetType
? _value.widgetType
: widgetType // ignore: cast_nullable_to_non_nullable
as String,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
button1Amount: null == button1Amount
? _value.button1Amount
: button1Amount // ignore: cast_nullable_to_non_nullable
as int,
button2Amount: null == button2Amount
? _value.button2Amount
: button2Amount // ignore: cast_nullable_to_non_nullable
as int,
goal: null == goal
? _value.goal
: goal // ignore: cast_nullable_to_non_nullable
as int,
current: null == current
? _value.current
: current // ignore: cast_nullable_to_non_nullable
as int,
isExpanded: null == isExpanded
? _value.isExpanded
: isExpanded // ignore: cast_nullable_to_non_nullable
as bool,
isVisible: null == isVisible
? _value.isVisible
: isVisible // ignore: cast_nullable_to_non_nullable
as bool,
createdOn: null == createdOn
? _value.createdOn
: createdOn // ignore: cast_nullable_to_non_nullable
as String,
completedOn: null == completedOn
? _value.completedOn
: completedOn // ignore: cast_nullable_to_non_nullable
as String,
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
));
}
}
/// @nodoc
@JsonSerializable()
class _$HydrationImpl with DiagnosticableTreeMixin implements _Hydration {
const _$HydrationImpl(
{required this.widgetType,
required this.name,
required this.button1Amount,
required this.button2Amount,
required this.goal,
required this.current,
required this.isExpanded,
required this.isVisible,
required this.createdOn,
required this.completedOn,
this.id = -1});
factory _$HydrationImpl.fromJson(Map<String, dynamic> json) =>
_$$HydrationImplFromJson(json);
@override
final String widgetType;
@override
final String name;
@override
final int button1Amount;
@override
final int button2Amount;
@override
final int goal;
@override
final int current;
@override
final bool isExpanded;
@override
final bool isVisible;
@override
final String createdOn;
@override
final String completedOn;
@override
@JsonKey()
final int id;
@override
String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) {
return 'Hydration(widgetType: $widgetType, name: $name, button1Amount: $button1Amount, button2Amount: $button2Amount, goal: $goal, current: $current, isExpanded: $isExpanded, isVisible: $isVisible, createdOn: $createdOn, completedOn: $completedOn, id: $id)';
}
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties
..add(DiagnosticsProperty('type', 'Hydration'))
..add(DiagnosticsProperty('widgetType', widgetType))
..add(DiagnosticsProperty('name', name))
..add(DiagnosticsProperty('button1Amount', button1Amount))
..add(DiagnosticsProperty('button2Amount', button2Amount))
..add(DiagnosticsProperty('goal', goal))
..add(DiagnosticsProperty('current', current))
..add(DiagnosticsProperty('isExpanded', isExpanded))
..add(DiagnosticsProperty('isVisible', isVisible))
..add(DiagnosticsProperty('createdOn', createdOn))
..add(DiagnosticsProperty('completedOn', completedOn))
..add(DiagnosticsProperty('id', id));
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$HydrationImpl &&
(identical(other.widgetType, widgetType) ||
other.widgetType == widgetType) &&
(identical(other.name, name) || other.name == name) &&
(identical(other.button1Amount, button1Amount) ||
other.button1Amount == button1Amount) &&
(identical(other.button2Amount, button2Amount) ||
other.button2Amount == button2Amount) &&
(identical(other.goal, goal) || other.goal == goal) &&
(identical(other.current, current) || other.current == current) &&
(identical(other.isExpanded, isExpanded) ||
other.isExpanded == isExpanded) &&
(identical(other.isVisible, isVisible) ||
other.isVisible == isVisible) &&
(identical(other.createdOn, createdOn) ||
other.createdOn == createdOn) &&
(identical(other.completedOn, completedOn) ||
other.completedOn == completedOn) &&
(identical(other.id, id) || other.id == id));
}
@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(
runtimeType,
widgetType,
name,
button1Amount,
button2Amount,
goal,
current,
isExpanded,
isVisible,
createdOn,
completedOn,
id);
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$HydrationImplCopyWith<_$HydrationImpl> get copyWith =>
__$$HydrationImplCopyWithImpl<_$HydrationImpl>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$HydrationImplToJson(
this,
);
}
}
abstract class _Hydration implements Hydration {
const factory _Hydration(
{required final String widgetType,
required final String name,
required final int button1Amount,
required final int button2Amount,
required final int goal,
required final int current,
required final bool isExpanded,
required final bool isVisible,
required final String createdOn,
required final String completedOn,
final int id}) = _$HydrationImpl;
factory _Hydration.fromJson(Map<String, dynamic> json) =
_$HydrationImpl.fromJson;
@override
String get widgetType;
@override
String get name;
@override
int get button1Amount;
@override
int get button2Amount;
@override
int get goal;
@override
int get current;
@override
bool get isExpanded;
@override
bool get isVisible;
@override
String get createdOn;
@override
String get completedOn;
@override
int get id;
@override
@JsonKey(ignore: true)
_$$HydrationImplCopyWith<_$HydrationImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View file

@ -0,0 +1,37 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'hydration.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_$HydrationImpl _$$HydrationImplFromJson(Map<String, dynamic> json) =>
_$HydrationImpl(
widgetType: json['widgetType'] as String,
name: json['name'] as String,
button1Amount: (json['button1Amount'] as num).toInt(),
button2Amount: (json['button2Amount'] as num).toInt(),
goal: (json['goal'] as num).toInt(),
current: (json['current'] as num).toInt(),
isExpanded: json['isExpanded'] as bool,
isVisible: json['isVisible'] as bool,
createdOn: json['createdOn'] as String,
completedOn: json['completedOn'] as String,
id: (json['id'] as num?)?.toInt() ?? -1,
);
Map<String, dynamic> _$$HydrationImplToJson(_$HydrationImpl instance) =>
<String, dynamic>{
'widgetType': instance.widgetType,
'name': instance.name,
'button1Amount': instance.button1Amount,
'button2Amount': instance.button2Amount,
'goal': instance.goal,
'current': instance.current,
'isExpanded': instance.isExpanded,
'isVisible': instance.isVisible,
'createdOn': instance.createdOn,
'completedOn': instance.completedOn,
'id': instance.id,
};

View file

@ -0,0 +1,9 @@
abstract class ItemRepository {
Future<int> insertItem(dynamic item);
Future<void> updateItem(dynamic item);
Future<void> deleteItem(int itemId);
Stream<List<dynamic>> getAllItemsStream();
}

View file

@ -0,0 +1,71 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:habitrack_app/main.dart';
import 'package:habitrack_app/sembast/global_providers.dart';
import 'package:habitrack_app/sembast/hydration.dart';
import 'package:habitrack_app/sembast/item_repository.dart';
import 'package:habitrack_app/sembast/tasks_list.dart';
import 'package:habitrack_app/sembast/timer.dart';
import 'package:sembast/sembast.dart';
final itemRepositoryProvider = Provider(
(ref) => SembastItemRepository(
database: ref.watch(databaseProvider),
),
);
class SembastItemRepository implements ItemRepository {
SembastItemRepository({required this.database}) {
_store = intMapStoreFactory.store('item_store');
}
final Database database;
late final StoreRef<int, Map<String, dynamic>> _store;
@override
Future<int> insertItem(dynamic item) {
if (item is Hydration) {
_store.add(database, item.toJson());
} else if (item is TimerItem) {
_store.add(database, item.toJson());
} else if (item is TasksItem) {
_store.add(database, item.toJson());
}
return Future.value(0);
}
@override
Future<void> updateItem(dynamic item) {
if (item is Hydration) {
_store.record(item.id).update(database, item.toJson());
} else if (item is TimerItem) {
_store.record(item.id).update(database, item.toJson());
} else if (item is TasksItem) {
logger.i('UPDATING TASKS ITEM');
_store.record(item.id).update(database, item.toJson());
}
logger.i('Item got past update: $item');
return Future.value();
// throw Error();
}
@override
Future<void> deleteItem(int itemId) => _store.record(itemId).delete(database);
@override
Stream<List<dynamic>> getAllItemsStream() =>
_store.query().onSnapshots(database).map(
(snapshot) => snapshot.map((item) {
logger.i('Querying the database! ${item.value}');
if (item.value.toString().contains('widgetType: Hydration')) {
logger.i('Le hydration has arrived');
return Hydration.fromJson(item.value).copyWith(id: item.key);
} else if (item.value.toString().contains('widgetType: Timer')) {
logger.i('Le timer has arrived');
return TimerItem.fromJson(item.value).copyWith(id: item.key);
} else if (item.value.toString().contains('widgetType: TODO')) {
logger.i('Le TODO has arrived');
return TasksItem.fromJson(item.value).copyWith(id: item.key);
}
}).toList(growable: false),
);
}

View file

@ -0,0 +1,53 @@
// ignore_for_file: flutter_style_todos
import 'package:flutter/foundation.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'tasks_list.freezed.dart';
part 'tasks_list.g.dart';
@freezed
class IndividualTodo with _$IndividualTodo {
const factory IndividualTodo({
required String todo,
required bool isCompleted,
required DateTime dueDate,
}) = _IndividualTodo;
factory IndividualTodo.fromJson(Map<String, Object?> json) =>
_$IndividualTodoFromJson(json);
}
@freezed
class TasksItem with _$TasksItem {
const factory TasksItem({
required String widgetType,
required String name,
required bool isExpanded,
required List<String> taskList,
required List<String> completedTaskList,
required bool isVisible,
@Default(-1) int id,
}) = _TasksItem;
factory TasksItem.fromJson(Map<String, Object?> json) =>
_$TasksItemFromJson(json);
}
extension JsonWithoutId on TasksItem {
Map<String, dynamic> toJsonWithoutId() {
final map = toJson()..remove('id');
// map['taskList'] = taskList.map((todo) => todo.toJson()).toList();
//map['completedTaskList'] =
// completedTaskList.map((todo) => todo.toJson()).toList();
return map;
}
}
/*
extension JsonWithoutID on TODO {
Map<String, dynamic> toJsonWithoutId() {
final map = toJson()..remove('id');
map['taskList'] = taskList.map((todo) => todo.toJson()).toList();
map['completedTaskList'] =
completedTaskList.map((todo) => todo.toJson()).toList();
return map;
}
}*/

View file

@ -0,0 +1,502 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'tasks_list.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
IndividualTodo _$IndividualTodoFromJson(Map<String, dynamic> json) {
return _IndividualTodo.fromJson(json);
}
/// @nodoc
mixin _$IndividualTodo {
String get todo => throw _privateConstructorUsedError;
bool get isCompleted => throw _privateConstructorUsedError;
DateTime get dueDate => throw _privateConstructorUsedError;
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$IndividualTodoCopyWith<IndividualTodo> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $IndividualTodoCopyWith<$Res> {
factory $IndividualTodoCopyWith(
IndividualTodo value, $Res Function(IndividualTodo) then) =
_$IndividualTodoCopyWithImpl<$Res, IndividualTodo>;
@useResult
$Res call({String todo, bool isCompleted, DateTime dueDate});
}
/// @nodoc
class _$IndividualTodoCopyWithImpl<$Res, $Val extends IndividualTodo>
implements $IndividualTodoCopyWith<$Res> {
_$IndividualTodoCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
@pragma('vm:prefer-inline')
@override
$Res call({
Object? todo = null,
Object? isCompleted = null,
Object? dueDate = null,
}) {
return _then(_value.copyWith(
todo: null == todo
? _value.todo
: todo // ignore: cast_nullable_to_non_nullable
as String,
isCompleted: null == isCompleted
? _value.isCompleted
: isCompleted // ignore: cast_nullable_to_non_nullable
as bool,
dueDate: null == dueDate
? _value.dueDate
: dueDate // ignore: cast_nullable_to_non_nullable
as DateTime,
) as $Val);
}
}
/// @nodoc
abstract class _$$IndividualTodoImplCopyWith<$Res>
implements $IndividualTodoCopyWith<$Res> {
factory _$$IndividualTodoImplCopyWith(_$IndividualTodoImpl value,
$Res Function(_$IndividualTodoImpl) then) =
__$$IndividualTodoImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({String todo, bool isCompleted, DateTime dueDate});
}
/// @nodoc
class __$$IndividualTodoImplCopyWithImpl<$Res>
extends _$IndividualTodoCopyWithImpl<$Res, _$IndividualTodoImpl>
implements _$$IndividualTodoImplCopyWith<$Res> {
__$$IndividualTodoImplCopyWithImpl(
_$IndividualTodoImpl _value, $Res Function(_$IndividualTodoImpl) _then)
: super(_value, _then);
@pragma('vm:prefer-inline')
@override
$Res call({
Object? todo = null,
Object? isCompleted = null,
Object? dueDate = null,
}) {
return _then(_$IndividualTodoImpl(
todo: null == todo
? _value.todo
: todo // ignore: cast_nullable_to_non_nullable
as String,
isCompleted: null == isCompleted
? _value.isCompleted
: isCompleted // ignore: cast_nullable_to_non_nullable
as bool,
dueDate: null == dueDate
? _value.dueDate
: dueDate // ignore: cast_nullable_to_non_nullable
as DateTime,
));
}
}
/// @nodoc
@JsonSerializable()
class _$IndividualTodoImpl
with DiagnosticableTreeMixin
implements _IndividualTodo {
const _$IndividualTodoImpl(
{required this.todo, required this.isCompleted, required this.dueDate});
factory _$IndividualTodoImpl.fromJson(Map<String, dynamic> json) =>
_$$IndividualTodoImplFromJson(json);
@override
final String todo;
@override
final bool isCompleted;
@override
final DateTime dueDate;
@override
String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) {
return 'IndividualTodo(todo: $todo, isCompleted: $isCompleted, dueDate: $dueDate)';
}
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties
..add(DiagnosticsProperty('type', 'IndividualTodo'))
..add(DiagnosticsProperty('todo', todo))
..add(DiagnosticsProperty('isCompleted', isCompleted))
..add(DiagnosticsProperty('dueDate', dueDate));
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$IndividualTodoImpl &&
(identical(other.todo, todo) || other.todo == todo) &&
(identical(other.isCompleted, isCompleted) ||
other.isCompleted == isCompleted) &&
(identical(other.dueDate, dueDate) || other.dueDate == dueDate));
}
@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(runtimeType, todo, isCompleted, dueDate);
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$IndividualTodoImplCopyWith<_$IndividualTodoImpl> get copyWith =>
__$$IndividualTodoImplCopyWithImpl<_$IndividualTodoImpl>(
this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$IndividualTodoImplToJson(
this,
);
}
}
abstract class _IndividualTodo implements IndividualTodo {
const factory _IndividualTodo(
{required final String todo,
required final bool isCompleted,
required final DateTime dueDate}) = _$IndividualTodoImpl;
factory _IndividualTodo.fromJson(Map<String, dynamic> json) =
_$IndividualTodoImpl.fromJson;
@override
String get todo;
@override
bool get isCompleted;
@override
DateTime get dueDate;
@override
@JsonKey(ignore: true)
_$$IndividualTodoImplCopyWith<_$IndividualTodoImpl> get copyWith =>
throw _privateConstructorUsedError;
}
TasksItem _$TasksItemFromJson(Map<String, dynamic> json) {
return _TasksItem.fromJson(json);
}
/// @nodoc
mixin _$TasksItem {
String get widgetType => throw _privateConstructorUsedError;
String get name => throw _privateConstructorUsedError;
bool get isExpanded => throw _privateConstructorUsedError;
List<String> get taskList => throw _privateConstructorUsedError;
List<String> get completedTaskList => throw _privateConstructorUsedError;
bool get isVisible => throw _privateConstructorUsedError;
int get id => throw _privateConstructorUsedError;
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$TasksItemCopyWith<TasksItem> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $TasksItemCopyWith<$Res> {
factory $TasksItemCopyWith(TasksItem value, $Res Function(TasksItem) then) =
_$TasksItemCopyWithImpl<$Res, TasksItem>;
@useResult
$Res call(
{String widgetType,
String name,
bool isExpanded,
List<String> taskList,
List<String> completedTaskList,
bool isVisible,
int id});
}
/// @nodoc
class _$TasksItemCopyWithImpl<$Res, $Val extends TasksItem>
implements $TasksItemCopyWith<$Res> {
_$TasksItemCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
@pragma('vm:prefer-inline')
@override
$Res call({
Object? widgetType = null,
Object? name = null,
Object? isExpanded = null,
Object? taskList = null,
Object? completedTaskList = null,
Object? isVisible = null,
Object? id = null,
}) {
return _then(_value.copyWith(
widgetType: null == widgetType
? _value.widgetType
: widgetType // ignore: cast_nullable_to_non_nullable
as String,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
isExpanded: null == isExpanded
? _value.isExpanded
: isExpanded // ignore: cast_nullable_to_non_nullable
as bool,
taskList: null == taskList
? _value.taskList
: taskList // ignore: cast_nullable_to_non_nullable
as List<String>,
completedTaskList: null == completedTaskList
? _value.completedTaskList
: completedTaskList // ignore: cast_nullable_to_non_nullable
as List<String>,
isVisible: null == isVisible
? _value.isVisible
: isVisible // ignore: cast_nullable_to_non_nullable
as bool,
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
) as $Val);
}
}
/// @nodoc
abstract class _$$TasksItemImplCopyWith<$Res>
implements $TasksItemCopyWith<$Res> {
factory _$$TasksItemImplCopyWith(
_$TasksItemImpl value, $Res Function(_$TasksItemImpl) then) =
__$$TasksItemImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{String widgetType,
String name,
bool isExpanded,
List<String> taskList,
List<String> completedTaskList,
bool isVisible,
int id});
}
/// @nodoc
class __$$TasksItemImplCopyWithImpl<$Res>
extends _$TasksItemCopyWithImpl<$Res, _$TasksItemImpl>
implements _$$TasksItemImplCopyWith<$Res> {
__$$TasksItemImplCopyWithImpl(
_$TasksItemImpl _value, $Res Function(_$TasksItemImpl) _then)
: super(_value, _then);
@pragma('vm:prefer-inline')
@override
$Res call({
Object? widgetType = null,
Object? name = null,
Object? isExpanded = null,
Object? taskList = null,
Object? completedTaskList = null,
Object? isVisible = null,
Object? id = null,
}) {
return _then(_$TasksItemImpl(
widgetType: null == widgetType
? _value.widgetType
: widgetType // ignore: cast_nullable_to_non_nullable
as String,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
isExpanded: null == isExpanded
? _value.isExpanded
: isExpanded // ignore: cast_nullable_to_non_nullable
as bool,
taskList: null == taskList
? _value._taskList
: taskList // ignore: cast_nullable_to_non_nullable
as List<String>,
completedTaskList: null == completedTaskList
? _value._completedTaskList
: completedTaskList // ignore: cast_nullable_to_non_nullable
as List<String>,
isVisible: null == isVisible
? _value.isVisible
: isVisible // ignore: cast_nullable_to_non_nullable
as bool,
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
));
}
}
/// @nodoc
@JsonSerializable()
class _$TasksItemImpl with DiagnosticableTreeMixin implements _TasksItem {
const _$TasksItemImpl(
{required this.widgetType,
required this.name,
required this.isExpanded,
required final List<String> taskList,
required final List<String> completedTaskList,
required this.isVisible,
this.id = -1})
: _taskList = taskList,
_completedTaskList = completedTaskList;
factory _$TasksItemImpl.fromJson(Map<String, dynamic> json) =>
_$$TasksItemImplFromJson(json);
@override
final String widgetType;
@override
final String name;
@override
final bool isExpanded;
final List<String> _taskList;
@override
List<String> get taskList {
if (_taskList is EqualUnmodifiableListView) return _taskList;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_taskList);
}
final List<String> _completedTaskList;
@override
List<String> get completedTaskList {
if (_completedTaskList is EqualUnmodifiableListView)
return _completedTaskList;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_completedTaskList);
}
@override
final bool isVisible;
@override
@JsonKey()
final int id;
@override
String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) {
return 'TasksItem(widgetType: $widgetType, name: $name, isExpanded: $isExpanded, taskList: $taskList, completedTaskList: $completedTaskList, isVisible: $isVisible, id: $id)';
}
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties
..add(DiagnosticsProperty('type', 'TasksItem'))
..add(DiagnosticsProperty('widgetType', widgetType))
..add(DiagnosticsProperty('name', name))
..add(DiagnosticsProperty('isExpanded', isExpanded))
..add(DiagnosticsProperty('taskList', taskList))
..add(DiagnosticsProperty('completedTaskList', completedTaskList))
..add(DiagnosticsProperty('isVisible', isVisible))
..add(DiagnosticsProperty('id', id));
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$TasksItemImpl &&
(identical(other.widgetType, widgetType) ||
other.widgetType == widgetType) &&
(identical(other.name, name) || other.name == name) &&
(identical(other.isExpanded, isExpanded) ||
other.isExpanded == isExpanded) &&
const DeepCollectionEquality().equals(other._taskList, _taskList) &&
const DeepCollectionEquality()
.equals(other._completedTaskList, _completedTaskList) &&
(identical(other.isVisible, isVisible) ||
other.isVisible == isVisible) &&
(identical(other.id, id) || other.id == id));
}
@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(
runtimeType,
widgetType,
name,
isExpanded,
const DeepCollectionEquality().hash(_taskList),
const DeepCollectionEquality().hash(_completedTaskList),
isVisible,
id);
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$TasksItemImplCopyWith<_$TasksItemImpl> get copyWith =>
__$$TasksItemImplCopyWithImpl<_$TasksItemImpl>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$TasksItemImplToJson(
this,
);
}
}
abstract class _TasksItem implements TasksItem {
const factory _TasksItem(
{required final String widgetType,
required final String name,
required final bool isExpanded,
required final List<String> taskList,
required final List<String> completedTaskList,
required final bool isVisible,
final int id}) = _$TasksItemImpl;
factory _TasksItem.fromJson(Map<String, dynamic> json) =
_$TasksItemImpl.fromJson;
@override
String get widgetType;
@override
String get name;
@override
bool get isExpanded;
@override
List<String> get taskList;
@override
List<String> get completedTaskList;
@override
bool get isVisible;
@override
int get id;
@override
@JsonKey(ignore: true)
_$$TasksItemImplCopyWith<_$TasksItemImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View file

@ -0,0 +1,47 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'tasks_list.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_$IndividualTodoImpl _$$IndividualTodoImplFromJson(Map<String, dynamic> json) =>
_$IndividualTodoImpl(
todo: json['todo'] as String,
isCompleted: json['isCompleted'] as bool,
dueDate: DateTime.parse(json['dueDate'] as String),
);
Map<String, dynamic> _$$IndividualTodoImplToJson(
_$IndividualTodoImpl instance) =>
<String, dynamic>{
'todo': instance.todo,
'isCompleted': instance.isCompleted,
'dueDate': instance.dueDate.toIso8601String(),
};
_$TasksItemImpl _$$TasksItemImplFromJson(Map<String, dynamic> json) =>
_$TasksItemImpl(
widgetType: json['widgetType'] as String,
name: json['name'] as String,
isExpanded: json['isExpanded'] as bool,
taskList:
(json['taskList'] as List<dynamic>).map((e) => e as String).toList(),
completedTaskList: (json['completedTaskList'] as List<dynamic>)
.map((e) => e as String)
.toList(),
isVisible: json['isVisible'] as bool,
id: (json['id'] as num?)?.toInt() ?? -1,
);
Map<String, dynamic> _$$TasksItemImplToJson(_$TasksItemImpl instance) =>
<String, dynamic>{
'widgetType': instance.widgetType,
'name': instance.name,
'isExpanded': instance.isExpanded,
'taskList': instance.taskList,
'completedTaskList': instance.completedTaskList,
'isVisible': instance.isVisible,
'id': instance.id,
};

View file

@ -0,0 +1,50 @@
import 'package:flutter/foundation.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'timer.freezed.dart';
part 'timer.g.dart';
@freezed
class TimerItem with _$TimerItem {
const factory TimerItem({
required String widgetType,
required String name,
required int current,
required int goal,
required bool isExpanded,
required bool isVisible,
required String createdOn,
required String completedOn,
required String state,
@Default(-1) int id,
}) = _TimerItem;
factory TimerItem.fromJson(Map<String, Object?> json) =>
_$TimerItemFromJson(json);
}
extension JsonWithoutId on TimerItem {
Map<String, dynamic> toJsonWithoutId() {
final map = toJson()..remove('id');
return map;
}
}
/*
@freezed
class Student with _$Student {
const factory Student({
required String name,
int? id,
}) = _Student;
factory Student.fromJson(Map<String, Object?> json) =>
_$StudentFromJson(json);
}
extension JsonWithoutId on Student {
Map<String, dynamic> toJsonWithoutId() {
final map = toJson()..remove('id');
return map;
}
}
*/

View file

@ -0,0 +1,358 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'timer.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
TimerItem _$TimerItemFromJson(Map<String, dynamic> json) {
return _TimerItem.fromJson(json);
}
/// @nodoc
mixin _$TimerItem {
String get widgetType => throw _privateConstructorUsedError;
String get name => throw _privateConstructorUsedError;
int get current => throw _privateConstructorUsedError;
int get goal => throw _privateConstructorUsedError;
bool get isExpanded => throw _privateConstructorUsedError;
bool get isVisible => throw _privateConstructorUsedError;
String get createdOn => throw _privateConstructorUsedError;
String get completedOn => throw _privateConstructorUsedError;
String get state => throw _privateConstructorUsedError;
int get id => throw _privateConstructorUsedError;
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$TimerItemCopyWith<TimerItem> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $TimerItemCopyWith<$Res> {
factory $TimerItemCopyWith(TimerItem value, $Res Function(TimerItem) then) =
_$TimerItemCopyWithImpl<$Res, TimerItem>;
@useResult
$Res call(
{String widgetType,
String name,
int current,
int goal,
bool isExpanded,
bool isVisible,
String createdOn,
String completedOn,
String state,
int id});
}
/// @nodoc
class _$TimerItemCopyWithImpl<$Res, $Val extends TimerItem>
implements $TimerItemCopyWith<$Res> {
_$TimerItemCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
@pragma('vm:prefer-inline')
@override
$Res call({
Object? widgetType = null,
Object? name = null,
Object? current = null,
Object? goal = null,
Object? isExpanded = null,
Object? isVisible = null,
Object? createdOn = null,
Object? completedOn = null,
Object? state = null,
Object? id = null,
}) {
return _then(_value.copyWith(
widgetType: null == widgetType
? _value.widgetType
: widgetType // ignore: cast_nullable_to_non_nullable
as String,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
current: null == current
? _value.current
: current // ignore: cast_nullable_to_non_nullable
as int,
goal: null == goal
? _value.goal
: goal // ignore: cast_nullable_to_non_nullable
as int,
isExpanded: null == isExpanded
? _value.isExpanded
: isExpanded // ignore: cast_nullable_to_non_nullable
as bool,
isVisible: null == isVisible
? _value.isVisible
: isVisible // ignore: cast_nullable_to_non_nullable
as bool,
createdOn: null == createdOn
? _value.createdOn
: createdOn // ignore: cast_nullable_to_non_nullable
as String,
completedOn: null == completedOn
? _value.completedOn
: completedOn // ignore: cast_nullable_to_non_nullable
as String,
state: null == state
? _value.state
: state // ignore: cast_nullable_to_non_nullable
as String,
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
) as $Val);
}
}
/// @nodoc
abstract class _$$TimerItemImplCopyWith<$Res>
implements $TimerItemCopyWith<$Res> {
factory _$$TimerItemImplCopyWith(
_$TimerItemImpl value, $Res Function(_$TimerItemImpl) then) =
__$$TimerItemImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{String widgetType,
String name,
int current,
int goal,
bool isExpanded,
bool isVisible,
String createdOn,
String completedOn,
String state,
int id});
}
/// @nodoc
class __$$TimerItemImplCopyWithImpl<$Res>
extends _$TimerItemCopyWithImpl<$Res, _$TimerItemImpl>
implements _$$TimerItemImplCopyWith<$Res> {
__$$TimerItemImplCopyWithImpl(
_$TimerItemImpl _value, $Res Function(_$TimerItemImpl) _then)
: super(_value, _then);
@pragma('vm:prefer-inline')
@override
$Res call({
Object? widgetType = null,
Object? name = null,
Object? current = null,
Object? goal = null,
Object? isExpanded = null,
Object? isVisible = null,
Object? createdOn = null,
Object? completedOn = null,
Object? state = null,
Object? id = null,
}) {
return _then(_$TimerItemImpl(
widgetType: null == widgetType
? _value.widgetType
: widgetType // ignore: cast_nullable_to_non_nullable
as String,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
current: null == current
? _value.current
: current // ignore: cast_nullable_to_non_nullable
as int,
goal: null == goal
? _value.goal
: goal // ignore: cast_nullable_to_non_nullable
as int,
isExpanded: null == isExpanded
? _value.isExpanded
: isExpanded // ignore: cast_nullable_to_non_nullable
as bool,
isVisible: null == isVisible
? _value.isVisible
: isVisible // ignore: cast_nullable_to_non_nullable
as bool,
createdOn: null == createdOn
? _value.createdOn
: createdOn // ignore: cast_nullable_to_non_nullable
as String,
completedOn: null == completedOn
? _value.completedOn
: completedOn // ignore: cast_nullable_to_non_nullable
as String,
state: null == state
? _value.state
: state // ignore: cast_nullable_to_non_nullable
as String,
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
));
}
}
/// @nodoc
@JsonSerializable()
class _$TimerItemImpl with DiagnosticableTreeMixin implements _TimerItem {
const _$TimerItemImpl(
{required this.widgetType,
required this.name,
required this.current,
required this.goal,
required this.isExpanded,
required this.isVisible,
required this.createdOn,
required this.completedOn,
required this.state,
this.id = -1});
factory _$TimerItemImpl.fromJson(Map<String, dynamic> json) =>
_$$TimerItemImplFromJson(json);
@override
final String widgetType;
@override
final String name;
@override
final int current;
@override
final int goal;
@override
final bool isExpanded;
@override
final bool isVisible;
@override
final String createdOn;
@override
final String completedOn;
@override
final String state;
@override
@JsonKey()
final int id;
@override
String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) {
return 'TimerItem(widgetType: $widgetType, name: $name, current: $current, goal: $goal, isExpanded: $isExpanded, isVisible: $isVisible, createdOn: $createdOn, completedOn: $completedOn, state: $state, id: $id)';
}
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties
..add(DiagnosticsProperty('type', 'TimerItem'))
..add(DiagnosticsProperty('widgetType', widgetType))
..add(DiagnosticsProperty('name', name))
..add(DiagnosticsProperty('current', current))
..add(DiagnosticsProperty('goal', goal))
..add(DiagnosticsProperty('isExpanded', isExpanded))
..add(DiagnosticsProperty('isVisible', isVisible))
..add(DiagnosticsProperty('createdOn', createdOn))
..add(DiagnosticsProperty('completedOn', completedOn))
..add(DiagnosticsProperty('state', state))
..add(DiagnosticsProperty('id', id));
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$TimerItemImpl &&
(identical(other.widgetType, widgetType) ||
other.widgetType == widgetType) &&
(identical(other.name, name) || other.name == name) &&
(identical(other.current, current) || other.current == current) &&
(identical(other.goal, goal) || other.goal == goal) &&
(identical(other.isExpanded, isExpanded) ||
other.isExpanded == isExpanded) &&
(identical(other.isVisible, isVisible) ||
other.isVisible == isVisible) &&
(identical(other.createdOn, createdOn) ||
other.createdOn == createdOn) &&
(identical(other.completedOn, completedOn) ||
other.completedOn == completedOn) &&
(identical(other.state, state) || other.state == state) &&
(identical(other.id, id) || other.id == id));
}
@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(runtimeType, widgetType, name, current, goal,
isExpanded, isVisible, createdOn, completedOn, state, id);
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$TimerItemImplCopyWith<_$TimerItemImpl> get copyWith =>
__$$TimerItemImplCopyWithImpl<_$TimerItemImpl>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$TimerItemImplToJson(
this,
);
}
}
abstract class _TimerItem implements TimerItem {
const factory _TimerItem(
{required final String widgetType,
required final String name,
required final int current,
required final int goal,
required final bool isExpanded,
required final bool isVisible,
required final String createdOn,
required final String completedOn,
required final String state,
final int id}) = _$TimerItemImpl;
factory _TimerItem.fromJson(Map<String, dynamic> json) =
_$TimerItemImpl.fromJson;
@override
String get widgetType;
@override
String get name;
@override
int get current;
@override
int get goal;
@override
bool get isExpanded;
@override
bool get isVisible;
@override
String get createdOn;
@override
String get completedOn;
@override
String get state;
@override
int get id;
@override
@JsonKey(ignore: true)
_$$TimerItemImplCopyWith<_$TimerItemImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View file

@ -0,0 +1,35 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'timer.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_$TimerItemImpl _$$TimerItemImplFromJson(Map<String, dynamic> json) =>
_$TimerItemImpl(
widgetType: json['widgetType'] as String,
name: json['name'] as String,
current: (json['current'] as num).toInt(),
goal: (json['goal'] as num).toInt(),
isExpanded: json['isExpanded'] as bool,
isVisible: json['isVisible'] as bool,
createdOn: json['createdOn'] as String,
completedOn: json['completedOn'] as String,
state: json['state'] as String,
id: (json['id'] as num?)?.toInt() ?? -1,
);
Map<String, dynamic> _$$TimerItemImplToJson(_$TimerItemImpl instance) =>
<String, dynamic>{
'widgetType': instance.widgetType,
'name': instance.name,
'current': instance.current,
'goal': instance.goal,
'isExpanded': instance.isExpanded,
'isVisible': instance.isVisible,
'createdOn': instance.createdOn,
'completedOn': instance.completedOn,
'state': instance.state,
'id': instance.id,
};