mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-12 23:45:18 +00:00
19 lines
568 B
Dart
19 lines
568 B
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
bool? useIsCurrentRoute([String matcher = "/"]) {
|
|
final isCurrentRoute = useState<bool?>(null);
|
|
final context = useContext();
|
|
useEffect(() {
|
|
WidgetsBinding.instance.addPostFrameCallback((timer) {
|
|
final isCurrent = GoRouter.of(context).location == matcher;
|
|
if (isCurrent != isCurrentRoute.value) {
|
|
isCurrentRoute.value = isCurrent;
|
|
}
|
|
});
|
|
return null;
|
|
});
|
|
return isCurrentRoute.value;
|
|
}
|