Compare commits

..

6 Commits

41 changed files with 3241 additions and 1431 deletions

1
.gitignore vendored
View File

@@ -52,3 +52,4 @@ lib/i18n/
# Build artifacts # Build artifacts
release-*/ release-*/
android/build

View File

@@ -1,11 +1,11 @@
# This file tracks properties of this Flutter project. # This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc. # Used by Flutter tool to assess capabilities and perform upgrades etc.
# #
# This file should be version controlled. # This file should be version controlled and should not be manually edited.
version: version:
revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 revision: "3b62efc2a3da49882f43c372e0bc53daef7295a6"
channel: stable channel: "stable"
project_type: app project_type: app
@@ -13,26 +13,14 @@ project_type: app
migration: migration:
platforms: platforms:
- platform: root - platform: root
create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 create_revision: 3b62efc2a3da49882f43c372e0bc53daef7295a6
base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 base_revision: 3b62efc2a3da49882f43c372e0bc53daef7295a6
- platform: android - platform: android
create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 create_revision: 3b62efc2a3da49882f43c372e0bc53daef7295a6
base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 base_revision: 3b62efc2a3da49882f43c372e0bc53daef7295a6
- platform: ios
create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
- platform: linux - platform: linux
create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 create_revision: 3b62efc2a3da49882f43c372e0bc53daef7295a6
base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 base_revision: 3b62efc2a3da49882f43c372e0bc53daef7295a6
- platform: macos
create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
- platform: web
create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
- platform: windows
create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57
# User provided section # User provided section

View File

@@ -1,61 +0,0 @@
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
}
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
android {
compileSdkVersion 34
ndkVersion flutter.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
applicationId "me.polynom.anitrack"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
signingConfig null
}
}
}
flutter {
source '../..'
}

View File

@@ -0,0 +1,43 @@
plugins {
id("com.android.application")
id("kotlin-android")
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id("dev.flutter.flutter-gradle-plugin")
}
android {
namespace = "me.polynom.anitrack"
compileSdk = flutter.compileSdkVersion
ndkVersion = flutter.ndkVersion
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "me.polynom.anitrack"
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
minSdk = flutter.minSdkVersion
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
}
buildTypes {
release {
// Externally signed using a security key
signingConfig = null
}
}
}
flutter {
source = "../.."
}

View File

@@ -1,18 +0,0 @@
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
tasks.register("clean", Delete) {
delete rootProject.buildDir
}

24
android/build.gradle.kts Normal file
View File

@@ -0,0 +1,24 @@
allprojects {
repositories {
google()
mavenCentral()
}
}
val newBuildDir: Directory =
rootProject.layout.buildDirectory
.dir("../../build")
.get()
rootProject.layout.buildDirectory.value(newBuildDir)
subprojects {
val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name)
project.layout.buildDirectory.value(newSubprojectBuildDir)
}
subprojects {
project.evaluationDependsOn(":app")
}
tasks.register<Delete>("clean") {
delete(rootProject.layout.buildDirectory)
}

View File

@@ -1,3 +1,4 @@
org.gradle.jvmargs=-Xmx1536M org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true android.useAndroidX=true
android.enableJetifier=true android.enableJetifier=true
android.newDsl=false

View File

@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-all.zip

View File

@@ -1,25 +0,0 @@
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}()
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
}
include ":app"

View File

