chore: fix analyzer issues

This commit is contained in:
Kingkor Roy Tirtho 2024-04-15 19:47:15 +06:00
parent 883783b769
commit 930539ca48
5 changed files with 11 additions and 16 deletions

View File

@ -16,7 +16,6 @@ class TokenLoginForm extends HookConsumerWidget {
Widget build(BuildContext context, ref) {
final authenticationNotifier = ref.watch(authenticationProvider.notifier);
final directCodeController = useTextEditingController();
final mounted = useIsMounted();
final isLoading = useState(false);
@ -57,7 +56,7 @@ class TokenLoginForm extends HookConsumerWidget {
await AuthenticationCredentials.fromCookie(
cookieHeader),
);
if (mounted()) {
if (context.mounted) {
onDone?.call();
}
} finally {

View File

@ -20,8 +20,6 @@ class Waypoint extends HookWidget {
@override
Widget build(BuildContext context) {
final isMounted = useIsMounted();
useEffect(() {
if (isGrid) {
return null;
@ -32,19 +30,19 @@ class Waypoint extends HookWidget {
// scrollController fetches the next paginated data when the current
// position of the user on the screen has surpassed
if (controller.position.pixels >= nextPageTrigger && isMounted()) {
if (controller.position.pixels >= nextPageTrigger && context.mounted) {
await onTouchEdge?.call();
}
}
WidgetsBinding.instance.addPostFrameCallback((_) {
if (controller.hasClients && isMounted()) {
if (controller.hasClients && context.mounted) {
listener();
controller.addListener(listener);
}
});
return () => controller.removeListener(listener);
}, [controller, onTouchEdge, isMounted]);
}, [controller, onTouchEdge]);
if (isGrid) {
return VisibilityDetector(

View File

@ -7,7 +7,7 @@ import 'package:spotube/components/library/user_local_tracks.dart';
import 'package:spotube/hooks/utils/use_async_effect.dart';
void useGetStoragePermissions(WidgetRef ref) {
final isMounted = useIsMounted();
final context = useContext();
useAsyncEffect(
() async {
@ -25,11 +25,11 @@ void useGetStoragePermissions(WidgetRef ref) {
if (hasNoStoragePerm) {
await Permission.storage.request();
if (isMounted()) ref.invalidate(localTracksProvider);
if (context.mounted) ref.invalidate(localTracksProvider);
}
if (hasNoAudioPerm) {
await Permission.audio.request();
if (isMounted()) ref.invalidate(localTracksProvider);
if (context.mounted) ref.invalidate(localTracksProvider);
}
},
null,

View File

@ -14,7 +14,6 @@ PaletteColor usePaletteColor(String imageUrl, WidgetRef ref) {
final context = useContext();
final theme = Theme.of(context);
final paletteColor = ref.watch(_paletteColorState);
final mounted = useIsMounted();
useEffect(() {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
@ -25,7 +24,7 @@ PaletteColor usePaletteColor(String imageUrl, WidgetRef ref) {
width: 50,
),
);
if (!mounted()) return;
if (!context.mounted) return;
final color = theme.brightness == Brightness.light
? palette.lightMutedColor ?? palette.lightVibrantColor
: palette.darkMutedColor ?? palette.darkVibrantColor;
@ -41,7 +40,7 @@ PaletteColor usePaletteColor(String imageUrl, WidgetRef ref) {
PaletteGenerator usePaletteGenerator(String imageUrl) {
final palette = useState(PaletteGenerator.fromColors([]));
final mounted = useIsMounted();
final context = useContext();
useEffect(() {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
@ -52,7 +51,7 @@ PaletteGenerator usePaletteGenerator(String imageUrl) {
width: 50,
),
);
if (!mounted()) return;
if (!context.mounted) return;
palette.value = newPalette;
});

View File

@ -38,7 +38,6 @@ class RootApp extends HookConsumerWidget {
@override
Widget build(BuildContext context, ref) {
final isMounted = useIsMounted();
final showingDialogCompleter = useRef(Completer()..complete());
final downloader = ref.watch(downloadManagerProvider);
final scaffoldMessenger = ScaffoldMessenger.of(context);
@ -129,7 +128,7 @@ class RootApp extends HookConsumerWidget {
useEffect(() {
downloader.onFileExists = (track) async {
if (!isMounted()) return false;
if (!context.mounted) return false;
if (!showingDialogCompleter.value.isCompleted) {
await showingDialogCompleter.value.future;