claude refactorings, flutter best practices, platform dependent changes, general cleanup

This commit is contained in:
2026-05-06 11:58:50 +02:00
parent 4b1d4379a0
commit 4e1272aba9
281 changed files with 1948 additions and 1041 deletions
+73 -29
View File
@@ -1,44 +1,88 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
# Static analysis configuration for the Flutter project.
# https://dart.dev/guides/language/analysis-options
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.
# Base ruleset: flutter_lints (recommended Flutter defaults).
# Additional lints below catch real bugs and enforce consistent style.
# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml
analyzer:
language:
strict-casts: true
strict-raw-types: true
errors:
invalid_annotation_target: ignore
todo: ignore
exclude:
- "**/*.g.dart"
- "**/*.freezed.dart"
- "lib/firebase_options.dart"
- "build/**"
linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
file_names: false
# === Project conventions ===
prefer_relative_imports: true
unnecessary_lambdas: true
prefer_single_quotes: true
prefer_if_elements_to_conditional_expressions: true
prefer_expression_function_bodies: true
omit_local_variable_types: true
eol_at_end_of_file: true
cast_nullable_to_non_nullable: true
avoid_void_async: true
omit_local_variable_types: true
avoid_multiple_declarations_per_line: true
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
# === Bug catchers ===
always_declare_return_types: true
avoid_empty_else: true
avoid_slow_async_io: true
avoid_type_to_string: true
avoid_void_async: true
await_only_futures: true
cancel_subscriptions: true
cast_nullable_to_non_nullable: true
close_sinks: true
empty_catches: true
hash_and_equals: true
no_adjacent_strings_in_list: true
no_duplicate_case_values: true
test_types_in_equals: true
throw_in_finally: true
unawaited_futures: true
unnecessary_statements: true
unrelated_type_equality_checks: true
use_build_context_synchronously: true
valid_regexps: true
# === Flutter widget hygiene ===
avoid_unnecessary_containers: true
sized_box_for_whitespace: true
sort_child_properties_last: true
use_colored_box: true
use_decorated_box: true
use_full_hex_values_for_flutter_colors: true
use_key_in_widget_constructors: true
# === Code clarity ===
directives_ordering: true
library_prefixes: true
no_leading_underscores_for_local_identifiers: true
prefer_conditional_assignment: true
prefer_if_elements_to_conditional_expressions: true
prefer_if_null_operators: true
prefer_initializing_formals: true
prefer_interpolation_to_compose_strings: true
prefer_is_empty: true
prefer_is_not_empty: true
prefer_is_not_operator: true
prefer_iterable_whereType: true
prefer_null_aware_operators: true
prefer_spread_collections: true
prefer_void_to_null: true
unnecessary_await_in_return: true
unnecessary_brace_in_string_interps: true
unnecessary_lambdas: true
unnecessary_null_aware_assignments: true
unnecessary_null_checks: true
unnecessary_parenthesis: true
unnecessary_string_interpolations: true
use_super_parameters: true
# === File naming ===
file_names: true
+1 -1
View File
@@ -25,7 +25,7 @@ if (flutterVersionName == null) {
android {
namespace "eu.mhsl.marianum.mobile.client"
compileSdk flutter.compileSdkVersion
ndkVersion "27.0.12077973"
ndkVersion "28.2.13676358"
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
+3 -3
View File
@@ -3,9 +3,9 @@ import 'dart:io';
import 'package:http/http.dart' as http;
import '../apiError.dart';
import '../marianumcloud/talk/talkError.dart';
import '../webuntis/webuntisError.dart';
import '../api_error.dart';
import '../marianumcloud/talk/talk_error.dart';
import '../webuntis/webuntis_error.dart';
import 'app_exception.dart';
import 'network_exception.dart';
import 'parse_exception.dart';
+1 -1
View File
@@ -1,4 +1,4 @@
import '../marianumcloud/talk/talkError.dart';
import '../marianumcloud/talk/talk_error.dart';
import 'app_exception.dart';
class TalkException extends AppException {
+1 -1
View File
@@ -1,4 +1,4 @@
import '../webuntis/webuntisError.dart';
import '../webuntis/webuntis_error.dart';
import 'app_exception.dart';
class WebuntisException extends AppException {
@@ -1,7 +1,7 @@
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'getHolidaysResponse.dart';
import 'get_holidays_response.dart';
class GetHolidays {
Future<GetHolidaysResponse> query() async {
@@ -1,6 +1,6 @@
import '../requestCache.dart';
import 'getHolidays.dart';
import 'getHolidaysResponse.dart';
import '../request_cache.dart';
import 'get_holidays.dart';
import 'get_holidays_response.dart';
class GetHolidaysCache extends SimpleCache<GetHolidaysResponse> {
GetHolidaysCache({super.onUpdate, super.renew})
@@ -1,9 +1,9 @@
import 'package:json_annotation/json_annotation.dart';
import '../apiResponse.dart';
import '../api_response.dart';
part 'getHolidaysResponse.g.dart';
part 'get_holidays_response.g.dart';
@JsonSerializable(explicitToJson: true)
class GetHolidaysResponse extends ApiResponse {
@@ -1,6 +1,6 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'getHolidaysResponse.dart';
part of 'get_holidays_response.dart';
// **************************************************************************
// JsonSerializableGenerator
@@ -4,7 +4,7 @@ import 'dart:io';
import 'package:http/http.dart' as http;
import '../nextcloud_ocs.dart';
import 'autocompleteResponse.dart';
import 'autocomplete_response.dart';
class AutocompleteApi {
Future<AutocompleteResponse> find(String query) async {
@@ -22,6 +22,7 @@ class AutocompleteApi {
if (response.statusCode != HttpStatus.ok) {
throw Exception('Api call failed with ${response.statusCode}: ${response.body}');
}
return AutocompleteResponse.fromJson(jsonDecode(response.body)['ocs']);
final decoded = jsonDecode(response.body) as Map<String, dynamic>;
return AutocompleteResponse.fromJson(decoded['ocs'] as Map<String, dynamic>);
}
}
@@ -1,6 +1,6 @@
import 'package:json_annotation/json_annotation.dart';
part 'autocompleteResponse.g.dart';
part 'autocomplete_response.g.dart';
@JsonSerializable(explicitToJson: true)
class AutocompleteResponse {
@@ -1,6 +1,6 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'autocompleteResponse.dart';
part of 'autocomplete_response.dart';
// **************************************************************************
// JsonSerializableGenerator
@@ -3,7 +3,7 @@ import 'dart:io';
import 'package:http/http.dart' as http;
import '../nextcloud_ocs.dart';
import 'fileSharingApiParams.dart';
import 'file_sharing_api_params.dart';
class FileSharingApi {
Future<void> share(FileSharingApiParams query) async {
@@ -1,6 +1,6 @@
import 'package:json_annotation/json_annotation.dart';
part 'fileSharingApiParams.g.dart';
part 'file_sharing_api_params.g.dart';
@JsonSerializable()
class FileSharingApiParams {
@@ -1,6 +1,6 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'fileSharingApiParams.dart';
part of 'file_sharing_api_params.dart';
// **************************************************************************
// JsonSerializableGenerator
@@ -1,8 +1,8 @@
import 'package:http/http.dart' as http;
import '../../../apiParams.dart';
import '../../../apiResponse.dart';
import '../talkApi.dart';
import '../../../api_params.dart';
import '../../../api_response.dart';
import '../talk_api.dart';
/// Small POST/DELETE-only Talk endpoints that have no response payload.
/// Each class extends [TalkApi] with `assemble` returning `null`. They share
@@ -3,9 +3,9 @@ import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:http/http.dart';
import '../talkApi.dart';
import 'getChatParams.dart';
import 'getChatResponse.dart';
import '../talk_api.dart';
import 'get_chat_params.dart';
import 'get_chat_response.dart';
class GetChat extends TalkApi<GetChatResponse> {
String chatToken;
@@ -14,7 +14,10 @@ class GetChat extends TalkApi<GetChatResponse> {
GetChat(this.chatToken, this.params) : super('v1/chat/$chatToken', null, getParameters: params.toJson());
@override
assemble(String raw) => GetChatResponse.fromJson(jsonDecode(raw)['ocs']);
GetChatResponse assemble(String raw) {
final decoded = jsonDecode(raw) as Map<String, dynamic>;
return GetChatResponse.fromJson(decoded['ocs'] as Map<String, dynamic>);
}
@override
Future<Response> request(Uri uri, Object? body, Map<String, String>? headers) => http.get(uri, headers: headers);
@@ -1,7 +1,7 @@
import '../../../requestCache.dart';
import 'getChat.dart';
import 'getChatParams.dart';
import 'getChatResponse.dart';
import '../../../request_cache.dart';
import 'get_chat.dart';
import 'get_chat_params.dart';
import 'get_chat_response.dart';
class GetChatCache extends SimpleCache<GetChatResponse> {
GetChatCache({
@@ -1,8 +1,8 @@
import 'package:json_annotation/json_annotation.dart';
import '../../../apiParams.dart';
import '../../../api_params.dart';
part 'getChatParams.g.dart';
part 'get_chat_params.g.dart';
@JsonSerializable(explicitToJson: true, includeIfNull: false)
class GetChatParams extends ApiParams {
@@ -1,6 +1,6 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'getChatParams.dart';
part of 'get_chat_params.dart';
// **************************************************************************
// JsonSerializableGenerator
@@ -1,10 +1,10 @@
import 'package:jiffy/jiffy.dart';
import 'package:json_annotation/json_annotation.dart';
import '../../../apiResponse.dart';
import '../room/getRoomResponse.dart';
import '../../../api_response.dart';
import '../room/get_room_response.dart';
part 'getChatResponse.g.dart';
part 'get_chat_response.g.dart';
@JsonSerializable(explicitToJson: true)
class GetChatResponse extends ApiResponse {
@@ -88,9 +88,9 @@ class GetChatResponseObject {
Map<String, RichObjectString>? _fromJson(dynamic json) {
if (json is Map<String, dynamic>) {
var data = <String, RichObjectString>{};
for (var element in json.keys) {
data.putIfAbsent(element, () => RichObjectString.fromJson(json[element]));
final data = <String, RichObjectString>{};
for (final element in json.keys) {
data.putIfAbsent(element, () => RichObjectString.fromJson(json[element] as Map<String, dynamic>));
}
return data;
}
@@ -1,6 +1,6 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'getChatResponse.dart';
part of 'get_chat_response.dart';
// **************************************************************************
// JsonSerializableGenerator
@@ -1,5 +1,5 @@
import 'getChatResponse.dart';
import 'get_chat_response.dart';
class RichObjectStringProcessor {
static String parseToString(String message, Map<String, RichObjectString>? data) {
@@ -2,15 +2,15 @@
import 'package:http/http.dart' as http;
import 'package:http/http.dart';
import '../talkApi.dart';
import 'createRoomParams.dart';
import '../talk_api.dart';
import 'create_room_params.dart';
class CreateRoom extends TalkApi {
CreateRoomParams params;
CreateRoom(this.params) : super('v4/room', params);
@override
assemble(String raw) => null;
Null assemble(String raw) => null;
@override
Future<Response>? request(Uri uri, Object? body, Map<String, String>? headers) {
@@ -1,8 +1,8 @@
import 'package:json_annotation/json_annotation.dart';
import '../../../apiParams.dart';
import '../../../api_params.dart';
part 'createRoomParams.g.dart';
part 'create_room_params.g.dart';
@JsonSerializable()
class CreateRoomParams extends ApiParams {
@@ -1,6 +1,6 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'createRoomParams.dart';
part of 'create_room_params.dart';
// **************************************************************************
// JsonSerializableGenerator
@@ -1,9 +1,9 @@
import 'package:http/http.dart' as http;
import 'package:http/http.dart';
import '../../../apiParams.dart';
import '../talkApi.dart';
import 'deleteReactMessageParams.dart';
import '../../../api_params.dart';
import '../talk_api.dart';
import 'delete_react_message_params.dart';
class DeleteReactMessage extends TalkApi {
String chatToken;
@@ -11,7 +11,7 @@ class DeleteReactMessage extends TalkApi {
DeleteReactMessage({required this.chatToken, required this.messageId, required DeleteReactMessageParams params}) : super('v1/reaction/$chatToken/$messageId', params);
@override
assemble(String raw) => null;
Null assemble(String raw) => null;
@override
Future<Response>? request(Uri uri, ApiParams? body, Map<String, String>? headers) {
@@ -1,8 +1,8 @@
import 'package:json_annotation/json_annotation.dart';
import '../../../apiParams.dart';
import '../../../api_params.dart';
part 'deleteReactMessageParams.g.dart';
part 'delete_react_message_params.g.dart';
@JsonSerializable()
class DeleteReactMessageParams extends ApiParams {
@@ -1,6 +1,6 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'deleteReactMessageParams.dart';
part of 'delete_react_message_params.dart';
// **************************************************************************
// JsonSerializableGenerator
@@ -2,15 +2,18 @@ import 'dart:convert';
import 'package:http/http.dart' as http;
import '../talkApi.dart';
import 'getParticipantsResponse.dart';
import '../talk_api.dart';
import 'get_participants_response.dart';
class GetParticipants extends TalkApi<GetParticipantsResponse> {
String token;
GetParticipants(this.token) : super('v4/room/$token/participants', null);
@override
GetParticipantsResponse assemble(String raw) => GetParticipantsResponse.fromJson(jsonDecode(raw)['ocs']);
GetParticipantsResponse assemble(String raw) {
final decoded = jsonDecode(raw) as Map<String, dynamic>;
return GetParticipantsResponse.fromJson(decoded['ocs'] as Map<String, dynamic>);
}
@override
Future<http.Response> request(Uri uri, Object? body, Map<String, String>? headers) => http.get(uri, headers: headers);
@@ -1,6 +1,6 @@
import '../../../requestCache.dart';
import 'getParticipants.dart';
import 'getParticipantsResponse.dart';
import '../../../request_cache.dart';
import 'get_participants.dart';
import 'get_participants_response.dart';
class GetParticipantsCache extends SimpleCache<GetParticipantsResponse> {
GetParticipantsCache({
@@ -1,9 +1,9 @@
import 'package:json_annotation/json_annotation.dart';
import '../../../apiResponse.dart';
import '../../../api_response.dart';
part 'getParticipantsResponse.g.dart';
part 'get_participants_response.g.dart';
@JsonSerializable(explicitToJson: true)
class GetParticipantsResponse extends ApiResponse {
@@ -1,6 +1,6 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'getParticipantsResponse.dart';
part of 'get_participants_response.dart';
// **************************************************************************
// JsonSerializableGenerator
@@ -2,8 +2,8 @@ import 'dart:convert';
import 'package:http/http.dart' as http;
import '../talkApi.dart';
import 'getPollStateResponse.dart';
import '../talk_api.dart';
import 'get_poll_state_response.dart';
class GetPollState extends TalkApi<GetPollStateResponse> {
String token;
@@ -11,7 +11,10 @@ class GetPollState extends TalkApi<GetPollStateResponse> {
GetPollState({required this.token, required this.pollId}) : super('v1/poll/$token/$pollId', null);
@override
GetPollStateResponse assemble(String raw) => GetPollStateResponse.fromJson(jsonDecode(raw)['ocs']);
GetPollStateResponse assemble(String raw) {
final decoded = jsonDecode(raw) as Map<String, dynamic>;
return GetPollStateResponse.fromJson(decoded['ocs'] as Map<String, dynamic>);
}
@override
Future<http.Response> request(Uri uri, Object? body, Map<String, String>? headers) => http.get(uri, headers: headers);
@@ -1,8 +1,8 @@
import 'package:json_annotation/json_annotation.dart';
import '../../../apiResponse.dart';
import '../../../api_response.dart';
part 'getPollStateResponse.g.dart';
part 'get_poll_state_response.g.dart';
@JsonSerializable(explicitToJson: true)
class GetPollStateResponse extends ApiResponse {
@@ -1,6 +1,6 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'getPollStateResponse.dart';
part of 'get_poll_state_response.dart';
// **************************************************************************
// JsonSerializableGenerator
@@ -3,9 +3,9 @@ import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:http/http.dart';
import '../../../apiParams.dart';
import '../talkApi.dart';
import 'getReactionsResponse.dart';
import '../../../api_params.dart';
import '../talk_api.dart';
import 'get_reactions_response.dart';
class GetReactions extends TalkApi<GetReactionsResponse> {
String chatToken;
@@ -13,7 +13,10 @@ class GetReactions extends TalkApi<GetReactionsResponse> {
GetReactions({required this.chatToken, required this.messageId}) : super('v1/reaction/$chatToken/$messageId', null);
@override
assemble(String raw) => GetReactionsResponse.fromJson(jsonDecode(raw)['ocs']);
GetReactionsResponse assemble(String raw) {
final decoded = jsonDecode(raw) as Map<String, dynamic>;
return GetReactionsResponse.fromJson(decoded['ocs'] as Map<String, dynamic>);
}
@override
Future<Response>? request(Uri uri, ApiParams? body, Map<String, String>? headers) => http.get(uri, headers: headers);
@@ -1,8 +1,8 @@
import 'package:json_annotation/json_annotation.dart';
import '../../../apiResponse.dart';
import '../../../api_response.dart';
part 'getReactionsResponse.g.dart';
part 'get_reactions_response.g.dart';
@JsonSerializable(explicitToJson: true)
class GetReactionsResponse extends ApiResponse {
@@ -1,6 +1,6 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'getReactionsResponse.dart';
part of 'get_reactions_response.dart';
// **************************************************************************
// JsonSerializableGenerator
@@ -1,9 +1,9 @@
import 'package:http/http.dart' as http;
import 'package:http/http.dart';
import '../../../apiParams.dart';
import '../talkApi.dart';
import 'reactMessageParams.dart';
import '../../../api_params.dart';
import '../talk_api.dart';
import 'react_message_params.dart';
class ReactMessage extends TalkApi {
String chatToken;
@@ -11,7 +11,7 @@ class ReactMessage extends TalkApi {
ReactMessage({required this.chatToken, required this.messageId, required ReactMessageParams params}) : super('v1/reaction/$chatToken/$messageId', params);
@override
assemble(String raw) => null;
Null assemble(String raw) => null;
@override
Future<Response>? request(Uri uri, ApiParams? body, Map<String, String>? headers) {
@@ -1,8 +1,8 @@
import 'package:json_annotation/json_annotation.dart';
import '../../../apiParams.dart';
import '../../../api_params.dart';
part 'reactMessageParams.g.dart';
part 'react_message_params.g.dart';
@JsonSerializable()
class ReactMessageParams extends ApiParams {
@@ -1,6 +1,6 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'reactMessageParams.dart';
part of 'react_message_params.dart';
// **************************************************************************
// JsonSerializableGenerator
@@ -2,9 +2,9 @@ import 'dart:convert';
import 'package:http/http.dart' as http;
import '../talkApi.dart';
import 'getRoomParams.dart';
import 'getRoomResponse.dart';
import '../talk_api.dart';
import 'get_room_params.dart';
import 'get_room_response.dart';
class GetRoom extends TalkApi<GetRoomResponse> {
@@ -14,7 +14,10 @@ class GetRoom extends TalkApi<GetRoomResponse> {
@override
GetRoomResponse assemble(String raw) => GetRoomResponse.fromJson(jsonDecode(raw)['ocs']);
GetRoomResponse assemble(String raw) {
final decoded = jsonDecode(raw) as Map<String, dynamic>;
return GetRoomResponse.fromJson(decoded['ocs'] as Map<String, dynamic>);
}
@override
Future<http.Response> request(Uri uri, Object? body, Map<String, String>? headers) => http.get(uri, headers: headers);
@@ -1,7 +1,7 @@
import '../../../requestCache.dart';
import 'getRoom.dart';
import 'getRoomParams.dart';
import 'getRoomResponse.dart';
import '../../../request_cache.dart';
import 'get_room.dart';
import 'get_room_params.dart';
import 'get_room_response.dart';
class GetRoomCache extends SimpleCache<GetRoomResponse> {
GetRoomCache({super.onUpdate, super.onError, super.renew})
@@ -1,9 +1,9 @@
import 'package:json_annotation/json_annotation.dart';
import '../../../apiParams.dart';
import '../../../api_params.dart';
part 'getRoomParams.g.dart';
part 'get_room_params.g.dart';
@JsonSerializable(explicitToJson: true)
class GetRoomParams extends ApiParams {
@@ -1,6 +1,6 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'getRoomParams.dart';
part of 'get_room_params.dart';
// **************************************************************************
// JsonSerializableGenerator
@@ -1,9 +1,9 @@
import 'package:json_annotation/json_annotation.dart';
import '../../../apiResponse.dart';
import '../chat/getChatResponse.dart';
import '../../../api_response.dart';
import '../chat/get_chat_response.dart';
part 'getRoomResponse.g.dart';
part 'get_room_response.g.dart';
@JsonSerializable(explicitToJson: true)
class GetRoomResponse extends ApiResponse {
@@ -1,6 +1,6 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'getRoomResponse.dart';
part of 'get_room_response.dart';
// **************************************************************************
// JsonSerializableGenerator
@@ -1,16 +1,16 @@
import 'package:http/http.dart' as http;
import 'package:http/http.dart';
import '../../../apiParams.dart';
import '../talkApi.dart';
import 'sendMessageParams.dart';
import '../../../api_params.dart';
import '../talk_api.dart';
import 'send_message_params.dart';
class SendMessage extends TalkApi {
String chatToken;
SendMessage(this.chatToken, SendMessageParams params) : super('v1/chat/$chatToken', params);
@override
assemble(String raw) => null;
Null assemble(String raw) => null;
@override
Future<Response>? request(Uri uri, ApiParams? body, Map<String, String>? headers) {
@@ -1,8 +1,8 @@
import 'package:json_annotation/json_annotation.dart';
import '../../../apiParams.dart';
import '../../../api_params.dart';
part 'sendMessageParams.g.dart';
part 'send_message_params.g.dart';
@JsonSerializable(explicitToJson: true, includeIfNull: false)
class SendMessageParams extends ApiParams {
@@ -1,6 +1,6 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'sendMessageParams.dart';
part of 'send_message_params.dart';
// **************************************************************************
// JsonSerializableGenerator
@@ -2,8 +2,8 @@
import 'package:http/http.dart' as http;
import 'package:http/http.dart';
import '../talkApi.dart';
import 'setReadMarkerParams.dart';
import '../talk_api.dart';
import 'set_read_marker_params.dart';
class SetReadMarker extends TalkApi {
String chatToken;
@@ -15,7 +15,7 @@ class SetReadMarker extends TalkApi {
}
@override
assemble(String raw) => null;
Null assemble(String raw) => null;
@override
Future<Response> request(Uri uri, Object? body, Map<String, String>? headers) {
@@ -1,8 +1,8 @@
import 'package:json_annotation/json_annotation.dart';
import '../../../apiParams.dart';
import '../../../api_params.dart';
part 'setReadMarkerParams.g.dart';
part 'set_read_marker_params.g.dart';
@JsonSerializable()
class SetReadMarkerParams extends ApiParams {
@@ -1,6 +1,6 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'setReadMarkerParams.dart';
part of 'set_read_marker_params.dart';
// **************************************************************************
// JsonSerializableGenerator
@@ -4,9 +4,9 @@ import 'dart:io';
import 'package:http/http.dart' as http;
import '../../apiParams.dart';
import '../../apiRequest.dart';
import '../../apiResponse.dart';
import '../../api_params.dart';
import '../../api_request.dart';
import '../../api_response.dart';
import '../../errors/auth_exception.dart';
import '../../errors/network_exception.dart';
import '../../errors/not_found_exception.dart';
@@ -1,22 +0,0 @@
import '../../../../apiResponse.dart';
import '../../webdavApi.dart';
import 'downloadFileParams.dart';
class DownloadFile extends WebdavApi<DownloadFileParams> {
DownloadFileParams params;
DownloadFile(this.params) : super(params);
@override
Future<ApiResponse> run() async {
// final file = await File(localPath).create();
// Uint8List downloadedFile = await (await WebdavApi.webdav).download(params.webdavPath);
// file.writeAsBytesSync(downloadedFile, flush: true, mode: FileMode.write);
//
// OpenFile.open(localPath);
throw UnimplementedError();
}
}
@@ -0,0 +1,16 @@
import '../../../../api_response.dart';
import '../../webdav_api.dart';
import 'download_file_params.dart';
class DownloadFile extends WebdavApi<DownloadFileParams> {
DownloadFileParams params;
DownloadFile(this.params) : super(params);
@override
Future<ApiResponse> run() async {
throw UnimplementedError();
}
}
@@ -1,8 +1,8 @@
import 'package:json_annotation/json_annotation.dart';
import '../../../../apiParams.dart';
import '../../../../api_params.dart';
part 'downloadFileParams.g.dart';
part 'download_file_params.g.dart';
@JsonSerializable()
class DownloadFileParams extends ApiParams {
@@ -1,6 +1,6 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'downloadFileParams.dart';
part of 'download_file_params.dart';
// **************************************************************************
// JsonSerializableGenerator
@@ -1,7 +1,7 @@
import 'package:json_annotation/json_annotation.dart';
part 'downloadFileResponse.g.dart';
part 'download_file_response.g.dart';
@JsonSerializable()
class DownloadFileResponse {
@@ -1,6 +1,6 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'downloadFileResponse.dart';
part of 'download_file_response.dart';
// **************************************************************************
// JsonSerializableGenerator
@@ -1,25 +0,0 @@
import 'dart:convert';
import 'package:crypto/crypto.dart';
import '../../../../requestCache.dart';
import 'listFiles.dart';
import 'listFilesParams.dart';
import 'listFilesResponse.dart';
class ListFilesCache extends SimpleCache<ListFilesResponse> {
ListFilesCache({
required void Function(ListFilesResponse) onUpdate,
super.onCacheData,
super.onNetworkData,
super.onError,
required String path,
}) : super(
cacheTime: RequestCache.cacheNothing,
loader: () => ListFiles(ListFilesParams(path)).run(),
fromJson: ListFilesResponse.fromJson,
onUpdate: onUpdate,
) {
final cacheName = md5.convert(utf8.encode('MarianumMobile-$path')).toString();
start('wd-folder-$cacheName');
}
}
@@ -1,7 +1,7 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:nextcloud/nextcloud.dart';
part 'cacheableFile.g.dart';
part 'cacheable_file.g.dart';
@JsonSerializable(explicitToJson: true)
class CacheableFile {
@@ -15,10 +15,6 @@ class CacheableFile {
DateTime? modifiedAt;
String? sort;
@JsonKey(includeFromJson: false, includeToJson: false)
bool currentlyDownloading = false;
CacheableFile({required this.path, required this.isDirectory, required this.name, this.mimeType, this.size, this.eTag, this.createdAt, this.modifiedAt});
CacheableFile.fromDavFile(WebDavFile file) {
@@ -1,6 +1,6 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'cacheableFile.dart';
part of 'cacheable_file.dart';
// **************************************************************************
// JsonSerializableGenerator
@@ -1,10 +1,10 @@
import 'package:nextcloud/nextcloud.dart';
import '../../webdavApi.dart';
import 'cacheableFile.dart';
import 'listFilesParams.dart';
import 'listFilesResponse.dart';
import '../../webdav_api.dart';
import 'cacheable_file.dart';
import 'list_files_params.dart';
import 'list_files_response.dart';
class ListFiles extends WebdavApi<ListFilesParams> {
ListFilesParams params;
@@ -27,16 +27,8 @@ class ListFiles extends WebdavApi<ListFilesParams> {
final webdav = await WebdavApi.webdav;
final timeout = _isRoot ? _rootTimeout : _subfolderTimeout;
final davFiles = (await webdav.propfind(PathUri.parse(params.path)).timeout(timeout)).toWebDavFiles();
var files = davFiles.map(CacheableFile.fromDavFile).toSet();
final files = davFiles.map(CacheableFile.fromDavFile).toSet();
// webdav handles subdirectories wrong, this is a fix
// currently this fix is not needed anymore
// if(EndpointData().getEndpointMode() == EndpointMode.stage) {
// files = files.map((e) { // somehow
// e.path = e.path.split("mobile/cloud/remote.php/webdav")[1];
// return e;
// }).toSet();
// }
// somehow the current working folder is also listed, it is filtered here.
files.removeWhere((element) => element.path == '/${params.path}/' || element.path == '/');
@@ -0,0 +1,41 @@
import 'dart:convert';
import 'package:crypto/crypto.dart';
import 'package:localstore/localstore.dart';
import '../../../../../utils/cache_invalidation_bus.dart';
import '../../../../request_cache.dart';
import 'list_files.dart';
import 'list_files_params.dart';
import 'list_files_response.dart';
class ListFilesCache extends SimpleCache<ListFilesResponse> {
ListFilesCache({
required void Function(ListFilesResponse) onUpdate,
super.onCacheData,
super.onNetworkData,
super.onError,
required String path,
}) : super(
cacheTime: RequestCache.cacheNothing,
loader: () => ListFiles(ListFilesParams(path)).run(),
fromJson: ListFilesResponse.fromJson,
onUpdate: onUpdate,
) {
start(_documentId(path));
}
static String _documentId(String path) {
final cacheName = md5.convert(utf8.encode('MarianumMobile-$path')).toString();
return 'wd-folder-$cacheName';
}
/// Drops the cached listing for [path] from local storage so the next
/// `listFiles` call cannot serve stale data, and notifies any live
/// `_FilesView` for that path via [CacheInvalidationBus] so it refetches
/// even while it is sitting in the background of the navigation stack.
static Future<void> invalidate(String path) async {
await Localstore.instance.collection(RequestCache.collection).doc(_documentId(path)).delete();
CacheInvalidationBus.notifyListFiles(path);
}
}
@@ -1,8 +1,8 @@
import 'package:json_annotation/json_annotation.dart';
import '../../../../apiParams.dart';
import '../../../../api_params.dart';
part 'listFilesParams.g.dart';
part 'list_files_params.g.dart';
@JsonSerializable(explicitToJson: true)
class ListFilesParams extends ApiParams {
@@ -1,6 +1,6 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'listFilesParams.dart';
part of 'list_files_params.dart';
// **************************************************************************
// JsonSerializableGenerator
@@ -2,10 +2,10 @@ import 'package:jiffy/jiffy.dart';
import 'package:json_annotation/json_annotation.dart';
import '../../../../../view/pages/files/files.dart';
import '../../../../apiResponse.dart';
import 'cacheableFile.dart';
import '../../../../api_response.dart';
import 'cacheable_file.dart';
part 'listFilesResponse.g.dart';
part 'list_files_response.g.dart';
@JsonSerializable(explicitToJson: true)
class ListFilesResponse extends ApiResponse {
@@ -1,6 +1,6 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'listFilesResponse.dart';
part of 'list_files_response.dart';
// **************************************************************************
// JsonSerializableGenerator
@@ -2,8 +2,8 @@ import 'package:nextcloud/nextcloud.dart';
import '../../../model/account_data.dart';
import '../../../model/endpoint_data.dart';
import '../../apiRequest.dart';
import '../../apiResponse.dart';
import '../../api_request.dart';
import '../../api_response.dart';
abstract class WebdavApi<T> extends ApiRequest {
T genericParams;
@@ -2,14 +2,14 @@ import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:http/http.dart';
import '../../mhslApi.dart';
import 'getBreakersResponse.dart';
import '../../mhsl_api.dart';
import 'get_breakers_response.dart';
class GetBreakers extends MhslApi<GetBreakersResponse> {
GetBreakers() : super('breaker/');
@override
GetBreakersResponse assemble(String raw) => GetBreakersResponse.fromJson(jsonDecode(raw));
GetBreakersResponse assemble(String raw) => GetBreakersResponse.fromJson(jsonDecode(raw) as Map<String, dynamic>);
@override
Future<Response>? request(Uri uri) => http.get(uri);
@@ -1,6 +1,6 @@
import '../../../requestCache.dart';
import 'getBreakers.dart';
import 'getBreakersResponse.dart';
import '../../../request_cache.dart';
import 'get_breakers.dart';
import 'get_breakers_response.dart';
class GetBreakersCache extends SimpleCache<GetBreakersResponse> {
GetBreakersCache({super.onUpdate, super.renew})
@@ -1,9 +1,9 @@
import 'package:json_annotation/json_annotation.dart';
import '../../../apiResponse.dart';
import '../../../api_response.dart';
part 'getBreakersResponse.g.dart';
part 'get_breakers_response.g.dart';
@JsonSerializable(explicitToJson: true)
class GetBreakersResponse extends ApiResponse {
@@ -1,6 +1,6 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'getBreakersResponse.dart';
part of 'get_breakers_response.dart';
// **************************************************************************
// JsonSerializableGenerator
@@ -3,8 +3,8 @@ import 'dart:convert';
import 'package:http/http.dart';
import 'package:http/http.dart' as http;
import '../../mhslApi.dart';
import 'addCustomTimetableEventParams.dart';
import '../../mhsl_api.dart';
import 'add_custom_timetable_event_params.dart';
class AddCustomTimetableEvent extends MhslApi<void> {
AddCustomTimetableEventParams params;
@@ -1,8 +1,8 @@
import 'package:json_annotation/json_annotation.dart';
import '../customTimetableEvent.dart';
import '../custom_timetable_event.dart';
part 'addCustomTimetableEventParams.g.dart';
part 'add_custom_timetable_event_params.g.dart';
@JsonSerializable(explicitToJson: true)
class AddCustomTimetableEventParams {
@@ -1,6 +1,6 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'addCustomTimetableEventParams.dart';
part of 'add_custom_timetable_event_params.dart';
// **************************************************************************
// JsonSerializableGenerator
@@ -1,8 +1,8 @@
import 'package:json_annotation/json_annotation.dart';
import '../mhslApi.dart';
import '../mhsl_api.dart';
part 'customTimetableEvent.g.dart';
part 'custom_timetable_event.g.dart';
@JsonSerializable()
class CustomTimetableEvent {
@@ -1,6 +1,6 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'customTimetableEvent.dart';
part of 'custom_timetable_event.dart';
// **************************************************************************
// JsonSerializableGenerator
@@ -3,9 +3,9 @@ import 'dart:convert';
import 'package:http/http.dart';
import 'package:http/http.dart' as http;
import '../../mhslApi.dart';
import 'getCustomTimetableEventParams.dart';
import 'getCustomTimetableEventResponse.dart';
import '../../mhsl_api.dart';
import 'get_custom_timetable_event_params.dart';
import 'get_custom_timetable_event_response.dart';
class GetCustomTimetableEvent extends MhslApi<GetCustomTimetableEventResponse> {
GetCustomTimetableEventParams params;
@@ -1,7 +1,7 @@
import '../../../requestCache.dart';
import 'getCustomTimetableEvent.dart';
import 'getCustomTimetableEventParams.dart';
import 'getCustomTimetableEventResponse.dart';
import '../../../request_cache.dart';
import 'get_custom_timetable_event.dart';
import 'get_custom_timetable_event_params.dart';
import 'get_custom_timetable_event_response.dart';
class GetCustomTimetableEventCache extends SimpleCache<GetCustomTimetableEventResponse> {
GetCustomTimetableEventCache(
@@ -1,6 +1,6 @@
import 'package:json_annotation/json_annotation.dart';
part 'getCustomTimetableEventParams.g.dart';
part 'get_custom_timetable_event_params.g.dart';
@JsonSerializable()
class GetCustomTimetableEventParams {
@@ -1,6 +1,6 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'getCustomTimetableEventParams.dart';
part of 'get_custom_timetable_event_params.dart';
// **************************************************************************
// JsonSerializableGenerator
@@ -1,9 +1,9 @@
import 'package:json_annotation/json_annotation.dart';
import '../../../apiResponse.dart';
import '../customTimetableEvent.dart';
import '../../../api_response.dart';
import '../custom_timetable_event.dart';
part 'getCustomTimetableEventResponse.g.dart';
part 'get_custom_timetable_event_response.g.dart';
@JsonSerializable()
class GetCustomTimetableEventResponse extends ApiResponse {
@@ -1,6 +1,6 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'getCustomTimetableEventResponse.dart';
part of 'get_custom_timetable_event_response.dart';
// **************************************************************************
// JsonSerializableGenerator
@@ -3,8 +3,8 @@ import 'dart:convert';
import 'package:http/http.dart';
import 'package:http/http.dart' as http;
import '../../mhslApi.dart';
import 'removeCustomTimetableEventParams.dart';
import '../../mhsl_api.dart';
import 'remove_custom_timetable_event_params.dart';
class RemoveCustomTimetableEvent extends MhslApi<void> {
RemoveCustomTimetableEventParams params;
@@ -1,6 +1,6 @@
import 'package:json_annotation/json_annotation.dart';
part 'removeCustomTimetableEventParams.g.dart';
part 'remove_custom_timetable_event_params.g.dart';
@JsonSerializable()
class RemoveCustomTimetableEventParams {
@@ -1,6 +1,6 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'removeCustomTimetableEventParams.dart';
part of 'remove_custom_timetable_event_params.dart';
// **************************************************************************
// JsonSerializableGenerator
@@ -3,8 +3,8 @@ import 'dart:convert';
import 'package:http/http.dart';
import 'package:http/http.dart' as http;
import '../../mhslApi.dart';
import 'updateCustomTimetableEventParams.dart';
import '../../mhsl_api.dart';
import 'update_custom_timetable_event_params.dart';
class UpdateCustomTimetableEvent extends MhslApi<void> {
UpdateCustomTimetableEventParams params;
@@ -1,9 +1,9 @@
import 'package:json_annotation/json_annotation.dart';
import '../customTimetableEvent.dart';
import '../custom_timetable_event.dart';
part 'updateCustomTimetableEventParams.g.dart';
part 'update_custom_timetable_event_params.g.dart';
@JsonSerializable(explicitToJson: true)
class UpdateCustomTimetableEventParams {
@@ -1,6 +1,6 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'updateCustomTimetableEventParams.dart';
part of 'update_custom_timetable_event_params.dart';
// **************************************************************************
// JsonSerializableGenerator
@@ -5,7 +5,7 @@ import 'dart:io';
import 'package:http/http.dart' as http;
import 'package:jiffy/jiffy.dart';
import '../apiRequest.dart';
import '../api_request.dart';
import '../errors/network_exception.dart';
import '../errors/parse_exception.dart';
import '../errors/server_exception.dart';
@@ -4,8 +4,8 @@ import 'dart:developer';
import 'package:http/http.dart' as http;
import '../../mhslApi.dart';
import 'notifyRegisterParams.dart';
import '../../mhsl_api.dart';
import 'notify_register_params.dart';
class NotifyRegister extends MhslApi<void> {
NotifyRegisterParams params;
@@ -1,6 +1,6 @@
import 'package:json_annotation/json_annotation.dart';
part 'notifyRegisterParams.g.dart';
part 'notify_register_params.g.dart';
@JsonSerializable()
class NotifyRegisterParams {

Some files were not shown because too many files have changed in this diff Show More