Skip to content

Commit 8f560dd

Browse files
authored
Fix type error: use ref.invalidate() for FutureProvider refresh
Fix type error: use ref.invalidate() for FutureProvider refresh
2 parents bdf20d0 + bc27129 commit 8f560dd

7 files changed

Lines changed: 54 additions & 9 deletions

File tree

_codeql_detected_source_root

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.

lib/ui/book_info_page.dart

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Dart imports:
22
// import 'dart:convert';
3-
import 'dart:async' show unawaited;
43

54
// Flutter imports:
65
import 'package:flutter/material.dart';
@@ -257,7 +256,7 @@ class _ActionButtonWidgetState extends ConsumerState<ActionButtonWidget> {
257256
context: context,
258257
message: 'Download started in background',
259258
);
260-
unawaited(ref.refresh(myLibraryProvider));
259+
ref.invalidate(myLibraryProvider);
261260
}
262261
} else {
263262
showSnackBar(
@@ -309,11 +308,13 @@ class _ActionButtonWidgetState extends ConsumerState<ActionButtonWidget> {
309308

310309
await downloadManager.addDownload(task);
311310

312-
showSnackBar(
313-
context: context,
314-
message: 'Download started in background',
315-
);
316-
unawaited(ref.refresh(myLibraryProvider));
311+
if (context.mounted) {
312+
showSnackBar(
313+
context: context,
314+
message: 'Download started in background',
315+
);
316+
}
317+
ref.invalidate(myLibraryProvider);
317318
}
318319
} else {
319320
showSnackBar(
@@ -401,8 +402,7 @@ Future<void> downloadFileWidget(WidgetRef ref, BuildContext context,
401402
}
402403
// ignore: unused_result
403404
ref.refresh(checkIdExists(data.md5));
404-
// ignore: unused_result
405-
ref.refresh(myLibraryProvider);
405+
ref.invalidate(myLibraryProvider);
406406
// ignore: use_build_context_synchronously
407407
showSnackBar(context: context, message: 'Book has been downloaded!');
408408
}

linux/flutter/generated_plugin_registrant.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66

77
#include "generated_plugin_registrant.h"
88

9+
#include <open_file_linux/open_file_linux_plugin.h>
10+
#include <url_launcher_linux/url_launcher_plugin.h>
911

1012
void fl_register_plugins(FlPluginRegistry* registry) {
13+
g_autoptr(FlPluginRegistrar) open_file_linux_registrar =
14+
fl_plugin_registry_get_registrar_for_plugin(registry, "OpenFileLinuxPlugin");
15+
open_file_linux_plugin_register_with_registrar(open_file_linux_registrar);
16+
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
17+
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
18+
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
1119
}

linux/flutter/generated_plugins.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#
44

55
list(APPEND FLUTTER_PLUGIN_LIST
6+
open_file_linux
7+
url_launcher_linux
68
)
79

810
list(APPEND FLUTTER_FFI_PLUGIN_LIST

macos/Flutter/GeneratedPluginRegistrant.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,24 @@
55
import FlutterMacOS
66
import Foundation
77

8+
import device_info_plus
9+
import file_picker
10+
import flutter_inappwebview_macos
11+
import flutter_local_notifications
12+
import open_file_mac
13+
import path_provider_foundation
14+
import share_plus
15+
import sqflite_darwin
16+
import url_launcher_macos
817

918
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
19+
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
20+
FilePickerPlugin.register(with: registry.registrar(forPlugin: "FilePickerPlugin"))
21+
InAppWebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "InAppWebViewFlutterPlugin"))
22+
FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin"))
23+
OpenFilePlugin.register(with: registry.registrar(forPlugin: "OpenFilePlugin"))
24+
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
25+
SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin"))
26+
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
27+
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
1028
}

windows/flutter/generated_plugin_registrant.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@
66

77
#include "generated_plugin_registrant.h"
88

9+
#include <flutter_inappwebview_windows/flutter_inappwebview_windows_plugin_c_api.h>
10+
#include <permission_handler_windows/permission_handler_windows_plugin.h>
11+
#include <share_plus/share_plus_windows_plugin_c_api.h>
12+
#include <url_launcher_windows/url_launcher_windows.h>
913

1014
void RegisterPlugins(flutter::PluginRegistry* registry) {
15+
FlutterInappwebviewWindowsPluginCApiRegisterWithRegistrar(
16+
registry->GetRegistrarForPlugin("FlutterInappwebviewWindowsPluginCApi"));
17+
PermissionHandlerWindowsPluginRegisterWithRegistrar(
18+
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
19+
SharePlusWindowsPluginCApiRegisterWithRegistrar(
20+
registry->GetRegistrarForPlugin("SharePlusWindowsPluginCApi"));
21+
UrlLauncherWindowsRegisterWithRegistrar(
22+
registry->GetRegistrarForPlugin("UrlLauncherWindows"));
1123
}

windows/flutter/generated_plugins.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
#
44

55
list(APPEND FLUTTER_PLUGIN_LIST
6+
flutter_inappwebview_windows
7+
permission_handler_windows
8+
share_plus
9+
url_launcher_windows
610
)
711

812
list(APPEND FLUTTER_FFI_PLUGIN_LIST

0 commit comments

Comments
 (0)