@@ -0,0 +1,26 @@
pluginManagement {
val flutterSdkPath =
run {
val properties = java.util.Properties()
file("local.properties").inputStream().use { properties.load(it) }
val flutterSdkPath = properties.getProperty("flutter.sdk")
require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" }
flutterSdkPath
}
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
plugins {
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
id("com.android.application") version "8.11.1" apply false
id("org.jetbrains.kotlin.android") version "2.2.20" apply false
}
include(":app")

View File

@@ -17,7 +17,7 @@ class BoolConverter implements JsonConverter<bool, int> {
/// Data about a tracked anime /// Data about a tracked anime
@freezed @freezed
class AnimeTrackingData with _$AnimeTrackingData, TrackingMedium { abstract class AnimeTrackingData with _$AnimeTrackingData, TrackingMedium {
factory AnimeTrackingData( factory AnimeTrackingData(
/// The ID of the anime /// The ID of the anime
String id, String id,
@@ -44,6 +44,8 @@ class AnimeTrackingData with _$AnimeTrackingData, TrackingMedium {
String? broadcastDay, String? broadcastDay,
) = _AnimeTrackingData; ) = _AnimeTrackingData;
AnimeTrackingData._();
/// JSON /// JSON
factory AnimeTrackingData.fromJson(Map<String, dynamic> json) => factory AnimeTrackingData.fromJson(Map<String, dynamic> json) =>
_$AnimeTrackingDataFromJson(json); _$AnimeTrackingDataFromJson(json);

View File

@@ -1,5 +1,5 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND // GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// ignore_for_file: type=lint // 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 // 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
@@ -9,138 +9,83 @@ part of 'anime.dart';
// FreezedGenerator // FreezedGenerator
// ************************************************************************** // **************************************************************************
// dart format off
T _$identity<T>(T value) => value; 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');
AnimeTrackingData _$AnimeTrackingDataFromJson(Map<String, dynamic> json) {
return _AnimeTrackingData.fromJson(json);
}
/// @nodoc /// @nodoc
mixin _$AnimeTrackingData { mixin _$AnimeTrackingData {
/// The ID of the anime /// The ID of the anime
String get id => throw _privateConstructorUsedError; String get id;
/// The state of the anime /// The state of the anime
@MediumTrackingStateConverter() @MediumTrackingStateConverter()
MediumTrackingState get state => throw _privateConstructorUsedError; MediumTrackingState get state;
/// The title of the anime /// The title of the anime
String get title => throw _privateConstructorUsedError; String get title;
/// Episodes in total. /// Episodes in total.
int get episodesWatched => throw _privateConstructorUsedError; int get episodesWatched;
/// Episodes watched. /// Episodes watched.
int? get episodesTotal => throw _privateConstructorUsedError; int? get episodesTotal;
/// URL to the thumbnail/cover art for the anime. /// URL to the thumbnail/cover art for the anime.
String get thumbnailUrl => throw _privateConstructorUsedError; String get thumbnailUrl;
/// Flag whether the anime is airing /// Flag whether the anime is airing
@BoolConverter() @BoolConverter()
bool get airing => throw _privateConstructorUsedError; bool get airing;
/// The day of the week the anime is airing /// The day of the week the anime is airing
String? get broadcastDay => throw _privateConstructorUsedError; String? get broadcastDay;
/// Serializes this AnimeTrackingData to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of AnimeTrackingData /// Create a copy of AnimeTrackingData
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
$AnimeTrackingDataCopyWith<AnimeTrackingData> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $AnimeTrackingDataCopyWith<$Res> {
factory $AnimeTrackingDataCopyWith(
AnimeTrackingData value, $Res Function(AnimeTrackingData) then) =
_$AnimeTrackingDataCopyWithImpl<$Res, AnimeTrackingData>;
@useResult
$Res call(
{String id,
@MediumTrackingStateConverter() MediumTrackingState state,
String title,
int episodesWatched,
int? episodesTotal,
String thumbnailUrl,
@BoolConverter() bool airing,
String? broadcastDay});
}
/// @nodoc
class _$AnimeTrackingDataCopyWithImpl<$Res, $Val extends AnimeTrackingData>
implements $AnimeTrackingDataCopyWith<$Res> {
_$AnimeTrackingDataCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of AnimeTrackingData
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
$AnimeTrackingDataCopyWith<AnimeTrackingData> get copyWith =>
_$AnimeTrackingDataCopyWithImpl<AnimeTrackingData>(
this as AnimeTrackingData, _$identity);
/// Serializes this AnimeTrackingData to a JSON map.
Map<String, dynamic> toJson();
@override @override
$Res call({ bool operator ==(Object other) {
Object? id = null, return identical(this, other) ||
Object? state = null, (other.runtimeType == runtimeType &&
Object? title = null, other is AnimeTrackingData &&
Object? episodesWatched = null, (identical(other.id, id) || other.id == id) &&
Object? episodesTotal = freezed, (identical(other.state, state) || other.state == state) &&
Object? thumbnailUrl = null, (identical(other.title, title) || other.title == title) &&
Object? airing = null, (identical(other.episodesWatched, episodesWatched) ||
Object? broadcastDay = freezed, other.episodesWatched == episodesWatched) &&
}) { (identical(other.episodesTotal, episodesTotal) ||
return _then(_value.copyWith( other.episodesTotal == episodesTotal) &&
id: null == id (identical(other.thumbnailUrl, thumbnailUrl) ||
? _value.id other.thumbnailUrl == thumbnailUrl) &&
: id // ignore: cast_nullable_to_non_nullable (identical(other.airing, airing) || other.airing == airing) &&
as String, (identical(other.broadcastDay, broadcastDay) ||
state: null == state other.broadcastDay == broadcastDay));
? _value.state }
: state // ignore: cast_nullable_to_non_nullable
as MediumTrackingState, @JsonKey(includeFromJson: false, includeToJson: false)
title: null == title @override
? _value.title int get hashCode => Object.hash(runtimeType, id, state, title,
: title // ignore: cast_nullable_to_non_nullable episodesWatched, episodesTotal, thumbnailUrl, airing, broadcastDay);
as String,
episodesWatched: null == episodesWatched @override
? _value.episodesWatched String toString() {
: episodesWatched // ignore: cast_nullable_to_non_nullable return 'AnimeTrackingData(id: $id, state: $state, title: $title, episodesWatched: $episodesWatched, episodesTotal: $episodesTotal, thumbnailUrl: $thumbnailUrl, airing: $airing, broadcastDay: $broadcastDay)';
as int,
episodesTotal: freezed == episodesTotal
? _value.episodesTotal
: episodesTotal // ignore: cast_nullable_to_non_nullable
as int?,
thumbnailUrl: null == thumbnailUrl
? _value.thumbnailUrl
: thumbnailUrl // ignore: cast_nullable_to_non_nullable
as String,
airing: null == airing
? _value.airing
: airing // ignore: cast_nullable_to_non_nullable
as bool,
broadcastDay: freezed == broadcastDay
? _value.broadcastDay
: broadcastDay // ignore: cast_nullable_to_non_nullable
as String?,
) as $Val);
} }
} }
/// @nodoc /// @nodoc
abstract class _$$AnimeTrackingDataImplCopyWith<$Res> abstract mixin class $AnimeTrackingDataCopyWith<$Res> {
implements $AnimeTrackingDataCopyWith<$Res> { factory $AnimeTrackingDataCopyWith(
factory _$$AnimeTrackingDataImplCopyWith(_$AnimeTrackingDataImpl value, AnimeTrackingData value, $Res Function(AnimeTrackingData) _then) =
$Res Function(_$AnimeTrackingDataImpl) then) = _$AnimeTrackingDataCopyWithImpl;
__$$AnimeTrackingDataImplCopyWithImpl<$Res>;
@override
@useResult @useResult
$Res call( $Res call(
{String id, {String id,
@@ -154,12 +99,12 @@ abstract class _$$AnimeTrackingDataImplCopyWith<$Res>
} }
/// @nodoc /// @nodoc
class __$$AnimeTrackingDataImplCopyWithImpl<$Res> class _$AnimeTrackingDataCopyWithImpl<$Res>
extends _$AnimeTrackingDataCopyWithImpl<$Res, _$AnimeTrackingDataImpl> implements $AnimeTrackingDataCopyWith<$Res> {
implements _$$AnimeTrackingDataImplCopyWith<$Res> { _$AnimeTrackingDataCopyWithImpl(this._self, this._then);
__$$AnimeTrackingDataImplCopyWithImpl(_$AnimeTrackingDataImpl _value,
$Res Function(_$AnimeTrackingDataImpl) _then) final AnimeTrackingData _self;
: super(_value, _then); final $Res Function(AnimeTrackingData) _then;
/// Create a copy of AnimeTrackingData /// Create a copy of AnimeTrackingData
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@@ -175,47 +120,255 @@ class __$$AnimeTrackingDataImplCopyWithImpl<$Res>
Object? airing = null, Object? airing = null,
Object? broadcastDay = freezed, Object? broadcastDay = freezed,
}) { }) {
return _then(_$AnimeTrackingDataImpl( return _then(_self.copyWith(
null == id id: null == id
? _value.id ? _self.id
: id // ignore: cast_nullable_to_non_nullable : id // ignore: cast_nullable_to_non_nullable
as String, as String,
null == state state: null == state
? _value.state ? _self.state
: state // ignore: cast_nullable_to_non_nullable : state // ignore: cast_nullable_to_non_nullable
as MediumTrackingState, as MediumTrackingState,
null == title title: null == title
? _value.title ? _self.title
: title // ignore: cast_nullable_to_non_nullable : title // ignore: cast_nullable_to_non_nullable
as String, as String,
null == episodesWatched episodesWatched: null == episodesWatched
? _value.episodesWatched ? _self.episodesWatched
: episodesWatched // ignore: cast_nullable_to_non_nullable : episodesWatched // ignore: cast_nullable_to_non_nullable
as int, as int,
freezed == episodesTotal episodesTotal: freezed == episodesTotal
? _value.episodesTotal ? _self.episodesTotal
: episodesTotal // ignore: cast_nullable_to_non_nullable : episodesTotal // ignore: cast_nullable_to_non_nullable
as int?, as int?,
null == thumbnailUrl thumbnailUrl: null == thumbnailUrl
? _value.thumbnailUrl ? _self.thumbnailUrl
: thumbnailUrl // ignore: cast_nullable_to_non_nullable : thumbnailUrl // ignore: cast_nullable_to_non_nullable
as String, as String,
null == airing airing: null == airing
? _value.airing ? _self.airing
: airing // ignore: cast_nullable_to_non_nullable : airing // ignore: cast_nullable_to_non_nullable
as bool, as bool,
freezed == broadcastDay broadcastDay: freezed == broadcastDay
? _value.broadcastDay ? _self.broadcastDay
: broadcastDay // ignore: cast_nullable_to_non_nullable : broadcastDay // ignore: cast_nullable_to_non_nullable
as String?, as String?,
)); ));
} }
} }
/// Adds pattern-matching-related methods to [AnimeTrackingData].
extension AnimeTrackingDataPatterns on AnimeTrackingData {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>(
TResult Function(_AnimeTrackingData value)? $default, {
required TResult orElse(),
}) {
final _that = this;
switch (_that) {
case _AnimeTrackingData() when $default != null:
return $default(_that);
case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs
TResult map<TResult extends Object?>(
TResult Function(_AnimeTrackingData value) $default,
) {
final _that = this;
switch (_that) {
case _AnimeTrackingData():
return $default(_that);
case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>(
TResult? Function(_AnimeTrackingData value)? $default,
) {
final _that = this;
switch (_that) {
case _AnimeTrackingData() when $default != null:
return $default(_that);
case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
TResult Function(
String id,
@MediumTrackingStateConverter() MediumTrackingState state,
String title,
int episodesWatched,
int? episodesTotal,
String thumbnailUrl,
@BoolConverter() bool airing,
String? broadcastDay)?
$default, {
required TResult orElse(),
}) {
final _that = this;
switch (_that) {
case _AnimeTrackingData() when $default != null:
return $default(
_that.id,
_that.state,
_that.title,
_that.episodesWatched,
_that.episodesTotal,
_that.thumbnailUrl,
_that.airing,
_that.broadcastDay);
case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs
TResult when<TResult extends Object?>(
TResult Function(
String id,
@MediumTrackingStateConverter() MediumTrackingState state,
String title,
int episodesWatched,
int? episodesTotal,
String thumbnailUrl,
@BoolConverter() bool airing,
String? broadcastDay)
$default,
) {
final _that = this;
switch (_that) {
case _AnimeTrackingData():
return $default(
_that.id,
_that.state,
_that.title,
_that.episodesWatched,
_that.episodesTotal,
_that.thumbnailUrl,
_that.airing,
_that.broadcastDay);
case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>(
TResult? Function(
String id,
@MediumTrackingStateConverter() MediumTrackingState state,
String title,
int episodesWatched,
int? episodesTotal,
String thumbnailUrl,
@BoolConverter() bool airing,
String? broadcastDay)?
$default,
) {
final _that = this;
switch (_that) {
case _AnimeTrackingData() when $default != null:
return $default(
_that.id,
_that.state,
_that.title,
_that.episodesWatched,
_that.episodesTotal,
_that.thumbnailUrl,
_that.airing,
_that.broadcastDay);
case _:
return null;
}
}
}
/// @nodoc /// @nodoc
@JsonSerializable() @JsonSerializable()
class _$AnimeTrackingDataImpl implements _AnimeTrackingData { class _AnimeTrackingData extends AnimeTrackingData {
_$AnimeTrackingDataImpl( _AnimeTrackingData(
this.id, this.id,
@MediumTrackingStateConverter() this.state, @MediumTrackingStateConverter() this.state,
this.title, this.title,
@@ -223,10 +376,10 @@ class _$AnimeTrackingDataImpl implements _AnimeTrackingData {
this.episodesTotal, this.episodesTotal,
this.thumbnailUrl, this.thumbnailUrl,
@BoolConverter() this.airing, @BoolConverter() this.airing,
this.broadcastDay); this.broadcastDay)
: super._();
factory _$AnimeTrackingDataImpl.fromJson(Map<String, dynamic> json) => factory _AnimeTrackingData.fromJson(Map<String, dynamic> json) =>
_$$AnimeTrackingDataImplFromJson(json); _$AnimeTrackingDataFromJson(json);
/// The ID of the anime /// The ID of the anime
@override @override
@@ -262,16 +415,26 @@ class _$AnimeTrackingDataImpl implements _AnimeTrackingData {
@override @override
final String? broadcastDay; final String? broadcastDay;
/// Create a copy of AnimeTrackingData
/// with the given fields replaced by the non-null parameter values.
@override @override
String toString() { @JsonKey(includeFromJson: false, includeToJson: false)
return 'AnimeTrackingData(id: $id, state: $state, title: $title, episodesWatched: $episodesWatched, episodesTotal: $episodesTotal, thumbnailUrl: $thumbnailUrl, airing: $airing, broadcastDay: $broadcastDay)'; @pragma('vm:prefer-inline')
_$AnimeTrackingDataCopyWith<_AnimeTrackingData> get copyWith =>
__$AnimeTrackingDataCopyWithImpl<_AnimeTrackingData>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$AnimeTrackingDataToJson(
this,
);
} }
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
return identical(this, other) || return identical(this, other) ||
(other.runtimeType == runtimeType && (other.runtimeType == runtimeType &&
other is _$AnimeTrackingDataImpl && other is _AnimeTrackingData &&
(identical(other.id, id) || other.id == id) && (identical(other.id, id) || other.id == id) &&
(identical(other.state, state) || other.state == state) && (identical(other.state, state) || other.state == state) &&
(identical(other.title, title) || other.title == title) && (identical(other.title, title) || other.title == title) &&
@@ -291,75 +454,88 @@ class _$AnimeTrackingDataImpl implements _AnimeTrackingData {
int get hashCode => Object.hash(runtimeType, id, state, title, int get hashCode => Object.hash(runtimeType, id, state, title,
episodesWatched, episodesTotal, thumbnailUrl, airing, broadcastDay); episodesWatched, episodesTotal, thumbnailUrl, airing, broadcastDay);
/// Create a copy of AnimeTrackingData
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override @override
@pragma('vm:prefer-inline') String toString() {
_$$AnimeTrackingDataImplCopyWith<_$AnimeTrackingDataImpl> get copyWith => return 'AnimeTrackingData(id: $id, state: $state, title: $title, episodesWatched: $episodesWatched, episodesTotal: $episodesTotal, thumbnailUrl: $thumbnailUrl, airing: $airing, broadcastDay: $broadcastDay)';
__$$AnimeTrackingDataImplCopyWithImpl<_$AnimeTrackingDataImpl>(
this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$AnimeTrackingDataImplToJson(
this,
);
} }
} }
abstract class _AnimeTrackingData implements AnimeTrackingData { /// @nodoc
factory _AnimeTrackingData( abstract mixin class _$AnimeTrackingDataCopyWith<$Res>
final String id, implements $AnimeTrackingDataCopyWith<$Res> {
@MediumTrackingStateConverter() final MediumTrackingState state, factory _$AnimeTrackingDataCopyWith(
final String title, _AnimeTrackingData value, $Res Function(_AnimeTrackingData) _then) =
final int episodesWatched, __$AnimeTrackingDataCopyWithImpl;
final int? episodesTotal,
final String thumbnailUrl,
@BoolConverter() final bool airing,
final String? broadcastDay) = _$AnimeTrackingDataImpl;
factory _AnimeTrackingData.fromJson(Map<String, dynamic> json) =
_$AnimeTrackingDataImpl.fromJson;
/// The ID of the anime
@override @override
String get id; @useResult
$Res call(
{String id,
@MediumTrackingStateConverter() MediumTrackingState state,
String title,
int episodesWatched,
int? episodesTotal,
String thumbnailUrl,
@BoolConverter() bool airing,
String? broadcastDay});
}
/// The state of the anime /// @nodoc
@override class __$AnimeTrackingDataCopyWithImpl<$Res>
@MediumTrackingStateConverter() implements _$AnimeTrackingDataCopyWith<$Res> {
MediumTrackingState get state; __$AnimeTrackingDataCopyWithImpl(this._self, this._then);
/// The title of the anime final _AnimeTrackingData _self;
@override final $Res Function(_AnimeTrackingData) _then;
String get title;
/// Episodes in total.
@override
int get episodesWatched;
/// Episodes watched.
@override
int? get episodesTotal;
/// URL to the thumbnail/cover art for the anime.
@override
String get thumbnailUrl;
/// Flag whether the anime is airing
@override
@BoolConverter()
bool get airing;
/// The day of the week the anime is airing
@override
String? get broadcastDay;
/// Create a copy of AnimeTrackingData /// Create a copy of AnimeTrackingData
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@override @override
@JsonKey(includeFromJson: false, includeToJson: false) @pragma('vm:prefer-inline')
_$$AnimeTrackingDataImplCopyWith<_$AnimeTrackingDataImpl> get copyWith => $Res call({
throw _privateConstructorUsedError; Object? id = null,
Object? state = null,
Object? title = null,
Object? episodesWatched = null,
Object? episodesTotal = freezed,
Object? thumbnailUrl = null,
Object? airing = null,
Object? broadcastDay = freezed,
}) {
return _then(_AnimeTrackingData(
null == id
? _self.id
: id // ignore: cast_nullable_to_non_nullable
as String,
null == state
? _self.state
: state // ignore: cast_nullable_to_non_nullable
as MediumTrackingState,
null == title
? _self.title
: title // ignore: cast_nullable_to_non_nullable
as String,
null == episodesWatched
? _self.episodesWatched
: episodesWatched // ignore: cast_nullable_to_non_nullable
as int,
freezed == episodesTotal
? _self.episodesTotal
: episodesTotal // ignore: cast_nullable_to_non_nullable
as int?,
null == thumbnailUrl
? _self.thumbnailUrl
: thumbnailUrl // ignore: cast_nullable_to_non_nullable
as String,
null == airing
? _self.airing
: airing // ignore: cast_nullable_to_non_nullable
as bool,
freezed == broadcastDay
? _self.broadcastDay
: broadcastDay // ignore: cast_nullable_to_non_nullable
as String?,
));
}
} }
// dart format on

View File

@@ -6,9 +6,8 @@ part of 'anime.dart';
// JsonSerializableGenerator // JsonSerializableGenerator
// ************************************************************************** // **************************************************************************
_$AnimeTrackingDataImpl _$$AnimeTrackingDataImplFromJson( _AnimeTrackingData _$AnimeTrackingDataFromJson(Map<String, dynamic> json) =>
Map<String, dynamic> json) => _AnimeTrackingData(
_$AnimeTrackingDataImpl(
json['id'] as String, json['id'] as String,
const MediumTrackingStateConverter() const MediumTrackingStateConverter()
.fromJson((json['state'] as num).toInt()), .fromJson((json['state'] as num).toInt()),
@@ -20,8 +19,7 @@ _$AnimeTrackingDataImpl _$$AnimeTrackingDataImplFromJson(
json['broadcastDay'] as String?, json['broadcastDay'] as String?,
); );
Map<String, dynamic> _$$AnimeTrackingDataImplToJson( Map<String, dynamic> _$AnimeTrackingDataToJson(_AnimeTrackingData instance) =>
_$AnimeTrackingDataImpl instance) =>
<String, dynamic>{ <String, dynamic>{
'id': instance.id, 'id': instance.id,
'state': const MediumTrackingStateConverter().toJson(instance.state), 'state': const MediumTrackingStateConverter().toJson(instance.state),

View File

@@ -6,7 +6,7 @@ part 'manga.g.dart';
/// Data about a tracked anime /// Data about a tracked anime
@freezed @freezed
class MangaTrackingData with _$MangaTrackingData, TrackingMedium { abstract class MangaTrackingData with _$MangaTrackingData, TrackingMedium {
factory MangaTrackingData( factory MangaTrackingData(
/// The ID of the manga /// The ID of the manga
String id, String id,
@@ -30,6 +30,8 @@ class MangaTrackingData with _$MangaTrackingData, TrackingMedium {
String thumbnailUrl, String thumbnailUrl,
) = _MangaTrackingData; ) = _MangaTrackingData;
MangaTrackingData._();
/// JSON /// JSON
factory MangaTrackingData.fromJson(Map<String, dynamic> json) => factory MangaTrackingData.fromJson(Map<String, dynamic> json) =>
_$MangaTrackingDataFromJson(json); _$MangaTrackingDataFromJson(json);

View File

@@ -1,5 +1,5 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND // GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// ignore_for_file: type=lint // 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 // 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
@@ -9,128 +9,78 @@ part of 'manga.dart';
// FreezedGenerator // FreezedGenerator
// ************************************************************************** // **************************************************************************
// dart format off
T _$identity<T>(T value) => value; 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');
MangaTrackingData _$MangaTrackingDataFromJson(Map<String, dynamic> json) {
return _MangaTrackingData.fromJson(json);
}
/// @nodoc /// @nodoc
mixin _$MangaTrackingData { mixin _$MangaTrackingData {
/// The ID of the manga /// The ID of the manga
String get id => throw _privateConstructorUsedError; String get id;
/// The state of the manga /// The state of the manga
@MediumTrackingStateConverter() @MediumTrackingStateConverter()
MediumTrackingState get state => throw _privateConstructorUsedError; MediumTrackingState get state;
/// The title of the manga /// The title of the manga
String get title => throw _privateConstructorUsedError; String get title;
/// Chapters read. /// Chapters read.
int get chaptersRead => throw _privateConstructorUsedError; int get chaptersRead;
/// Chapters read. /// Chapters read.
int get volumesOwned => throw _privateConstructorUsedError; int get volumesOwned;
/// Episodes watched. /// Episodes watched.
int? get chaptersTotal => throw _privateConstructorUsedError; int? get chaptersTotal;
/// URL to the thumbnail/cover art for the manga. /// URL to the thumbnail/cover art for the manga.
String get thumbnailUrl => throw _privateConstructorUsedError; String get thumbnailUrl;
/// Serializes this MangaTrackingData to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of MangaTrackingData /// Create a copy of MangaTrackingData
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
$MangaTrackingDataCopyWith<MangaTrackingData> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $MangaTrackingDataCopyWith<$Res> {
factory $MangaTrackingDataCopyWith(
MangaTrackingData value, $Res Function(MangaTrackingData) then) =
_$MangaTrackingDataCopyWithImpl<$Res, MangaTrackingData>;
@useResult
$Res call(
{String id,
@MediumTrackingStateConverter() MediumTrackingState state,
String title,
int chaptersRead,
int volumesOwned,
int? chaptersTotal,
String thumbnailUrl});
}
/// @nodoc
class _$MangaTrackingDataCopyWithImpl<$Res, $Val extends MangaTrackingData>
implements $MangaTrackingDataCopyWith<$Res> {
_$MangaTrackingDataCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of MangaTrackingData
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
$MangaTrackingDataCopyWith<MangaTrackingData> get copyWith =>
_$MangaTrackingDataCopyWithImpl<MangaTrackingData>(
this as MangaTrackingData, _$identity);
/// Serializes this MangaTrackingData to a JSON map.
Map<String, dynamic> toJson();
@override @override
$Res call({ bool operator ==(Object other) {
Object? id = null, return identical(this, other) ||
Object? state = null, (other.runtimeType == runtimeType &&
Object? title = null, other is MangaTrackingData &&
Object? chaptersRead = null, (identical(other.id, id) || other.id == id) &&
Object? volumesOwned = null, (identical(other.state, state) || other.state == state) &&
Object? chaptersTotal = freezed, (identical(other.title, title) || other.title == title) &&
Object? thumbnailUrl = null, (identical(other.chaptersRead, chaptersRead) ||
}) { other.chaptersRead == chaptersRead) &&
return _then(_value.copyWith( (identical(other.volumesOwned, volumesOwned) ||
id: null == id other.volumesOwned == volumesOwned) &&
? _value.id (identical(other.chaptersTotal, chaptersTotal) ||
: id // ignore: cast_nullable_to_non_nullable other.chaptersTotal == chaptersTotal) &&
as String, (identical(other.thumbnailUrl, thumbnailUrl) ||
state: null == state other.thumbnailUrl == thumbnailUrl));
? _value.state }
: state // ignore: cast_nullable_to_non_nullable
as MediumTrackingState, @JsonKey(includeFromJson: false, includeToJson: false)
title: null == title @override
? _value.title int get hashCode => Object.hash(runtimeType, id, state, title, chaptersRead,
: title // ignore: cast_nullable_to_non_nullable volumesOwned, chaptersTotal, thumbnailUrl);
as String,
chaptersRead: null == chaptersRead @override
? _value.chaptersRead String toString() {
: chaptersRead // ignore: cast_nullable_to_non_nullable return 'MangaTrackingData(id: $id, state: $state, title: $title, chaptersRead: $chaptersRead, volumesOwned: $volumesOwned, chaptersTotal: $chaptersTotal, thumbnailUrl: $thumbnailUrl)';
as int,
volumesOwned: null == volumesOwned
? _value.volumesOwned
: volumesOwned // ignore: cast_nullable_to_non_nullable
as int,
chaptersTotal: freezed == chaptersTotal
? _value.chaptersTotal
: chaptersTotal // ignore: cast_nullable_to_non_nullable
as int?,
thumbnailUrl: null == thumbnailUrl
? _value.thumbnailUrl
: thumbnailUrl // ignore: cast_nullable_to_non_nullable
as String,
) as $Val);
} }
} }
/// @nodoc /// @nodoc
abstract class _$$MangaTrackingDataImplCopyWith<$Res> abstract mixin class $MangaTrackingDataCopyWith<$Res> {
implements $MangaTrackingDataCopyWith<$Res> { factory $MangaTrackingDataCopyWith(
factory _$$MangaTrackingDataImplCopyWith(_$MangaTrackingDataImpl value, MangaTrackingData value, $Res Function(MangaTrackingData) _then) =
$Res Function(_$MangaTrackingDataImpl) then) = _$MangaTrackingDataCopyWithImpl;
__$$MangaTrackingDataImplCopyWithImpl<$Res>;
@override
@useResult @useResult
$Res call( $Res call(
{String id, {String id,
@@ -143,12 +93,12 @@ abstract class _$$MangaTrackingDataImplCopyWith<$Res>
} }
/// @nodoc /// @nodoc
class __$$MangaTrackingDataImplCopyWithImpl<$Res> class _$MangaTrackingDataCopyWithImpl<$Res>
extends _$MangaTrackingDataCopyWithImpl<$Res, _$MangaTrackingDataImpl> implements $MangaTrackingDataCopyWith<$Res> {
implements _$$MangaTrackingDataImplCopyWith<$Res> { _$MangaTrackingDataCopyWithImpl(this._self, this._then);
__$$MangaTrackingDataImplCopyWithImpl(_$MangaTrackingDataImpl _value,
$Res Function(_$MangaTrackingDataImpl) _then) final MangaTrackingData _self;
: super(_value, _then); final $Res Function(MangaTrackingData) _then;
/// Create a copy of MangaTrackingData /// Create a copy of MangaTrackingData
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@@ -163,53 +113,237 @@ class __$$MangaTrackingDataImplCopyWithImpl<$Res>
Object? chaptersTotal = freezed, Object? chaptersTotal = freezed,
Object? thumbnailUrl = null, Object? thumbnailUrl = null,
}) { }) {
return _then(_$MangaTrackingDataImpl( return _then(_self.copyWith(
null == id id: null == id
? _value.id ? _self.id
: id // ignore: cast_nullable_to_non_nullable : id // ignore: cast_nullable_to_non_nullable
as String, as String,
null == state state: null == state
? _value.state ? _self.state
: state // ignore: cast_nullable_to_non_nullable : state // ignore: cast_nullable_to_non_nullable
as MediumTrackingState, as MediumTrackingState,
null == title title: null == title
? _value.title ? _self.title
: title // ignore: cast_nullable_to_non_nullable : title // ignore: cast_nullable_to_non_nullable
as String, as String,
null == chaptersRead chaptersRead: null == chaptersRead
? _value.chaptersRead ? _self.chaptersRead
: chaptersRead // ignore: cast_nullable_to_non_nullable : chaptersRead // ignore: cast_nullable_to_non_nullable
as int, as int,
null == volumesOwned volumesOwned: null == volumesOwned
? _value.volumesOwned ? _self.volumesOwned
: volumesOwned // ignore: cast_nullable_to_non_nullable : volumesOwned // ignore: cast_nullable_to_non_nullable
as int, as int,
freezed == chaptersTotal chaptersTotal: freezed == chaptersTotal
? _value.chaptersTotal ? _self.chaptersTotal
: chaptersTotal // ignore: cast_nullable_to_non_nullable : chaptersTotal // ignore: cast_nullable_to_non_nullable
as int?, as int?,
null == thumbnailUrl thumbnailUrl: null == thumbnailUrl
? _value.thumbnailUrl ? _self.thumbnailUrl
: thumbnailUrl // ignore: cast_nullable_to_non_nullable : thumbnailUrl // ignore: cast_nullable_to_non_nullable
as String, as String,
)); ));
} }
} }
/// Adds pattern-matching-related methods to [MangaTrackingData].
extension MangaTrackingDataPatterns on MangaTrackingData {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>(
TResult Function(_MangaTrackingData value)? $default, {
required TResult orElse(),
}) {
final _that = this;
switch (_that) {
case _MangaTrackingData() when $default != null:
return $default(_that);
case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs
TResult map<TResult extends Object?>(
TResult Function(_MangaTrackingData value) $default,
) {
final _that = this;
switch (_that) {
case _MangaTrackingData():
return $default(_that);
case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>(
TResult? Function(_MangaTrackingData value)? $default,
) {
final _that = this;
switch (_that) {
case _MangaTrackingData() when $default != null:
return $default(_that);
case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
TResult Function(
String id,
@MediumTrackingStateConverter() MediumTrackingState state,
String title,
int chaptersRead,
int volumesOwned,
int? chaptersTotal,
String thumbnailUrl)?
$default, {
required TResult orElse(),
}) {
final _that = this;
switch (_that) {
case _MangaTrackingData() when $default != null:
return $default(_that.id, _that.state, _that.title, _that.chaptersRead,
_that.volumesOwned, _that.chaptersTotal, _that.thumbnailUrl);
case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs
TResult when<TResult extends Object?>(
TResult Function(
String id,
@MediumTrackingStateConverter() MediumTrackingState state,
String title,
int chaptersRead,
int volumesOwned,
int? chaptersTotal,
String thumbnailUrl)
$default,
) {
final _that = this;
switch (_that) {
case _MangaTrackingData():
return $default(_that.id, _that.state, _that.title, _that.chaptersRead,
_that.volumesOwned, _that.chaptersTotal, _that.thumbnailUrl);
case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>(
TResult? Function(
String id,
@MediumTrackingStateConverter() MediumTrackingState state,
String title,
int chaptersRead,
int volumesOwned,
int? chaptersTotal,
String thumbnailUrl)?
$default,
) {
final _that = this;
switch (_that) {
case _MangaTrackingData() when $default != null:
return $default(_that.id, _that.state, _that.title, _that.chaptersRead,
_that.volumesOwned, _that.chaptersTotal, _that.thumbnailUrl);
case _:
return null;
}
}
}
/// @nodoc /// @nodoc
@JsonSerializable() @JsonSerializable()
class _$MangaTrackingDataImpl implements _MangaTrackingData { class _MangaTrackingData extends MangaTrackingData {
_$MangaTrackingDataImpl( _MangaTrackingData(
this.id, this.id,
@MediumTrackingStateConverter() this.state, @MediumTrackingStateConverter() this.state,
this.title, this.title,
this.chaptersRead, this.chaptersRead,
this.volumesOwned, this.volumesOwned,
this.chaptersTotal, this.chaptersTotal,
this.thumbnailUrl); this.thumbnailUrl)
: super._();
factory _$MangaTrackingDataImpl.fromJson(Map<String, dynamic> json) => factory _MangaTrackingData.fromJson(Map<String, dynamic> json) =>
_$$MangaTrackingDataImplFromJson(json); _$MangaTrackingDataFromJson(json);
/// The ID of the manga /// The ID of the manga
@override @override
@@ -240,16 +374,26 @@ class _$MangaTrackingDataImpl implements _MangaTrackingData {
@override @override
final String thumbnailUrl; final String thumbnailUrl;
/// Create a copy of MangaTrackingData
/// with the given fields replaced by the non-null parameter values.
@override @override
String toString() { @JsonKey(includeFromJson: false, includeToJson: false)
return 'MangaTrackingData(id: $id, state: $state, title: $title, chaptersRead: $chaptersRead, volumesOwned: $volumesOwned, chaptersTotal: $chaptersTotal, thumbnailUrl: $thumbnailUrl)'; @pragma('vm:prefer-inline')
_$MangaTrackingDataCopyWith<_MangaTrackingData> get copyWith =>
__$MangaTrackingDataCopyWithImpl<_MangaTrackingData>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$MangaTrackingDataToJson(
this,
);
} }
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
return identical(this, other) || return identical(this, other) ||
(other.runtimeType == runtimeType && (other.runtimeType == runtimeType &&
other is _$MangaTrackingDataImpl && other is _MangaTrackingData &&
(identical(other.id, id) || other.id == id) && (identical(other.id, id) || other.id == id) &&
(identical(other.state, state) || other.state == state) && (identical(other.state, state) || other.state == state) &&
(identical(other.title, title) || other.title == title) && (identical(other.title, title) || other.title == title) &&
@@ -268,69 +412,82 @@ class _$MangaTrackingDataImpl implements _MangaTrackingData {
int get hashCode => Object.hash(runtimeType, id, state, title, chaptersRead, int get hashCode => Object.hash(runtimeType, id, state, title, chaptersRead,
volumesOwned, chaptersTotal, thumbnailUrl); volumesOwned, chaptersTotal, thumbnailUrl);
/// Create a copy of MangaTrackingData
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override @override
@pragma('vm:prefer-inline') String toString() {
_$$MangaTrackingDataImplCopyWith<_$MangaTrackingDataImpl> get copyWith => return 'MangaTrackingData(id: $id, state: $state, title: $title, chaptersRead: $chaptersRead, volumesOwned: $volumesOwned, chaptersTotal: $chaptersTotal, thumbnailUrl: $thumbnailUrl)';
__$$MangaTrackingDataImplCopyWithImpl<_$MangaTrackingDataImpl>(
this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$MangaTrackingDataImplToJson(
this,
);
} }
} }
abstract class _MangaTrackingData implements MangaTrackingData { /// @nodoc
factory _MangaTrackingData( abstract mixin class _$MangaTrackingDataCopyWith<$Res>
final String id, implements $MangaTrackingDataCopyWith<$Res> {
@MediumTrackingStateConverter() final MediumTrackingState state, factory _$MangaTrackingDataCopyWith(
final String title, _MangaTrackingData value, $Res Function(_MangaTrackingData) _then) =
final int chaptersRead, __$MangaTrackingDataCopyWithImpl;
final int volumesOwned,
final int? chaptersTotal,
final String thumbnailUrl) = _$MangaTrackingDataImpl;
factory _MangaTrackingData.fromJson(Map<String, dynamic> json) =
_$MangaTrackingDataImpl.fromJson;
/// The ID of the manga
@override @override
String get id; @useResult
$Res call(
{String id,
@MediumTrackingStateConverter() MediumTrackingState state,
String title,
int chaptersRead,
int volumesOwned,
int? chaptersTotal,
String thumbnailUrl});
}
/// The state of the manga /// @nodoc
@override class __$MangaTrackingDataCopyWithImpl<$Res>
@MediumTrackingStateConverter() implements _$MangaTrackingDataCopyWith<$Res> {
MediumTrackingState get state; __$MangaTrackingDataCopyWithImpl(this._self, this._then);
/// The title of the manga final _MangaTrackingData _self;
@override final $Res Function(_MangaTrackingData) _then;
String get title;
/// Chapters read.
@override
int get chaptersRead;
/// Chapters read.
@override
int get volumesOwned;
/// Episodes watched.
@override
int? get chaptersTotal;
/// URL to the thumbnail/cover art for the manga.
@override
String get thumbnailUrl;
/// Create a copy of MangaTrackingData /// Create a copy of MangaTrackingData
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@override @override
@JsonKey(includeFromJson: false, includeToJson: false) @pragma('vm:prefer-inline')
_$$MangaTrackingDataImplCopyWith<_$MangaTrackingDataImpl> get copyWith => $Res call({
throw _privateConstructorUsedError; Object? id = null,
Object? state = null,
Object? title = null,
Object? chaptersRead = null,
Object? volumesOwned = null,
Object? chaptersTotal = freezed,
Object? thumbnailUrl = null,
}) {
return _then(_MangaTrackingData(
null == id
? _self.id
: id // ignore: cast_nullable_to_non_nullable
as String,
null == state
? _self.state
: state // ignore: cast_nullable_to_non_nullable
as MediumTrackingState,
null == title
? _self.title
: title // ignore: cast_nullable_to_non_nullable
as String,
null == chaptersRead
? _self.chaptersRead
: chaptersRead // ignore: cast_nullable_to_non_nullable
as int,
null == volumesOwned
? _self.volumesOwned
: volumesOwned // ignore: cast_nullable_to_non_nullable
as int,
freezed == chaptersTotal
? _self.chaptersTotal
: chaptersTotal // ignore: cast_nullable_to_non_nullable
as int?,
null == thumbnailUrl
? _self.thumbnailUrl
: thumbnailUrl // ignore: cast_nullable_to_non_nullable
as String,
));
}
} }
// dart format on

View File

@@ -6,9 +6,8 @@ part of 'manga.dart';
// JsonSerializableGenerator // JsonSerializableGenerator
// ************************************************************************** // **************************************************************************
_$MangaTrackingDataImpl _$$MangaTrackingDataImplFromJson( _MangaTrackingData _$MangaTrackingDataFromJson(Map<String, dynamic> json) =>
Map<String, dynamic> json) => _MangaTrackingData(
_$MangaTrackingDataImpl(
json['id'] as String, json['id'] as String,
const MediumTrackingStateConverter() const MediumTrackingStateConverter()
.fromJson((json['state'] as num).toInt()), .fromJson((json['state'] as num).toInt()),
@@ -19,8 +18,7 @@ _$MangaTrackingDataImpl _$$MangaTrackingDataImplFromJson(
json['thumbnailUrl'] as String, json['thumbnailUrl'] as String,
); );
Map<String, dynamic> _$$MangaTrackingDataImplToJson( Map<String, dynamic> _$MangaTrackingDataToJson(_MangaTrackingData instance) =>
_$MangaTrackingDataImpl instance) =>
<String, dynamic>{ <String, dynamic>{
'id': instance.id, 'id': instance.id,
'state': const MediumTrackingStateConverter().toJson(instance.state), 'state': const MediumTrackingStateConverter().toJson(instance.state),

View File

@@ -1,8 +1,11 @@
import 'dart:io';
import 'package:anitrack/src/data/anime.dart'; import 'package:anitrack/src/data/anime.dart';
import 'package:anitrack/src/data/manga.dart'; import 'package:anitrack/src/data/manga.dart';
import 'package:anitrack/src/service/migrations/0000_airing.dart'; import 'package:anitrack/src/service/migrations/0000_airing.dart';
import 'package:anitrack/src/service/migrations/0000_score.dart'; import 'package:anitrack/src/service/migrations/0000_score.dart';
import 'package:sqflite/sqflite.dart'; import 'package:sqflite/sqflite.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
const animeTable = 'Anime'; const animeTable = 'Anime';
const mangaTable = 'Manga'; const mangaTable = 'Manga';
@@ -53,6 +56,12 @@ class DatabaseService {
late final Database _db; late final Database _db;
Future<void> initialize() async { Future<void> initialize() async {
// Allow initializing the database on Windows and Linux as well.
if (Platform.isLinux || Platform.isWindows) {
sqfliteFfiInit();
databaseFactory = databaseFactoryFfi;
}
_db = await openDatabase( _db = await openDatabase(
'anitrack.db', 'anitrack.db',
version: 3, version: 3,
@@ -113,6 +122,21 @@ class DatabaseService {
); );
} }
Future<AnimeTrackingData> incrementAnimeWatchCounter(AnimeTrackingData data, int value) async {
final result = await _db.rawQuery(
'UPDATE $animeTable SET episodesWatched = episodesWatched + $value WHERE id = ? RETURNING *',
[
data.id,
],
);
return result
.cast<Map<String, dynamic>>()
.map(AnimeTrackingData.fromJson)
.toList()
.first;
}
Future<void> deleteAnime(String id) async { Future<void> deleteAnime(String id) async {
await _db.delete( await _db.delete(
animeTable, animeTable,
@@ -145,4 +169,19 @@ class DatabaseService {
whereArgs: [id], whereArgs: [id],
); );
} }
Future<MangaTrackingData> incrementMangaReadChapters(MangaTrackingData data, int value) async {
final result = await _db.rawQuery(
'UPDATE $mangaTable SET episodesWatched = chaptersRead + $value WHERE id = ? RETURNING *',
[
data.id,
],
);
return result
.cast<Map<String, dynamic>>()
.map(MangaTrackingData.fromJson)
.toList()
.first;
}
} }

View File

@@ -122,19 +122,14 @@ class AnimeListBloc extends Bloc<AnimeListEvent, AnimeListState> {
if (anime.episodesTotal != null && if (anime.episodesTotal != null &&
anime.episodesWatched + 1 > anime.episodesTotal!) return; anime.episodesWatched + 1 > anime.episodesTotal!) return;
final newAnime = await GetIt.I.get<DatabaseService>().incrementAnimeWatchCounter(anime, 1);
final newList = List<AnimeTrackingData>.from(state.animes); final newList = List<AnimeTrackingData>.from(state.animes);
final newAnime = anime.copyWith(
episodesWatched: anime.episodesWatched + 1,
);
newList[index] = newAnime; newList[index] = newAnime;
emit( emit(
state.copyWith( state.copyWith(
animes: newList, animes: newList,
), ),
); );
await GetIt.I.get<DatabaseService>().updateAnime(newAnime);
} }
Future<void> _onAnimeDecremented( Future<void> _onAnimeDecremented(
@@ -147,19 +142,15 @@ class AnimeListBloc extends Bloc<AnimeListEvent, AnimeListState> {
final anime = state.animes[index]; final anime = state.animes[index];
if (anime.episodesWatched - 1 < 0) return; if (anime.episodesWatched - 1 < 0) return;
final newList = List<AnimeTrackingData>.from(state.animes);
final newAnime = anime.copyWith(
episodesWatched: anime.episodesWatched - 1,
);
newList[index] = newAnime;
final newAnime = await GetIt.I.get<DatabaseService>().incrementAnimeWatchCounter(anime, -1);
final newList = List<AnimeTrackingData>.from(state.animes);
newList[index] = newAnime;
emit( emit(
state.copyWith( state.copyWith(
animes: newList, animes: newList,
), ),
); );
await GetIt.I.get<DatabaseService>().updateAnime(newAnime);
} }
Future<void> _onAnimesLoaded( Future<void> _onAnimesLoaded(
@@ -228,24 +219,19 @@ class AnimeListBloc extends Bloc<AnimeListEvent, AnimeListState> {
if (manga.chaptersTotal != null && if (manga.chaptersTotal != null &&
manga.chaptersRead + 1 > manga.chaptersTotal!) return; manga.chaptersRead + 1 > manga.chaptersTotal!) return;
final newManga = await GetIt.I.get<DatabaseService>().incrementMangaReadChapters(manga, 1);
final newList = List<MangaTrackingData>.from(state.mangas); final newList = List<MangaTrackingData>.from(state.mangas);
final newManga = manga.copyWith(
chaptersRead: manga.chaptersRead + 1,
);
newList[index] = newManga; newList[index] = newManga;
// Update the cache
final cacheIndex = _mangas.indexWhere((m) => m.id == event.id);
assert(cacheIndex != -1, 'The manga must exist');
_mangas[cacheIndex] = newManga;
emit( emit(
state.copyWith( state.copyWith(
mangas: newList, mangas: newList,
), ),
); );
await GetIt.I.get<DatabaseService>().updateManga(newManga); // Update the cache
final cacheIndex = _mangas.indexWhere((m) => m.id == event.id);
assert(cacheIndex != -1, 'The manga must exist');
_mangas[cacheIndex] = newManga;
} }
Future<void> _onMangaDecremented( Future<void> _onMangaDecremented(
@@ -258,24 +244,19 @@ class AnimeListBloc extends Bloc<AnimeListEvent, AnimeListState> {
final manga = state.mangas[index]; final manga = state.mangas[index];
if (manga.chaptersRead - 1 < 0) return; if (manga.chaptersRead - 1 < 0) return;
final newManga = await GetIt.I.get<DatabaseService>().incrementMangaReadChapters(manga, -1);
final newList = List<MangaTrackingData>.from(state.mangas); final newList = List<MangaTrackingData>.from(state.mangas);
final newManga = manga.copyWith(
chaptersRead: manga.chaptersRead - 1,
);
newList[index] = newManga; newList[index] = newManga;
// Update the cache
final cacheIndex = _mangas.indexWhere((m) => m.id == event.id);
assert(cacheIndex != -1, 'The manga must exist');
_mangas[cacheIndex] = newManga;
emit( emit(
state.copyWith( state.copyWith(
mangas: newList, mangas: newList,
), ),
); );
await GetIt.I.get<DatabaseService>().updateManga(newManga); // Update the cache
final cacheIndex = _mangas.indexWhere((m) => m.id == event.id);
assert(cacheIndex != -1, 'The manga must exist');
_mangas[cacheIndex] = newManga;
} }
Future<void> _onAnimeUpdated( Future<void> _onAnimeUpdated(

View File

@@ -1,5 +1,5 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND // GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// ignore_for_file: type=lint // 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 // 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
@@ -9,102 +9,64 @@ part of 'anime_list_bloc.dart';
// FreezedGenerator // FreezedGenerator
// ************************************************************************** // **************************************************************************
// dart format off
T _$identity<T>(T value) => value; 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');
/// @nodoc /// @nodoc
mixin _$AnimeListState { mixin _$AnimeListState {
bool get buttonVisibility => throw _privateConstructorUsedError; bool get buttonVisibility;
List<AnimeTrackingData> get animes => throw _privateConstructorUsedError; List<AnimeTrackingData> get animes;
List<MangaTrackingData> get mangas => throw _privateConstructorUsedError; List<MangaTrackingData> get mangas;
MediumTrackingState get animeFilterState => MediumTrackingState get animeFilterState;
throw _privateConstructorUsedError; MediumTrackingState get mangaFilterState;
MediumTrackingState get mangaFilterState => TrackingMediumType get trackingType;
throw _privateConstructorUsedError;
TrackingMediumType get trackingType => throw _privateConstructorUsedError;
/// Create a copy of AnimeListState /// Create a copy of AnimeListState
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
$AnimeListStateCopyWith<AnimeListState> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $AnimeListStateCopyWith<$Res> {
factory $AnimeListStateCopyWith(
AnimeListState value, $Res Function(AnimeListState) then) =
_$AnimeListStateCopyWithImpl<$Res, AnimeListState>;
@useResult
$Res call(
{bool buttonVisibility,
List<AnimeTrackingData> animes,
List<MangaTrackingData> mangas,
MediumTrackingState animeFilterState,
MediumTrackingState mangaFilterState,
TrackingMediumType trackingType});
}
/// @nodoc
class _$AnimeListStateCopyWithImpl<$Res, $Val extends AnimeListState>
implements $AnimeListStateCopyWith<$Res> {
_$AnimeListStateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of AnimeListState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
$AnimeListStateCopyWith<AnimeListState> get copyWith =>
_$AnimeListStateCopyWithImpl<AnimeListState>(
this as AnimeListState, _$identity);
@override @override
$Res call({ bool operator ==(Object other) {
Object? buttonVisibility = null, return identical(this, other) ||
Object? animes = null, (other.runtimeType == runtimeType &&
Object? mangas = null, other is AnimeListState &&
Object? animeFilterState = null, (identical(other.buttonVisibility, buttonVisibility) ||
Object? mangaFilterState = null, other.buttonVisibility == buttonVisibility) &&
Object? trackingType = null, const DeepCollectionEquality().equals(other.animes, animes) &&
}) { const DeepCollectionEquality().equals(other.mangas, mangas) &&
return _then(_value.copyWith( (identical(other.animeFilterState, animeFilterState) ||
buttonVisibility: null == buttonVisibility other.animeFilterState == animeFilterState) &&
? _value.buttonVisibility (identical(other.mangaFilterState, mangaFilterState) ||
: buttonVisibility // ignore: cast_nullable_to_non_nullable other.mangaFilterState == mangaFilterState) &&
as bool, (identical(other.trackingType, trackingType) ||
animes: null == animes other.trackingType == trackingType));
? _value.animes }
: animes // ignore: cast_nullable_to_non_nullable
as List<AnimeTrackingData>, @override
mangas: null == mangas int get hashCode => Object.hash(
? _value.mangas runtimeType,
: mangas // ignore: cast_nullable_to_non_nullable buttonVisibility,
as List<MangaTrackingData>, const DeepCollectionEquality().hash(animes),
animeFilterState: null == animeFilterState const DeepCollectionEquality().hash(mangas),
? _value.animeFilterState animeFilterState,
: animeFilterState // ignore: cast_nullable_to_non_nullable mangaFilterState,
as MediumTrackingState, trackingType);
mangaFilterState: null == mangaFilterState
? _value.mangaFilterState @override
: mangaFilterState // ignore: cast_nullable_to_non_nullable String toString() {
as MediumTrackingState, return 'AnimeListState(buttonVisibility: $buttonVisibility, animes: $animes, mangas: $mangas, animeFilterState: $animeFilterState, mangaFilterState: $mangaFilterState, trackingType: $trackingType)';
trackingType: null == trackingType
? _value.trackingType
: trackingType // ignore: cast_nullable_to_non_nullable
as TrackingMediumType,
) as $Val);
} }
} }
/// @nodoc /// @nodoc
abstract class _$$AnimeListStateImplCopyWith<$Res> abstract mixin class $AnimeListStateCopyWith<$Res> {
implements $AnimeListStateCopyWith<$Res> { factory $AnimeListStateCopyWith(
factory _$$AnimeListStateImplCopyWith(_$AnimeListStateImpl value, AnimeListState value, $Res Function(AnimeListState) _then) =
$Res Function(_$AnimeListStateImpl) then) = _$AnimeListStateCopyWithImpl;
__$$AnimeListStateImplCopyWithImpl<$Res>;
@override
@useResult @useResult
$Res call( $Res call(
{bool buttonVisibility, {bool buttonVisibility,
@@ -116,12 +78,12 @@ abstract class _$$AnimeListStateImplCopyWith<$Res>
} }
/// @nodoc /// @nodoc
class __$$AnimeListStateImplCopyWithImpl<$Res> class _$AnimeListStateCopyWithImpl<$Res>
extends _$AnimeListStateCopyWithImpl<$Res, _$AnimeListStateImpl> implements $AnimeListStateCopyWith<$Res> {
implements _$$AnimeListStateImplCopyWith<$Res> { _$AnimeListStateCopyWithImpl(this._self, this._then);
__$$AnimeListStateImplCopyWithImpl(
_$AnimeListStateImpl _value, $Res Function(_$AnimeListStateImpl) _then) final AnimeListState _self;
: super(_value, _then); final $Res Function(AnimeListState) _then;
/// Create a copy of AnimeListState /// Create a copy of AnimeListState
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@@ -135,39 +97,220 @@ class __$$AnimeListStateImplCopyWithImpl<$Res>
Object? mangaFilterState = null, Object? mangaFilterState = null,
Object? trackingType = null, Object? trackingType = null,
}) { }) {
return _then(_$AnimeListStateImpl( return _then(_self.copyWith(
buttonVisibility: null == buttonVisibility buttonVisibility: null == buttonVisibility
? _value.buttonVisibility ? _self.buttonVisibility
: buttonVisibility // ignore: cast_nullable_to_non_nullable : buttonVisibility // ignore: cast_nullable_to_non_nullable
as bool, as bool,
animes: null == animes animes: null == animes
? _value._animes ? _self.animes
: animes // ignore: cast_nullable_to_non_nullable : animes // ignore: cast_nullable_to_non_nullable
as List<AnimeTrackingData>, as List<AnimeTrackingData>,
mangas: null == mangas mangas: null == mangas
? _value._mangas ? _self.mangas
: mangas // ignore: cast_nullable_to_non_nullable : mangas // ignore: cast_nullable_to_non_nullable
as List<MangaTrackingData>, as List<MangaTrackingData>,
animeFilterState: null == animeFilterState animeFilterState: null == animeFilterState
? _value.animeFilterState ? _self.animeFilterState
: animeFilterState // ignore: cast_nullable_to_non_nullable : animeFilterState // ignore: cast_nullable_to_non_nullable
as MediumTrackingState, as MediumTrackingState,
mangaFilterState: null == mangaFilterState mangaFilterState: null == mangaFilterState
? _value.mangaFilterState ? _self.mangaFilterState
: mangaFilterState // ignore: cast_nullable_to_non_nullable : mangaFilterState // ignore: cast_nullable_to_non_nullable
as MediumTrackingState, as MediumTrackingState,
trackingType: null == trackingType trackingType: null == trackingType
? _value.trackingType ? _self.trackingType
: trackingType // ignore: cast_nullable_to_non_nullable : trackingType // ignore: cast_nullable_to_non_nullable
as TrackingMediumType, as TrackingMediumType,
)); ));
} }
} }
/// Adds pattern-matching-related methods to [AnimeListState].
extension AnimeListStatePatterns on AnimeListState {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>(
TResult Function(_AnimeListState value)? $default, {
required TResult orElse(),
}) {
final _that = this;
switch (_that) {
case _AnimeListState() when $default != null:
return $default(_that);
case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs
TResult map<TResult extends Object?>(
TResult Function(_AnimeListState value) $default,
) {
final _that = this;
switch (_that) {
case _AnimeListState():
return $default(_that);
case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>(
TResult? Function(_AnimeListState value)? $default,
) {
final _that = this;
switch (_that) {
case _AnimeListState() when $default != null:
return $default(_that);
case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
TResult Function(
bool buttonVisibility,
List<AnimeTrackingData> animes,
List<MangaTrackingData> mangas,
MediumTrackingState animeFilterState,
MediumTrackingState mangaFilterState,
TrackingMediumType trackingType)?
$default, {
required TResult orElse(),
}) {
final _that = this;
switch (_that) {
case _AnimeListState() when $default != null:
return $default(_that.buttonVisibility, _that.animes, _that.mangas,
_that.animeFilterState, _that.mangaFilterState, _that.trackingType);
case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs
TResult when<TResult extends Object?>(
TResult Function(
bool buttonVisibility,
List<AnimeTrackingData> animes,
List<MangaTrackingData> mangas,
MediumTrackingState animeFilterState,
MediumTrackingState mangaFilterState,
TrackingMediumType trackingType)
$default,
) {
final _that = this;
switch (_that) {
case _AnimeListState():
return $default(_that.buttonVisibility, _that.animes, _that.mangas,
_that.animeFilterState, _that.mangaFilterState, _that.trackingType);
case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>(
TResult? Function(
bool buttonVisibility,
List<AnimeTrackingData> animes,
List<MangaTrackingData> mangas,
MediumTrackingState animeFilterState,
MediumTrackingState mangaFilterState,
TrackingMediumType trackingType)?
$default,
) {
final _that = this;
switch (_that) {
case _AnimeListState() when $default != null:
return $default(_that.buttonVisibility, _that.animes, _that.mangas,
_that.animeFilterState, _that.mangaFilterState, _that.trackingType);
case _:
return null;
}
}
}
/// @nodoc /// @nodoc
class _$AnimeListStateImpl implements _AnimeListState { class _AnimeListState implements AnimeListState {
_$AnimeListStateImpl( _AnimeListState(
{this.buttonVisibility = true, {this.buttonVisibility = true,
final List<AnimeTrackingData> animes = const [], final List<AnimeTrackingData> animes = const [],
final List<MangaTrackingData> mangas = const [], final List<MangaTrackingData> mangas = const [],
@@ -208,16 +351,19 @@ class _$AnimeListStateImpl implements _AnimeListState {
@JsonKey() @JsonKey()
final TrackingMediumType trackingType; final TrackingMediumType trackingType;
/// Create a copy of AnimeListState
/// with the given fields replaced by the non-null parameter values.
@override @override
String toString() { @JsonKey(includeFromJson: false, includeToJson: false)
return 'AnimeListState(buttonVisibility: $buttonVisibility, animes: $animes, mangas: $mangas, animeFilterState: $animeFilterState, mangaFilterState: $mangaFilterState, trackingType: $trackingType)'; @pragma('vm:prefer-inline')
} _$AnimeListStateCopyWith<_AnimeListState> get copyWith =>
__$AnimeListStateCopyWithImpl<_AnimeListState>(this, _$identity);
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
return identical(this, other) || return identical(this, other) ||
(other.runtimeType == runtimeType && (other.runtimeType == runtimeType &&
other is _$AnimeListStateImpl && other is _AnimeListState &&
(identical(other.buttonVisibility, buttonVisibility) || (identical(other.buttonVisibility, buttonVisibility) ||
other.buttonVisibility == buttonVisibility) && other.buttonVisibility == buttonVisibility) &&
const DeepCollectionEquality().equals(other._animes, _animes) && const DeepCollectionEquality().equals(other._animes, _animes) &&
@@ -240,42 +386,76 @@ class _$AnimeListStateImpl implements _AnimeListState {
mangaFilterState, mangaFilterState,
trackingType); trackingType);
@override
String toString() {
return 'AnimeListState(buttonVisibility: $buttonVisibility, animes: $animes, mangas: $mangas, animeFilterState: $animeFilterState, mangaFilterState: $mangaFilterState, trackingType: $trackingType)';
}
}
/// @nodoc
abstract mixin class _$AnimeListStateCopyWith<$Res>
implements $AnimeListStateCopyWith<$Res> {
factory _$AnimeListStateCopyWith(
_AnimeListState value, $Res Function(_AnimeListState) _then) =
__$AnimeListStateCopyWithImpl;
@override
@useResult
$Res call(
{bool buttonVisibility,
List<AnimeTrackingData> animes,
List<MangaTrackingData> mangas,
MediumTrackingState animeFilterState,
MediumTrackingState mangaFilterState,
TrackingMediumType trackingType});
}
/// @nodoc
class __$AnimeListStateCopyWithImpl<$Res>
implements _$AnimeListStateCopyWith<$Res> {
__$AnimeListStateCopyWithImpl(this._self, this._then);
final _AnimeListState _self;
final $Res Function(_AnimeListState) _then;
/// Create a copy of AnimeListState /// Create a copy of AnimeListState
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override @override
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
_$$AnimeListStateImplCopyWith<_$AnimeListStateImpl> get copyWith => $Res call({
__$$AnimeListStateImplCopyWithImpl<_$AnimeListStateImpl>( Object? buttonVisibility = null,
this, _$identity); Object? animes = null,
Object? mangas = null,
Object? animeFilterState = null,
Object? mangaFilterState = null,
Object? trackingType = null,
}) {
return _then(_AnimeListState(
buttonVisibility: null == buttonVisibility
? _self.buttonVisibility
: buttonVisibility // ignore: cast_nullable_to_non_nullable
as bool,
animes: null == animes
? _self._animes
: animes // ignore: cast_nullable_to_non_nullable
as List<AnimeTrackingData>,
mangas: null == mangas
? _self._mangas
: mangas // ignore: cast_nullable_to_non_nullable
as List<MangaTrackingData>,
animeFilterState: null == animeFilterState
? _self.animeFilterState
: animeFilterState // ignore: cast_nullable_to_non_nullable
as MediumTrackingState,
mangaFilterState: null == mangaFilterState
? _self.mangaFilterState
: mangaFilterState // ignore: cast_nullable_to_non_nullable
as MediumTrackingState,
trackingType: null == trackingType
? _self.trackingType
: trackingType // ignore: cast_nullable_to_non_nullable
as TrackingMediumType,
));
}
} }
abstract class _AnimeListState implements AnimeListState { // dart format on
factory _AnimeListState(
{final bool buttonVisibility,
final List<AnimeTrackingData> animes,
final List<MangaTrackingData> mangas,
final MediumTrackingState animeFilterState,
final MediumTrackingState mangaFilterState,
final TrackingMediumType trackingType}) = _$AnimeListStateImpl;
@override
bool get buttonVisibility;
@override
List<AnimeTrackingData> get animes;
@override
List<MangaTrackingData> get mangas;
@override
MediumTrackingState get animeFilterState;
@override
MediumTrackingState get mangaFilterState;
@override
TrackingMediumType get trackingType;
/// Create a copy of AnimeListState
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$AnimeListStateImplCopyWith<_$AnimeListStateImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@@ -1,7 +1,7 @@
part of 'anime_list_bloc.dart'; part of 'anime_list_bloc.dart';
@freezed @freezed
class AnimeListState with _$AnimeListState { abstract class AnimeListState with _$AnimeListState {
factory AnimeListState({ factory AnimeListState({
@Default(true) bool buttonVisibility, @Default(true) bool buttonVisibility,
@Default([]) List<AnimeTrackingData> animes, @Default([]) List<AnimeTrackingData> animes,

View File

@@ -1,5 +1,5 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND // GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// ignore_for_file: type=lint // 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 // 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
@@ -9,86 +9,53 @@ part of 'anime_search_bloc.dart';
// FreezedGenerator // FreezedGenerator
// ************************************************************************** // **************************************************************************
// dart format off
T _$identity<T>(T value) => value; 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');
/// @nodoc /// @nodoc
mixin _$AnimeSearchState { mixin _$AnimeSearchState {
TrackingMediumType get trackingType => throw _privateConstructorUsedError; TrackingMediumType get trackingType;
String get searchQuery => throw _privateConstructorUsedError; String get searchQuery;
bool get working => throw _privateConstructorUsedError; bool get working;
List<SearchResult> get searchResults => throw _privateConstructorUsedError; List<SearchResult> get searchResults;
/// Create a copy of AnimeSearchState /// Create a copy of AnimeSearchState
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
$AnimeSearchStateCopyWith<AnimeSearchState> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $AnimeSearchStateCopyWith<$Res> {
factory $AnimeSearchStateCopyWith(
AnimeSearchState value, $Res Function(AnimeSearchState) then) =
_$AnimeSearchStateCopyWithImpl<$Res, AnimeSearchState>;
@useResult
$Res call(
{TrackingMediumType trackingType,
String searchQuery,
bool working,
List<SearchResult> searchResults});
}
/// @nodoc
class _$AnimeSearchStateCopyWithImpl<$Res, $Val extends AnimeSearchState>
implements $AnimeSearchStateCopyWith<$Res> {
_$AnimeSearchStateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of AnimeSearchState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
$AnimeSearchStateCopyWith<AnimeSearchState> get copyWith =>
_$AnimeSearchStateCopyWithImpl<AnimeSearchState>(
this as AnimeSearchState, _$identity);
@override @override
$Res call({ bool operator ==(Object other) {
Object? trackingType = null, return identical(this, other) ||
Object? searchQuery = null, (other.runtimeType == runtimeType &&
Object? working = null, other is AnimeSearchState &&
Object? searchResults = null, (identical(other.trackingType, trackingType) ||
}) { other.trackingType == trackingType) &&
return _then(_value.copyWith( (identical(other.searchQuery, searchQuery) ||
trackingType: null == trackingType other.searchQuery == searchQuery) &&
? _value.trackingType (identical(other.working, working) || other.working == working) &&
: trackingType // ignore: cast_nullable_to_non_nullable const DeepCollectionEquality()
as TrackingMediumType, .equals(other.searchResults, searchResults));
searchQuery: null == searchQuery }
? _value.searchQuery
: searchQuery // ignore: cast_nullable_to_non_nullable @override
as String, int get hashCode => Object.hash(runtimeType, trackingType, searchQuery,
working: null == working working, const DeepCollectionEquality().hash(searchResults));
? _value.working
: working // ignore: cast_nullable_to_non_nullable @override
as bool, String toString() {
searchResults: null == searchResults return 'AnimeSearchState(trackingType: $trackingType, searchQuery: $searchQuery, working: $working, searchResults: $searchResults)';
? _value.searchResults
: searchResults // ignore: cast_nullable_to_non_nullable
as List<SearchResult>,
) as $Val);
} }
} }
/// @nodoc /// @nodoc
abstract class _$$AnimeSearchStateImplCopyWith<$Res> abstract mixin class $AnimeSearchStateCopyWith<$Res> {
implements $AnimeSearchStateCopyWith<$Res> { factory $AnimeSearchStateCopyWith(
factory _$$AnimeSearchStateImplCopyWith(_$AnimeSearchStateImpl value, AnimeSearchState value, $Res Function(AnimeSearchState) _then) =
$Res Function(_$AnimeSearchStateImpl) then) = _$AnimeSearchStateCopyWithImpl;
__$$AnimeSearchStateImplCopyWithImpl<$Res>;
@override
@useResult @useResult
$Res call( $Res call(
{TrackingMediumType trackingType, {TrackingMediumType trackingType,
@@ -98,12 +65,12 @@ abstract class _$$AnimeSearchStateImplCopyWith<$Res>
} }
/// @nodoc /// @nodoc
class __$$AnimeSearchStateImplCopyWithImpl<$Res> class _$AnimeSearchStateCopyWithImpl<$Res>
extends _$AnimeSearchStateCopyWithImpl<$Res, _$AnimeSearchStateImpl> implements $AnimeSearchStateCopyWith<$Res> {
implements _$$AnimeSearchStateImplCopyWith<$Res> { _$AnimeSearchStateCopyWithImpl(this._self, this._then);
__$$AnimeSearchStateImplCopyWithImpl(_$AnimeSearchStateImpl _value,
$Res Function(_$AnimeSearchStateImpl) _then) final AnimeSearchState _self;
: super(_value, _then); final $Res Function(AnimeSearchState) _then;
/// Create a copy of AnimeSearchState /// Create a copy of AnimeSearchState
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@@ -115,31 +82,197 @@ class __$$AnimeSearchStateImplCopyWithImpl<$Res>
Object? working = null, Object? working = null,
Object? searchResults = null, Object? searchResults = null,
}) { }) {
return _then(_$AnimeSearchStateImpl( return _then(_self.copyWith(
trackingType: null == trackingType trackingType: null == trackingType
? _value.trackingType ? _self.trackingType
: trackingType // ignore: cast_nullable_to_non_nullable : trackingType // ignore: cast_nullable_to_non_nullable
as TrackingMediumType, as TrackingMediumType,
searchQuery: null == searchQuery searchQuery: null == searchQuery
? _value.searchQuery ? _self.searchQuery
: searchQuery // ignore: cast_nullable_to_non_nullable : searchQuery // ignore: cast_nullable_to_non_nullable
as String, as String,
working: null == working working: null == working
? _value.working ? _self.working
: working // ignore: cast_nullable_to_non_nullable : working // ignore: cast_nullable_to_non_nullable
as bool, as bool,
searchResults: null == searchResults searchResults: null == searchResults
? _value._searchResults ? _self.searchResults
: searchResults // ignore: cast_nullable_to_non_nullable : searchResults // ignore: cast_nullable_to_non_nullable
as List<SearchResult>, as List<SearchResult>,
)); ));
} }
} }
/// Adds pattern-matching-related methods to [AnimeSearchState].
extension AnimeSearchStatePatterns on AnimeSearchState {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>(
TResult Function(_AnimeSearchState value)? $default, {
required TResult orElse(),
}) {
final _that = this;
switch (_that) {
case _AnimeSearchState() when $default != null:
return $default(_that);
case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs
TResult map<TResult extends Object?>(
TResult Function(_AnimeSearchState value) $default,
) {
final _that = this;
switch (_that) {
case _AnimeSearchState():
return $default(_that);
case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>(
TResult? Function(_AnimeSearchState value)? $default,
) {
final _that = this;
switch (_that) {
case _AnimeSearchState() when $default != null:
return $default(_that);
case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
TResult Function(TrackingMediumType trackingType, String searchQuery,
bool working, List<SearchResult> searchResults)?
$default, {
required TResult orElse(),
}) {
final _that = this;
switch (_that) {
case _AnimeSearchState() when $default != null:
return $default(_that.trackingType, _that.searchQuery, _that.working,
_that.searchResults);
case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs
TResult when<TResult extends Object?>(
TResult Function(TrackingMediumType trackingType, String searchQuery,
bool working, List<SearchResult> searchResults)
$default,
) {
final _that = this;
switch (_that) {
case _AnimeSearchState():
return $default(_that.trackingType, _that.searchQuery, _that.working,
_that.searchResults);
case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>(
TResult? Function(TrackingMediumType trackingType, String searchQuery,
bool working, List<SearchResult> searchResults)?
$default,
) {
final _that = this;
switch (_that) {
case _AnimeSearchState() when $default != null:
return $default(_that.trackingType, _that.searchQuery, _that.working,
_that.searchResults);
case _:
return null;
}
}
}
/// @nodoc /// @nodoc
class _$AnimeSearchStateImpl implements _AnimeSearchState { class _AnimeSearchState implements AnimeSearchState {
_$AnimeSearchStateImpl( _AnimeSearchState(
{this.trackingType = TrackingMediumType.anime, {this.trackingType = TrackingMediumType.anime,
this.searchQuery = '', this.searchQuery = '',
this.working = false, this.working = false,
@@ -164,16 +297,19 @@ class _$AnimeSearchStateImpl implements _AnimeSearchState {
return EqualUnmodifiableListView(_searchResults); return EqualUnmodifiableListView(_searchResults);
} }
/// Create a copy of AnimeSearchState
/// with the given fields replaced by the non-null parameter values.
@override @override
String toString() { @JsonKey(includeFromJson: false, includeToJson: false)
return 'AnimeSearchState(trackingType: $trackingType, searchQuery: $searchQuery, working: $working, searchResults: $searchResults)'; @pragma('vm:prefer-inline')
} _$AnimeSearchStateCopyWith<_AnimeSearchState> get copyWith =>
__$AnimeSearchStateCopyWithImpl<_AnimeSearchState>(this, _$identity);
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
return identical(this, other) || return identical(this, other) ||
(other.runtimeType == runtimeType && (other.runtimeType == runtimeType &&
other is _$AnimeSearchStateImpl && other is _AnimeSearchState &&
(identical(other.trackingType, trackingType) || (identical(other.trackingType, trackingType) ||
other.trackingType == trackingType) && other.trackingType == trackingType) &&
(identical(other.searchQuery, searchQuery) || (identical(other.searchQuery, searchQuery) ||
@@ -187,36 +323,64 @@ class _$AnimeSearchStateImpl implements _AnimeSearchState {
int get hashCode => Object.hash(runtimeType, trackingType, searchQuery, int get hashCode => Object.hash(runtimeType, trackingType, searchQuery,
working, const DeepCollectionEquality().hash(_searchResults)); working, const DeepCollectionEquality().hash(_searchResults));
@override
String toString() {
return 'AnimeSearchState(trackingType: $trackingType, searchQuery: $searchQuery, working: $working, searchResults: $searchResults)';
}
}
/// @nodoc
abstract mixin class _$AnimeSearchStateCopyWith<$Res>
implements $AnimeSearchStateCopyWith<$Res> {
factory _$AnimeSearchStateCopyWith(
_AnimeSearchState value, $Res Function(_AnimeSearchState) _then) =
__$AnimeSearchStateCopyWithImpl;
@override
@useResult
$Res call(
{TrackingMediumType trackingType,
String searchQuery,
bool working,
List<SearchResult> searchResults});
}
/// @nodoc
class __$AnimeSearchStateCopyWithImpl<$Res>
implements _$AnimeSearchStateCopyWith<$Res> {
__$AnimeSearchStateCopyWithImpl(this._self, this._then);
final _AnimeSearchState _self;
final $Res Function(_AnimeSearchState) _then;
/// Create a copy of AnimeSearchState /// Create a copy of AnimeSearchState
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override @override
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
_$$AnimeSearchStateImplCopyWith<_$AnimeSearchStateImpl> get copyWith => $Res call({
__$$AnimeSearchStateImplCopyWithImpl<_$AnimeSearchStateImpl>( Object? trackingType = null,
this, _$identity); Object? searchQuery = null,
Object? working = null,
Object? searchResults = null,
}) {
return _then(_AnimeSearchState(
trackingType: null == trackingType
? _self.trackingType
: trackingType // ignore: cast_nullable_to_non_nullable
as TrackingMediumType,
searchQuery: null == searchQuery
? _self.searchQuery
: searchQuery // ignore: cast_nullable_to_non_nullable
as String,
working: null == working
? _self.working
: working // ignore: cast_nullable_to_non_nullable
as bool,
searchResults: null == searchResults
? _self._searchResults
: searchResults // ignore: cast_nullable_to_non_nullable
as List<SearchResult>,
));
}
} }
abstract class _AnimeSearchState implements AnimeSearchState { // dart format on
factory _AnimeSearchState(
{final TrackingMediumType trackingType,
final String searchQuery,
final bool working,
final List<SearchResult> searchResults}) = _$AnimeSearchStateImpl;
@override
TrackingMediumType get trackingType;
@override
String get searchQuery;
@override
bool get working;
@override
List<SearchResult> get searchResults;
/// Create a copy of AnimeSearchState
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$AnimeSearchStateImplCopyWith<_$AnimeSearchStateImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@@ -1,7 +1,7 @@
part of 'anime_search_bloc.dart'; part of 'anime_search_bloc.dart';
@freezed @freezed
class AnimeSearchState with _$AnimeSearchState { abstract class AnimeSearchState with _$AnimeSearchState {
factory AnimeSearchState({ factory AnimeSearchState({
@Default(TrackingMediumType.anime) TrackingMediumType trackingType, @Default(TrackingMediumType.anime) TrackingMediumType trackingType,
@Default('') String searchQuery, @Default('') String searchQuery,

View File

@@ -1,5 +1,5 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND // GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// ignore_for_file: type=lint // 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 // 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
@@ -9,137 +9,28 @@ part of 'calendar_bloc.dart';
// FreezedGenerator // FreezedGenerator
// ************************************************************************** // **************************************************************************
// dart format off
T _$identity<T>(T value) => value; 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');
/// @nodoc /// @nodoc
mixin _$CalendarState { mixin _$CalendarState {
bool get refreshing => throw _privateConstructorUsedError; bool get refreshing;
int get refreshingCount => throw _privateConstructorUsedError; int get refreshingCount;
int get refreshingTotal => throw _privateConstructorUsedError; int get refreshingTotal;
/// Create a copy of CalendarState /// Create a copy of CalendarState
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$CalendarStateCopyWith<CalendarState> get copyWith => $CalendarStateCopyWith<CalendarState> get copyWith =>
throw _privateConstructorUsedError; _$CalendarStateCopyWithImpl<CalendarState>(
} this as CalendarState, _$identity);
/// @nodoc
abstract class $CalendarStateCopyWith<$Res> {
factory $CalendarStateCopyWith(
CalendarState value, $Res Function(CalendarState) then) =
_$CalendarStateCopyWithImpl<$Res, CalendarState>;
@useResult
$Res call({bool refreshing, int refreshingCount, int refreshingTotal});
}
/// @nodoc
class _$CalendarStateCopyWithImpl<$Res, $Val extends CalendarState>
implements $CalendarStateCopyWith<$Res> {
_$CalendarStateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of CalendarState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? refreshing = null,
Object? refreshingCount = null,
Object? refreshingTotal = null,
}) {
return _then(_value.copyWith(
refreshing: null == refreshing
? _value.refreshing
: refreshing // ignore: cast_nullable_to_non_nullable
as bool,
refreshingCount: null == refreshingCount
? _value.refreshingCount
: refreshingCount // ignore: cast_nullable_to_non_nullable
as int,
refreshingTotal: null == refreshingTotal
? _value.refreshingTotal
: refreshingTotal // ignore: cast_nullable_to_non_nullable
as int,
) as $Val);
}
}
/// @nodoc
abstract class _$$CalendarStateImplCopyWith<$Res>
implements $CalendarStateCopyWith<$Res> {
factory _$$CalendarStateImplCopyWith(
_$CalendarStateImpl value, $Res Function(_$CalendarStateImpl) then) =
__$$CalendarStateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({bool refreshing, int refreshingCount, int refreshingTotal});
}
/// @nodoc
class __$$CalendarStateImplCopyWithImpl<$Res>
extends _$CalendarStateCopyWithImpl<$Res, _$CalendarStateImpl>
implements _$$CalendarStateImplCopyWith<$Res> {
__$$CalendarStateImplCopyWithImpl(
_$CalendarStateImpl _value, $Res Function(_$CalendarStateImpl) _then)
: super(_value, _then);
/// Create a copy of CalendarState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? refreshing = null,
Object? refreshingCount = null,
Object? refreshingTotal = null,
}) {
return _then(_$CalendarStateImpl(
null == refreshing
? _value.refreshing
: refreshing // ignore: cast_nullable_to_non_nullable
as bool,
null == refreshingCount
? _value.refreshingCount
: refreshingCount // ignore: cast_nullable_to_non_nullable
as int,
null == refreshingTotal
? _value.refreshingTotal
: refreshingTotal // ignore: cast_nullable_to_non_nullable
as int,
));
}
}
/// @nodoc
class _$CalendarStateImpl implements _CalendarState {
_$CalendarStateImpl(
this.refreshing, this.refreshingCount, this.refreshingTotal);
@override
final bool refreshing;
@override
final int refreshingCount;
@override
final int refreshingTotal;
@override
String toString() {
return 'CalendarState(refreshing: $refreshing, refreshingCount: $refreshingCount, refreshingTotal: $refreshingTotal)';
}
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
return identical(this, other) || return identical(this, other) ||
(other.runtimeType == runtimeType && (other.runtimeType == runtimeType &&
other is _$CalendarStateImpl && other is CalendarState &&
(identical(other.refreshing, refreshing) || (identical(other.refreshing, refreshing) ||
other.refreshing == refreshing) && other.refreshing == refreshing) &&
(identical(other.refreshingCount, refreshingCount) || (identical(other.refreshingCount, refreshingCount) ||
@@ -152,30 +43,305 @@ class _$CalendarStateImpl implements _CalendarState {
int get hashCode => int get hashCode =>
Object.hash(runtimeType, refreshing, refreshingCount, refreshingTotal); Object.hash(runtimeType, refreshing, refreshingCount, refreshingTotal);
@override
String toString() {
return 'CalendarState(refreshing: $refreshing, refreshingCount: $refreshingCount, refreshingTotal: $refreshingTotal)';
}
}
/// @nodoc
abstract mixin class $CalendarStateCopyWith<$Res> {
factory $CalendarStateCopyWith(
CalendarState value, $Res Function(CalendarState) _then) =
_$CalendarStateCopyWithImpl;
@useResult
$Res call({bool refreshing, int refreshingCount, int refreshingTotal});
}
/// @nodoc
class _$CalendarStateCopyWithImpl<$Res>
implements $CalendarStateCopyWith<$Res> {
_$CalendarStateCopyWithImpl(this._self, this._then);
final CalendarState _self;
final $Res Function(CalendarState) _then;
/// Create a copy of CalendarState /// Create a copy of CalendarState
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? refreshing = null,
Object? refreshingCount = null,
Object? refreshingTotal = null,
}) {
return _then(_self.copyWith(
refreshing: null == refreshing
? _self.refreshing
: refreshing // ignore: cast_nullable_to_non_nullable
as bool,
refreshingCount: null == refreshingCount
? _self.refreshingCount
: refreshingCount // ignore: cast_nullable_to_non_nullable
as int,
refreshingTotal: null == refreshingTotal
? _self.refreshingTotal
: refreshingTotal // ignore: cast_nullable_to_non_nullable
as int,
));
}
}
/// Adds pattern-matching-related methods to [CalendarState].
extension CalendarStatePatterns on CalendarState {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>(
TResult Function(_CalendarState value)? $default, {
required TResult orElse(),
}) {
final _that = this;
switch (_that) {
case _CalendarState() when $default != null:
return $default(_that);
case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs
TResult map<TResult extends Object?>(
TResult Function(_CalendarState value) $default,
) {
final _that = this;
switch (_that) {
case _CalendarState():
return $default(_that);
case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>(
TResult? Function(_CalendarState value)? $default,
) {
final _that = this;
switch (_that) {
case _CalendarState() when $default != null:
return $default(_that);
case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
TResult Function(bool refreshing, int refreshingCount, int refreshingTotal)?
$default, {
required TResult orElse(),
}) {
final _that = this;
switch (_that) {
case _CalendarState() when $default != null:
return $default(
_that.refreshing, _that.refreshingCount, _that.refreshingTotal);
case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs
TResult when<TResult extends Object?>(
TResult Function(bool refreshing, int refreshingCount, int refreshingTotal)
$default,
) {
final _that = this;
switch (_that) {
case _CalendarState():
return $default(
_that.refreshing, _that.refreshingCount, _that.refreshingTotal);
case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>(
TResult? Function(
bool refreshing, int refreshingCount, int refreshingTotal)?
$default,
) {
final _that = this;
switch (_that) {
case _CalendarState() when $default != null:
return $default(
_that.refreshing, _that.refreshingCount, _that.refreshingTotal);
case _:
return null;
}
}
}
/// @nodoc
class _CalendarState implements CalendarState {
_CalendarState(this.refreshing, this.refreshingCount, this.refreshingTotal);
@override
final bool refreshing;
@override
final int refreshingCount;
@override
final int refreshingTotal;
/// Create a copy of CalendarState
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$CalendarStateCopyWith<_CalendarState> get copyWith =>
__$CalendarStateCopyWithImpl<_CalendarState>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _CalendarState &&
(identical(other.refreshing, refreshing) ||
other.refreshing == refreshing) &&
(identical(other.refreshingCount, refreshingCount) ||
other.refreshingCount == refreshingCount) &&
(identical(other.refreshingTotal, refreshingTotal) ||
other.refreshingTotal == refreshingTotal));
}
@override
int get hashCode =>
Object.hash(runtimeType, refreshing, refreshingCount, refreshingTotal);
@override
String toString() {
return 'CalendarState(refreshing: $refreshing, refreshingCount: $refreshingCount, refreshingTotal: $refreshingTotal)';
}
}
/// @nodoc
abstract mixin class _$CalendarStateCopyWith<$Res>
implements $CalendarStateCopyWith<$Res> {
factory _$CalendarStateCopyWith(
_CalendarState value, $Res Function(_CalendarState) _then) =
__$CalendarStateCopyWithImpl;
@override
@useResult
$Res call({bool refreshing, int refreshingCount, int refreshingTotal});
}
/// @nodoc
class __$CalendarStateCopyWithImpl<$Res>
implements _$CalendarStateCopyWith<$Res> {
__$CalendarStateCopyWithImpl(this._self, this._then);
final _CalendarState _self;
final $Res Function(_CalendarState) _then;
/// Create a copy of CalendarState
/// with the given fields replaced by the non-null parameter values.
@override @override
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
_$$CalendarStateImplCopyWith<_$CalendarStateImpl> get copyWith => $Res call({
__$$CalendarStateImplCopyWithImpl<_$CalendarStateImpl>(this, _$identity); Object? refreshing = null,
Object? refreshingCount = null,
Object? refreshingTotal = null,
}) {
return _then(_CalendarState(
null == refreshing
? _self.refreshing
: refreshing // ignore: cast_nullable_to_non_nullable
as bool,
null == refreshingCount
? _self.refreshingCount
: refreshingCount // ignore: cast_nullable_to_non_nullable
as int,
null == refreshingTotal
? _self.refreshingTotal
: refreshingTotal // ignore: cast_nullable_to_non_nullable
as int,
));
}
} }
abstract class _CalendarState implements CalendarState { // dart format on
factory _CalendarState(final bool refreshing, final int refreshingCount,
final int refreshingTotal) = _$CalendarStateImpl;
@override
bool get refreshing;
@override
int get refreshingCount;
@override
int get refreshingTotal;
/// Create a copy of CalendarState
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$CalendarStateImplCopyWith<_$CalendarStateImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@@ -1,7 +1,7 @@
part of 'calendar_bloc.dart'; part of 'calendar_bloc.dart';
@freezed @freezed
class CalendarState with _$CalendarState { abstract class CalendarState with _$CalendarState {
factory CalendarState( factory CalendarState(
bool refreshing, bool refreshing,
int refreshingCount, int refreshingCount,

View File

@@ -1,5 +1,5 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND // GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// ignore_for_file: type=lint // 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 // 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
@@ -9,79 +9,50 @@ part of 'details_bloc.dart';
// FreezedGenerator // FreezedGenerator
// ************************************************************************** // **************************************************************************
// dart format off
T _$identity<T>(T value) => value; 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');
/// @nodoc /// @nodoc
mixin _$DetailsState { mixin _$DetailsState {
TrackingMedium? get data => throw _privateConstructorUsedError; TrackingMedium? get data;
String? get heroImagePrefix => throw _privateConstructorUsedError; String? get heroImagePrefix;
TrackingMediumType get trackingType => throw _privateConstructorUsedError; TrackingMediumType get trackingType;
/// Create a copy of DetailsState /// Create a copy of DetailsState
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
$DetailsStateCopyWith<DetailsState> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $DetailsStateCopyWith<$Res> {
factory $DetailsStateCopyWith(
DetailsState value, $Res Function(DetailsState) then) =
_$DetailsStateCopyWithImpl<$Res, DetailsState>;
@useResult
$Res call(
{TrackingMedium? data,
String? heroImagePrefix,
TrackingMediumType trackingType});
}
/// @nodoc
class _$DetailsStateCopyWithImpl<$Res, $Val extends DetailsState>
implements $DetailsStateCopyWith<$Res> {
_$DetailsStateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of DetailsState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
$DetailsStateCopyWith<DetailsState> get copyWith =>
_$DetailsStateCopyWithImpl<DetailsState>(
this as DetailsState, _$identity);
@override @override
$Res call({ bool operator ==(Object other) {
Object? data = freezed, return identical(this, other) ||
Object? heroImagePrefix = freezed, (other.runtimeType == runtimeType &&
Object? trackingType = null, other is DetailsState &&
}) { (identical(other.data, data) || other.data == data) &&
return _then(_value.copyWith( (identical(other.heroImagePrefix, heroImagePrefix) ||
data: freezed == data other.heroImagePrefix == heroImagePrefix) &&
? _value.data (identical(other.trackingType, trackingType) ||
: data // ignore: cast_nullable_to_non_nullable other.trackingType == trackingType));
as TrackingMedium?, }
heroImagePrefix: freezed == heroImagePrefix
? _value.heroImagePrefix @override
: heroImagePrefix // ignore: cast_nullable_to_non_nullable int get hashCode =>
as String?, Object.hash(runtimeType, data, heroImagePrefix, trackingType);
trackingType: null == trackingType
? _value.trackingType @override
: trackingType // ignore: cast_nullable_to_non_nullable String toString() {
as TrackingMediumType, return 'DetailsState(data: $data, heroImagePrefix: $heroImagePrefix, trackingType: $trackingType)';
) as $Val);
} }
} }
/// @nodoc /// @nodoc
abstract class _$$DetailsStateImplCopyWith<$Res> abstract mixin class $DetailsStateCopyWith<$Res> {
implements $DetailsStateCopyWith<$Res> { factory $DetailsStateCopyWith(
factory _$$DetailsStateImplCopyWith( DetailsState value, $Res Function(DetailsState) _then) =
_$DetailsStateImpl value, $Res Function(_$DetailsStateImpl) then) = _$DetailsStateCopyWithImpl;
__$$DetailsStateImplCopyWithImpl<$Res>;
@override
@useResult @useResult
$Res call( $Res call(
{TrackingMedium? data, {TrackingMedium? data,
@@ -90,12 +61,11 @@ abstract class _$$DetailsStateImplCopyWith<$Res>
} }
/// @nodoc /// @nodoc
class __$$DetailsStateImplCopyWithImpl<$Res> class _$DetailsStateCopyWithImpl<$Res> implements $DetailsStateCopyWith<$Res> {
extends _$DetailsStateCopyWithImpl<$Res, _$DetailsStateImpl> _$DetailsStateCopyWithImpl(this._self, this._then);
implements _$$DetailsStateImplCopyWith<$Res> {
__$$DetailsStateImplCopyWithImpl( final DetailsState _self;
_$DetailsStateImpl _value, $Res Function(_$DetailsStateImpl) _then) final $Res Function(DetailsState) _then;
: super(_value, _then);
/// Create a copy of DetailsState /// Create a copy of DetailsState
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@@ -106,27 +76,190 @@ class __$$DetailsStateImplCopyWithImpl<$Res>
Object? heroImagePrefix = freezed, Object? heroImagePrefix = freezed,
Object? trackingType = null, Object? trackingType = null,
}) { }) {
return _then(_$DetailsStateImpl( return _then(_self.copyWith(
data: freezed == data data: freezed == data
? _value.data ? _self.data
: data // ignore: cast_nullable_to_non_nullable : data // ignore: cast_nullable_to_non_nullable
as TrackingMedium?, as TrackingMedium?,
heroImagePrefix: freezed == heroImagePrefix heroImagePrefix: freezed == heroImagePrefix
? _value.heroImagePrefix ? _self.heroImagePrefix
: heroImagePrefix // ignore: cast_nullable_to_non_nullable : heroImagePrefix // ignore: cast_nullable_to_non_nullable
as String?, as String?,
trackingType: null == trackingType trackingType: null == trackingType
? _value.trackingType ? _self.trackingType
: trackingType // ignore: cast_nullable_to_non_nullable : trackingType // ignore: cast_nullable_to_non_nullable
as TrackingMediumType, as TrackingMediumType,
)); ));
} }
} }
/// Adds pattern-matching-related methods to [DetailsState].
extension DetailsStatePatterns on DetailsState {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>(
TResult Function(_DetailsState value)? $default, {
required TResult orElse(),
}) {
final _that = this;
switch (_that) {
case _DetailsState() when $default != null:
return $default(_that);
case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs
TResult map<TResult extends Object?>(
TResult Function(_DetailsState value) $default,
) {
final _that = this;
switch (_that) {
case _DetailsState():
return $default(_that);
case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>(
TResult? Function(_DetailsState value)? $default,
) {
final _that = this;
switch (_that) {
case _DetailsState() when $default != null:
return $default(_that);
case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
TResult Function(TrackingMedium? data, String? heroImagePrefix,
TrackingMediumType trackingType)?
$default, {
required TResult orElse(),
}) {
final _that = this;
switch (_that) {
case _DetailsState() when $default != null:
return $default(_that.data, _that.heroImagePrefix, _that.trackingType);
case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs
TResult when<TResult extends Object?>(
TResult Function(TrackingMedium? data, String? heroImagePrefix,
TrackingMediumType trackingType)
$default,
) {
final _that = this;
switch (_that) {
case _DetailsState():
return $default(_that.data, _that.heroImagePrefix, _that.trackingType);
case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>(
TResult? Function(TrackingMedium? data, String? heroImagePrefix,
TrackingMediumType trackingType)?
$default,
) {
final _that = this;
switch (_that) {
case _DetailsState() when $default != null:
return $default(_that.data, _that.heroImagePrefix, _that.trackingType);
case _:
return null;
}
}
}
/// @nodoc /// @nodoc
class _$DetailsStateImpl implements _DetailsState { class _DetailsState implements DetailsState {
_$DetailsStateImpl( _DetailsState(
{this.data, {this.data,
this.heroImagePrefix, this.heroImagePrefix,
this.trackingType = TrackingMediumType.anime}); this.trackingType = TrackingMediumType.anime});
@@ -139,16 +272,19 @@ class _$DetailsStateImpl implements _DetailsState {
@JsonKey() @JsonKey()
final TrackingMediumType trackingType; final TrackingMediumType trackingType;
/// Create a copy of DetailsState
/// with the given fields replaced by the non-null parameter values.
@override @override
String toString() { @JsonKey(includeFromJson: false, includeToJson: false)
return 'DetailsState(data: $data, heroImagePrefix: $heroImagePrefix, trackingType: $trackingType)'; @pragma('vm:prefer-inline')
} _$DetailsStateCopyWith<_DetailsState> get copyWith =>
__$DetailsStateCopyWithImpl<_DetailsState>(this, _$identity);
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
return identical(this, other) || return identical(this, other) ||
(other.runtimeType == runtimeType && (other.runtimeType == runtimeType &&
other is _$DetailsStateImpl && other is _DetailsState &&
(identical(other.data, data) || other.data == data) && (identical(other.data, data) || other.data == data) &&
(identical(other.heroImagePrefix, heroImagePrefix) || (identical(other.heroImagePrefix, heroImagePrefix) ||
other.heroImagePrefix == heroImagePrefix) && other.heroImagePrefix == heroImagePrefix) &&
@@ -160,32 +296,58 @@ class _$DetailsStateImpl implements _DetailsState {
int get hashCode => int get hashCode =>
Object.hash(runtimeType, data, heroImagePrefix, trackingType); Object.hash(runtimeType, data, heroImagePrefix, trackingType);
@override
String toString() {
return 'DetailsState(data: $data, heroImagePrefix: $heroImagePrefix, trackingType: $trackingType)';
}
}
/// @nodoc
abstract mixin class _$DetailsStateCopyWith<$Res>
implements $DetailsStateCopyWith<$Res> {
factory _$DetailsStateCopyWith(
_DetailsState value, $Res Function(_DetailsState) _then) =
__$DetailsStateCopyWithImpl;
@override
@useResult
$Res call(
{TrackingMedium? data,
String? heroImagePrefix,
TrackingMediumType trackingType});
}
/// @nodoc
class __$DetailsStateCopyWithImpl<$Res>
implements _$DetailsStateCopyWith<$Res> {
__$DetailsStateCopyWithImpl(this._self, this._then);
final _DetailsState _self;
final $Res Function(_DetailsState) _then;
/// Create a copy of DetailsState /// Create a copy of DetailsState
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override @override
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
_$$DetailsStateImplCopyWith<_$DetailsStateImpl> get copyWith => $Res call({
__$$DetailsStateImplCopyWithImpl<_$DetailsStateImpl>(this, _$identity); Object? data = freezed,
Object? heroImagePrefix = freezed,
Object? trackingType = null,
}) {
return _then(_DetailsState(
data: freezed == data
? _self.data
: data // ignore: cast_nullable_to_non_nullable
as TrackingMedium?,
heroImagePrefix: freezed == heroImagePrefix
? _self.heroImagePrefix
: heroImagePrefix // ignore: cast_nullable_to_non_nullable
as String?,
trackingType: null == trackingType
? _self.trackingType
: trackingType // ignore: cast_nullable_to_non_nullable
as TrackingMediumType,
));
}
} }
abstract class _DetailsState implements DetailsState { // dart format on
factory _DetailsState(
{final TrackingMedium? data,
final String? heroImagePrefix,
final TrackingMediumType trackingType}) = _$DetailsStateImpl;
@override
TrackingMedium? get data;
@override
String? get heroImagePrefix;
@override
TrackingMediumType get trackingType;
/// Create a copy of DetailsState
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$DetailsStateImplCopyWith<_$DetailsStateImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@@ -1,7 +1,7 @@
part of 'details_bloc.dart'; part of 'details_bloc.dart';
@freezed @freezed
class DetailsState with _$DetailsState { abstract class DetailsState with _$DetailsState {
factory DetailsState({ factory DetailsState({
TrackingMedium? data, TrackingMedium? data,
String? heroImagePrefix, String? heroImagePrefix,

View File

@@ -75,8 +75,8 @@ class SettingsBloc extends Bloc<SettingsEvent, SettingsState> {
); );
_showLoadingSpinner(emit); _showLoadingSpinner(emit);
final inputStream = InputFileStream(event.path); final input = await File(event.path).readAsBytes();
final listRaw = GZipDecoder().decodeBuffer(inputStream); final listRaw = const GZipDecoder().decodeBytes(input);
final listXml = utf8.decode(listRaw); final listXml = utf8.decode(listRaw);
final document = XmlDocument.parse(listXml); final document = XmlDocument.parse(listXml);
final mal = document.getElement('myanimelist'); final mal = document.getElement('myanimelist');
@@ -148,8 +148,8 @@ class SettingsBloc extends Bloc<SettingsEvent, SettingsState> {
); );
_showLoadingSpinner(emit); _showLoadingSpinner(emit);
final inputStream = InputFileStream(event.path); final input = await File(event.path).readAsBytes();
final listRaw = GZipDecoder().decodeBuffer(inputStream); final listRaw = const archive.GZipDecoder().decodeBytes(input);
final listXml = utf8.decode(listRaw); final listXml = utf8.decode(listRaw);
final document = XmlDocument.parse(listXml); final document = XmlDocument.parse(listXml);
final mal = document.getElement('myanimelist'); final mal = document.getElement('myanimelist');
@@ -230,11 +230,9 @@ class SettingsBloc extends Bloc<SettingsEvent, SettingsState> {
event.path, event.path,
'anitrack_${date.year}${date.month}${date.day}.json.gz', 'anitrack_${date.year}${date.month}${date.day}.json.gz',
); );
archive.GZipEncoder().encode(
InputStream(utf8.encode(exportData)),
output: OutputFileStream(outputPath),
);
final output = const archive.GZipEncoder().encode(utf8.encode(exportData));
await File(outputPath).writeAsBytes(output);
await Fluttertoast.showToast( await Fluttertoast.showToast(
msg: t.settings.dataExportSuccess, msg: t.settings.dataExportSuccess,
); );

View File

@@ -1,5 +1,5 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND // GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// ignore_for_file: type=lint // 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 // 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
@@ -9,87 +9,62 @@ part of 'settings_bloc.dart';
// FreezedGenerator // FreezedGenerator
// ************************************************************************** // **************************************************************************
// dart format off
T _$identity<T>(T value) => value; 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');
/// @nodoc /// @nodoc
mixin _$SettingsState { mixin _$SettingsState {
bool get importSpinnerVisible => throw _privateConstructorUsedError; bool get importSpinnerVisible;
int get importCurrent => throw _privateConstructorUsedError; int get importCurrent;
int get importTotal => throw _privateConstructorUsedError; int get importTotal;
/// Create a copy of SettingsState /// Create a copy of SettingsState
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
$SettingsStateCopyWith<SettingsState> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $SettingsStateCopyWith<$Res> {
factory $SettingsStateCopyWith(
SettingsState value, $Res Function(SettingsState) then) =
_$SettingsStateCopyWithImpl<$Res, SettingsState>;
@useResult
$Res call({bool importSpinnerVisible, int importCurrent, int importTotal});
}
/// @nodoc
class _$SettingsStateCopyWithImpl<$Res, $Val extends SettingsState>
implements $SettingsStateCopyWith<$Res> {
_$SettingsStateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of SettingsState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
$SettingsStateCopyWith<SettingsState> get copyWith =>
_$SettingsStateCopyWithImpl<SettingsState>(
this as SettingsState, _$identity);
@override @override
$Res call({ bool operator ==(Object other) {
Object? importSpinnerVisible = null, return identical(this, other) ||
Object? importCurrent = null, (other.runtimeType == runtimeType &&
Object? importTotal = null, other is SettingsState &&
}) { (identical(other.importSpinnerVisible, importSpinnerVisible) ||
return _then(_value.copyWith( other.importSpinnerVisible == importSpinnerVisible) &&
importSpinnerVisible: null == importSpinnerVisible (identical(other.importCurrent, importCurrent) ||
? _value.importSpinnerVisible other.importCurrent == importCurrent) &&
: importSpinnerVisible // ignore: cast_nullable_to_non_nullable (identical(other.importTotal, importTotal) ||
as bool, other.importTotal == importTotal));
importCurrent: null == importCurrent }
? _value.importCurrent
: importCurrent // ignore: cast_nullable_to_non_nullable @override
as int, int get hashCode => Object.hash(
importTotal: null == importTotal runtimeType, importSpinnerVisible, importCurrent, importTotal);
? _value.importTotal
: importTotal // ignore: cast_nullable_to_non_nullable @override
as int, String toString() {
) as $Val); return 'SettingsState(importSpinnerVisible: $importSpinnerVisible, importCurrent: $importCurrent, importTotal: $importTotal)';
} }
} }
/// @nodoc /// @nodoc
abstract class _$$SettingsStateImplCopyWith<$Res> abstract mixin class $SettingsStateCopyWith<$Res> {
implements $SettingsStateCopyWith<$Res> { factory $SettingsStateCopyWith(
factory _$$SettingsStateImplCopyWith( SettingsState value, $Res Function(SettingsState) _then) =
_$SettingsStateImpl value, $Res Function(_$SettingsStateImpl) then) = _$SettingsStateCopyWithImpl;
__$$SettingsStateImplCopyWithImpl<$Res>;
@override
@useResult @useResult
$Res call({bool importSpinnerVisible, int importCurrent, int importTotal}); $Res call({bool importSpinnerVisible, int importCurrent, int importTotal});
} }
/// @nodoc /// @nodoc
class __$$SettingsStateImplCopyWithImpl<$Res> class _$SettingsStateCopyWithImpl<$Res>
extends _$SettingsStateCopyWithImpl<$Res, _$SettingsStateImpl> implements $SettingsStateCopyWith<$Res> {
implements _$$SettingsStateImplCopyWith<$Res> { _$SettingsStateCopyWithImpl(this._self, this._then);
__$$SettingsStateImplCopyWithImpl(
_$SettingsStateImpl _value, $Res Function(_$SettingsStateImpl) _then) final SettingsState _self;
: super(_value, _then); final $Res Function(SettingsState) _then;
/// Create a copy of SettingsState /// Create a copy of SettingsState
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@@ -100,27 +75,193 @@ class __$$SettingsStateImplCopyWithImpl<$Res>
Object? importCurrent = null, Object? importCurrent = null,
Object? importTotal = null, Object? importTotal = null,
}) { }) {
return _then(_$SettingsStateImpl( return _then(_self.copyWith(
importSpinnerVisible: null == importSpinnerVisible importSpinnerVisible: null == importSpinnerVisible
? _value.importSpinnerVisible ? _self.importSpinnerVisible
: importSpinnerVisible // ignore: cast_nullable_to_non_nullable : importSpinnerVisible // ignore: cast_nullable_to_non_nullable
as bool, as bool,
importCurrent: null == importCurrent importCurrent: null == importCurrent
? _value.importCurrent ? _self.importCurrent
: importCurrent // ignore: cast_nullable_to_non_nullable : importCurrent // ignore: cast_nullable_to_non_nullable
as int, as int,
importTotal: null == importTotal importTotal: null == importTotal
? _value.importTotal ? _self.importTotal
: importTotal // ignore: cast_nullable_to_non_nullable : importTotal // ignore: cast_nullable_to_non_nullable
as int, as int,
)); ));
} }
} }
/// Adds pattern-matching-related methods to [SettingsState].
extension SettingsStatePatterns on SettingsState {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>(
TResult Function(_SettingsState value)? $default, {
required TResult orElse(),
}) {
final _that = this;
switch (_that) {
case _SettingsState() when $default != null:
return $default(_that);
case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs
TResult map<TResult extends Object?>(
TResult Function(_SettingsState value) $default,
) {
final _that = this;
switch (_that) {
case _SettingsState():
return $default(_that);
case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>(
TResult? Function(_SettingsState value)? $default,
) {
final _that = this;
switch (_that) {
case _SettingsState() when $default != null:
return $default(_that);
case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>(
TResult Function(
bool importSpinnerVisible, int importCurrent, int importTotal)?
$default, {
required TResult orElse(),
}) {
final _that = this;
switch (_that) {
case _SettingsState() when $default != null:
return $default(
_that.importSpinnerVisible, _that.importCurrent, _that.importTotal);
case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs
TResult when<TResult extends Object?>(
TResult Function(
bool importSpinnerVisible, int importCurrent, int importTotal)
$default,
) {
final _that = this;
switch (_that) {
case _SettingsState():
return $default(
_that.importSpinnerVisible, _that.importCurrent, _that.importTotal);
case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>(
TResult? Function(
bool importSpinnerVisible, int importCurrent, int importTotal)?
$default,
) {
final _that = this;
switch (_that) {
case _SettingsState() when $default != null:
return $default(
_that.importSpinnerVisible, _that.importCurrent, _that.importTotal);
case _:
return null;
}
}
}
/// @nodoc /// @nodoc
class _$SettingsStateImpl implements _SettingsState { class _SettingsState implements SettingsState {
_$SettingsStateImpl( _SettingsState(
{this.importSpinnerVisible = false, {this.importSpinnerVisible = false,
this.importCurrent = 0, this.importCurrent = 0,
this.importTotal = 0}); this.importTotal = 0});
@@ -135,16 +276,19 @@ class _$SettingsStateImpl implements _SettingsState {
@JsonKey() @JsonKey()
final int importTotal; final int importTotal;
/// Create a copy of SettingsState
/// with the given fields replaced by the non-null parameter values.
@override @override
String toString() { @JsonKey(includeFromJson: false, includeToJson: false)
return 'SettingsState(importSpinnerVisible: $importSpinnerVisible, importCurrent: $importCurrent, importTotal: $importTotal)'; @pragma('vm:prefer-inline')
} _$SettingsStateCopyWith<_SettingsState> get copyWith =>
__$SettingsStateCopyWithImpl<_SettingsState>(this, _$identity);
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
return identical(this, other) || return identical(this, other) ||
(other.runtimeType == runtimeType && (other.runtimeType == runtimeType &&
other is _$SettingsStateImpl && other is _SettingsState &&
(identical(other.importSpinnerVisible, importSpinnerVisible) || (identical(other.importSpinnerVisible, importSpinnerVisible) ||
other.importSpinnerVisible == importSpinnerVisible) && other.importSpinnerVisible == importSpinnerVisible) &&
(identical(other.importCurrent, importCurrent) || (identical(other.importCurrent, importCurrent) ||
@@ -157,32 +301,55 @@ class _$SettingsStateImpl implements _SettingsState {
int get hashCode => Object.hash( int get hashCode => Object.hash(
runtimeType, importSpinnerVisible, importCurrent, importTotal); runtimeType, importSpinnerVisible, importCurrent, importTotal);
@override
String toString() {
return 'SettingsState(importSpinnerVisible: $importSpinnerVisible, importCurrent: $importCurrent, importTotal: $importTotal)';
}
}
/// @nodoc
abstract mixin class _$SettingsStateCopyWith<$Res>
implements $SettingsStateCopyWith<$Res> {
factory _$SettingsStateCopyWith(
_SettingsState value, $Res Function(_SettingsState) _then) =
__$SettingsStateCopyWithImpl;
@override
@useResult
$Res call({bool importSpinnerVisible, int importCurrent, int importTotal});
}
/// @nodoc
class __$SettingsStateCopyWithImpl<$Res>
implements _$SettingsStateCopyWith<$Res> {
__$SettingsStateCopyWithImpl(this._self, this._then);
final _SettingsState _self;
final $Res Function(_SettingsState) _then;
/// Create a copy of SettingsState /// Create a copy of SettingsState
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override @override
@pragma('vm:prefer-inline') @pragma('vm:prefer-inline')
_$$SettingsStateImplCopyWith<_$SettingsStateImpl> get copyWith => $Res call({
__$$SettingsStateImplCopyWithImpl<_$SettingsStateImpl>(this, _$identity); Object? importSpinnerVisible = null,
Object? importCurrent = null,
Object? importTotal = null,
}) {
return _then(_SettingsState(
importSpinnerVisible: null == importSpinnerVisible
? _self.importSpinnerVisible
: importSpinnerVisible // ignore: cast_nullable_to_non_nullable
as bool,
importCurrent: null == importCurrent
? _self.importCurrent
: importCurrent // ignore: cast_nullable_to_non_nullable
as int,
importTotal: null == importTotal
? _self.importTotal
: importTotal // ignore: cast_nullable_to_non_nullable
as int,
));
}
} }
abstract class _SettingsState implements SettingsState { // dart format on
factory _SettingsState(
{final bool importSpinnerVisible,
final int importCurrent,
final int importTotal}) = _$SettingsStateImpl;
@override
bool get importSpinnerVisible;
@override
int get importCurrent;
@override
int get importTotal;
/// Create a copy of SettingsState
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$SettingsStateImplCopyWith<_$SettingsStateImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@@ -1,7 +1,7 @@
part of 'settings_bloc.dart'; part of 'settings_bloc.dart';
@freezed @freezed
class SettingsState with _$SettingsState { abstract class SettingsState with _$SettingsState {
factory SettingsState({ factory SettingsState({
@Default(false) bool importSpinnerVisible, @Default(false) bool importSpinnerVisible,
@Default(0) int importCurrent, @Default(0) int importCurrent,

1
linux/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
flutter/ephemeral

128
linux/CMakeLists.txt Normal file
View File

@@ -0,0 +1,128 @@
# Project-level configuration.
cmake_minimum_required(VERSION 3.13)
project(runner LANGUAGES CXX)
# The name of the executable created for the application. Change this to change
# the on-disk name of your application.
set(BINARY_NAME "anitrack")
# The unique GTK application identifier for this application. See:
# https://wiki.gnome.org/HowDoI/ChooseApplicationID
set(APPLICATION_ID "me.polynom.anitrack")
# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
# versions of CMake.
cmake_policy(SET CMP0063 NEW)
# Load bundled libraries from the lib/ directory relative to the binary.
set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
# Root filesystem for cross-building.
if(FLUTTER_TARGET_PLATFORM_SYSROOT)
set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT})
set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
endif()
# Define build configuration options.
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Debug" CACHE
STRING "Flutter build mode" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Profile" "Release")
endif()
# Compilation settings that should be applied to most targets.
#
# Be cautious about adding new options here, as plugins use this function by
# default. In most cases, you should add new options to specific targets instead
# of modifying this function.
function(APPLY_STANDARD_SETTINGS TARGET)
target_compile_features(${TARGET} PUBLIC cxx_std_14)
target_compile_options(${TARGET} PRIVATE -Wall -Werror)
target_compile_options(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O3>")
target_compile_definitions(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>")
endfunction()
# Flutter library and tool build rules.
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
add_subdirectory(${FLUTTER_MANAGED_DIR})
# System-level dependencies.
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
# Application build; see runner/CMakeLists.txt.
add_subdirectory("runner")
# Run the Flutter tool portions of the build. This must not be removed.
add_dependencies(${BINARY_NAME} flutter_assemble)
# Only the install-generated bundle's copy of the executable will launch
# correctly, since the resources must in the right relative locations. To avoid
# people trying to run the unbundled copy, put it in a subdirectory instead of
# the default top-level location.
set_target_properties(${BINARY_NAME}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run"
)
# Generated plugin build rules, which manage building the plugins and adding
# them to the application.
include(flutter/generated_plugins.cmake)
# === Installation ===
# By default, "installing" just makes a relocatable bundle in the build
# directory.
set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle")
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
endif()
# Start with a clean build bundle directory every time.
install(CODE "
file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\")
" COMPONENT Runtime)
set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
COMPONENT Runtime)
install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
COMPONENT Runtime)
install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES})
install(FILES "${bundled_library}"
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
endforeach(bundled_library)
# Copy the native assets provided by the build.dart from all packages.
set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/")
install(DIRECTORY "${NATIVE_ASSETS_DIR}"
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
# Fully re-copy the assets directory on each build to avoid having stale files
# from a previous install.
set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
install(CODE "
file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
" COMPONENT Runtime)
install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
# Install the AOT library on non-Debug builds only.
if(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
endif()

View File

@@ -0,0 +1,88 @@
# This file controls Flutter-level build steps. It should not be edited.
cmake_minimum_required(VERSION 3.10)
set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
# Configuration provided via flutter tool.
include(${EPHEMERAL_DIR}/generated_config.cmake)
# TODO: Move the rest of this into files in ephemeral. See
# https://github.com/flutter/flutter/issues/57146.
# Serves the same purpose as list(TRANSFORM ... PREPEND ...),
# which isn't available in 3.10.
function(list_prepend LIST_NAME PREFIX)
set(NEW_LIST "")
foreach(element ${${LIST_NAME}})
list(APPEND NEW_LIST "${PREFIX}${element}")
endforeach(element)
set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE)
endfunction()
# === Flutter Library ===
# System-level dependencies.
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0)
pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0)
set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so")
# Published to parent scope for install step.
set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE)
list(APPEND FLUTTER_LIBRARY_HEADERS
"fl_basic_message_channel.h"
"fl_binary_codec.h"
"fl_binary_messenger.h"
"fl_dart_project.h"
"fl_engine.h"
"fl_json_message_codec.h"
"fl_json_method_codec.h"
"fl_message_codec.h"
"fl_method_call.h"
"fl_method_channel.h"
"fl_method_codec.h"
"fl_method_response.h"
"fl_plugin_registrar.h"
"fl_plugin_registry.h"
"fl_standard_message_codec.h"
"fl_standard_method_codec.h"
"fl_string_codec.h"
"fl_value.h"
"fl_view.h"
"flutter_linux.h"
)
list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/")
add_library(flutter INTERFACE)
target_include_directories(flutter INTERFACE
"${EPHEMERAL_DIR}"
)
target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}")
target_link_libraries(flutter INTERFACE
PkgConfig::GTK
PkgConfig::GLIB
PkgConfig::GIO
)
add_dependencies(flutter flutter_assemble)
# === Flutter tool backend ===
# _phony_ is a non-existent file to force this command to run every time,
# since currently there's no way to get a full input/output list from the
# flutter tool.
add_custom_command(
OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
${CMAKE_CURRENT_BINARY_DIR}/_phony_
COMMAND ${CMAKE_COMMAND} -E env
${FLUTTER_TOOL_ENVIRONMENT}
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh"
${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE}
VERBATIM
)
add_custom_target(flutter_assemble DEPENDS
"${FLUTTER_LIBRARY}"
${FLUTTER_LIBRARY_HEADERS}
)

View File

@@ -0,0 +1,15 @@
//
// Generated file. Do not edit.
//
// clang-format off
#include "generated_plugin_registrant.h"
#include <url_launcher_linux/url_launcher_plugin.h>
void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
}

View File

@@ -0,0 +1,15 @@
//
// Generated file. Do not edit.
//
// clang-format off
#ifndef GENERATED_PLUGIN_REGISTRANT_
#define GENERATED_PLUGIN_REGISTRANT_
#include <flutter_linux/flutter_linux.h>
// Registers Flutter plugins.
void fl_register_plugins(FlPluginRegistry* registry);
#endif // GENERATED_PLUGIN_REGISTRANT_

View File

@@ -0,0 +1,24 @@
#
# Generated file, do not edit.
#
list(APPEND FLUTTER_PLUGIN_LIST
url_launcher_linux
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST
)
set(PLUGIN_BUNDLED_LIBRARIES)
foreach(plugin ${FLUTTER_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin})
target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
endforeach(plugin)
foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
endforeach(ffi_plugin)

View File

@@ -0,0 +1,26 @@
cmake_minimum_required(VERSION 3.13)
project(runner LANGUAGES CXX)
# Define the application target. To change its name, change BINARY_NAME in the
# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer
# work.
#
# Any new source files that you add to the application should be added here.
add_executable(${BINARY_NAME}
"main.cc"
"my_application.cc"
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
)
# Apply the standard set of build settings. This can be removed for applications
# that need different build settings.
apply_standard_settings(${BINARY_NAME})
# Add preprocessor definitions for the application ID.
add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}")
# Add dependency libraries. Add any application-specific dependencies here.
target_link_libraries(${BINARY_NAME} PRIVATE flutter)
target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK)
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")

6
linux/runner/main.cc Normal file
View File

@@ -0,0 +1,6 @@
#include "my_application.h"
int main(int argc, char** argv) {
g_autoptr(MyApplication) app = my_application_new();
return g_application_run(G_APPLICATION(app), argc, argv);
}

View File

@@ -0,0 +1,148 @@
#include "my_application.h"
#include <flutter_linux/flutter_linux.h>
#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
#endif
#include "flutter/generated_plugin_registrant.h"
struct _MyApplication {
GtkApplication parent_instance;
char** dart_entrypoint_arguments;
};
G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)
// Called when first Flutter frame received.
static void first_frame_cb(MyApplication* self, FlView* view) {
gtk_widget_show(gtk_widget_get_toplevel(GTK_WIDGET(view)));
}
// Implements GApplication::activate.
static void my_application_activate(GApplication* application) {
MyApplication* self = MY_APPLICATION(application);
GtkWindow* window =
GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));
// Use a header bar when running in GNOME as this is the common style used
// by applications and is the setup most users will be using (e.g. Ubuntu
// desktop).
// If running on X and not using GNOME then just use a traditional title bar
// in case the window manager does more exotic layout, e.g. tiling.
// If running on Wayland assume the header bar will work (may need changing
// if future cases occur).
gboolean use_header_bar = TRUE;
#ifdef GDK_WINDOWING_X11
GdkScreen* screen = gtk_window_get_screen(window);
if (GDK_IS_X11_SCREEN(screen)) {
const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen);
if (g_strcmp0(wm_name, "GNOME Shell") != 0) {
use_header_bar = FALSE;
}
}
#endif
if (use_header_bar) {
GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
gtk_widget_show(GTK_WIDGET(header_bar));
gtk_header_bar_set_title(header_bar, "anitrack");
gtk_header_bar_set_show_close_button(header_bar, TRUE);
gtk_window_set_titlebar(window, GTK_WIDGET(header_bar));
} else {
gtk_window_set_title(window, "anitrack");
}
gtk_window_set_default_size(window, 1280, 720);
g_autoptr(FlDartProject) project = fl_dart_project_new();
fl_dart_project_set_dart_entrypoint_arguments(
project, self->dart_entrypoint_arguments);
FlView* view = fl_view_new(project);
GdkRGBA background_color;
// Background defaults to black, override it here if necessary, e.g. #00000000
// for transparent.
gdk_rgba_parse(&background_color, "#000000");
fl_view_set_background_color(view, &background_color);
gtk_widget_show(GTK_WIDGET(view));
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view));
// Show the window when Flutter renders.
// Requires the view to be realized so we can start rendering.
g_signal_connect_swapped(view, "first-frame", G_CALLBACK(first_frame_cb),
self);
gtk_widget_realize(GTK_WIDGET(view));
fl_register_plugins(FL_PLUGIN_REGISTRY(view));
gtk_widget_grab_focus(GTK_WIDGET(view));
}
// Implements GApplication::local_command_line.
static gboolean my_application_local_command_line(GApplication* application,
gchar*** arguments,
int* exit_status) {
MyApplication* self = MY_APPLICATION(application);
// Strip out the first argument as it is the binary name.
self->dart_entrypoint_arguments = g_strdupv(*arguments + 1);
g_autoptr(GError) error = nullptr;
if (!g_application_register(application, nullptr, &error)) {
g_warning("Failed to register: %s", error->message);
*exit_status = 1;
return TRUE;
}
g_application_activate(application);
*exit_status = 0;
return TRUE;
}
// Implements GApplication::startup.
static void my_application_startup(GApplication* application) {
// MyApplication* self = MY_APPLICATION(object);
// Perform any actions required at application startup.
G_APPLICATION_CLASS(my_application_parent_class)->startup(application);
}
// Implements GApplication::shutdown.
static void my_application_shutdown(GApplication* application) {
// MyApplication* self = MY_APPLICATION(object);
// Perform any actions required at application shutdown.
G_APPLICATION_CLASS(my_application_parent_class)->shutdown(application);
}
// Implements GObject::dispose.
static void my_application_dispose(GObject* object) {
MyApplication* self = MY_APPLICATION(object);
g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev);
G_OBJECT_CLASS(my_application_parent_class)->dispose(object);
}
static void my_application_class_init(MyApplicationClass* klass) {
G_APPLICATION_CLASS(klass)->activate = my_application_activate;
G_APPLICATION_CLASS(klass)->local_command_line =
my_application_local_command_line;
G_APPLICATION_CLASS(klass)->startup = my_application_startup;
G_APPLICATION_CLASS(klass)->shutdown = my_application_shutdown;
G_OBJECT_CLASS(klass)->dispose = my_application_dispose;
}
static void my_application_init(MyApplication* self) {}
MyApplication* my_application_new() {
// Set the program name to the application ID, which helps various systems
// like GTK and desktop environments map this running application to its
// corresponding .desktop file. This ensures better integration by allowing
// the application to be recognized beyond its binary name.
g_set_prgname(APPLICATION_ID);
return MY_APPLICATION(g_object_new(my_application_get_type(),
"application-id", APPLICATION_ID, "flags",
G_APPLICATION_NON_UNIQUE, nullptr));
}

View File

@@ -0,0 +1,21 @@
#ifndef FLUTTER_MY_APPLICATION_H_
#define FLUTTER_MY_APPLICATION_H_
#include <gtk/gtk.h>
G_DECLARE_FINAL_TYPE(MyApplication,
my_application,
MY,
APPLICATION,
GtkApplication)
/**
* my_application_new:
*
* Creates a new Flutter-based application.
*
* Returns: a new #MyApplication.
*/
MyApplication* my_application_new();
#endif // FLUTTER_MY_APPLICATION_H_

File diff suppressed because it is too large Load Diff

View File

@@ -2,32 +2,33 @@ name: anitrack
description: An anime and manga tracker description: An anime and manga tracker
publish_to: "none" publish_to: "none"
version: 0.1.3+2011 version: 0.1.3+2013
environment: environment:
sdk: ">=3.0.0 <4.0.0" sdk: ^3.8.0
dependencies: dependencies:
archive: ^3.6.1 archive: ^4.0.9
bloc: ^8.1.4 bloc: ^9.2.0
bottom_bar: ^2.0.3 bottom_bar: ^2.0.3
cached_network_image: ^3.4.1 cached_network_image: ^3.4.1
collection: ^1.18.0 collection: ^1.18.0
cupertino_icons: ^1.0.8 cupertino_icons: ^1.0.8
file_picker: ^8.1.2 file_picker: ^10.3.10
flutter: flutter:
sdk: flutter sdk: flutter
flutter_bloc: ^8.1.6 flutter_bloc: ^9.1.1
fluttertoast: ^8.2.8 fluttertoast: ^9.0.0
freezed_annotation: ^2.4.4 freezed_annotation: ^3.1.0
get_it: ^8.0.0 get_it: ^9.2.1
jikan_api: ^2.2.1 jikan_api: ^2.2.1
json_annotation: ^4.9.0 json_annotation: ^4.11.0
path: ^1.9.0 path: ^1.9.0
permission_handler: ^11.3.1 permission_handler: ^12.0.1
slang: ^3.31.2 slang: ^4.13.0
slang_flutter: ^3.31.0 slang_flutter: ^4.13.0
sqflite: ^2.3.3+2 sqflite: ^2.3.3+2
sqflite_common_ffi:
swipeable_tile: ^2.0.1 swipeable_tile: ^2.0.1
url_launcher: ^6.3.0 url_launcher: ^6.3.0
xml: ^6.5.0 xml: ^6.5.0
@@ -35,14 +36,14 @@ dependencies:
dev_dependencies: dev_dependencies:
build_runner: ^2.4.12 build_runner: ^2.4.12
flutter_launcher_icons: ^0.14.1 flutter_launcher_icons: ^0.14.1
flutter_lints: ^5.0.0 flutter_lints: ^6.0.0
flutter_oss_licenses: ^3.0.2 flutter_oss_licenses: ^3.0.2
flutter_test: flutter_test:
sdk: flutter sdk: flutter
freezed: ^2.5.7 freezed: ^3.2.5
json_serializable: ^6.8.0 json_serializable: ^6.8.0
slang_build_runner: ^3.31.0 slang_build_runner: ^4.13.0
very_good_analysis: ^6.0.0 very_good_analysis: ^10.2.0
flutter: flutter:
uses-material-design: true uses-material-design: true