edsonbueno / focus_detector Goto Github PK
View Code? Open in Web Editor NEWAndroid's onResume/onPause and iOS's viewDidAppear/viewDidDisappear for Flutter.
Home Page: https://pub.dev/packages/focus_detector
License: MIT License
Android's onResume/onPause and iOS's viewDidAppear/viewDidDisappear for Flutter.
Home Page: https://pub.dev/packages/focus_detector
License: MIT License
visibility_detector-0.2.0/lib/src/visibility_detector_layer.dart:276:21: Error: Too many positional arguments: 1 allowed, but 2 found.
Try removing the extra positional arguments.
super.addToScene(builder, layerOffset);
Could init _isAppInForeground on initState?
because some native dialog pop on ui faster.
then flutter ui render.
@override
void initState() {
WidgetsBinding.instance.addObserver(this);
_isAppInForeground = (WidgetsBinding.instance.lifecycleState ?? AppLifecycleState.resumed) == AppLifecycleState.resumed;
super.initState();
}
if you double tap the home button on iphone, it minimizes current app and shows all apps tiled (app is not in foreground) but doesn't trigger a warning that the app in inactive/background.
is it possible to detect if the app is closed?
also, would be nice to add more detection triggers such as when there is no internet or if you're on cellular/wifi or even custom triggers
thanks
../../Software/FlutterSDK/flutter/.pub-cache/hosted/pub.dartlang.org/focus_detector-2.0.1/lib/focus_detector.dart:54:20: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.
Error occurs on widget test: "A Timer is still pending even after the widget tree was disposed"
Any ideas?
../../../Development/flutter/.pub-cache/hosted/pub.flutter-io.cn/focus_detector-2.0.1/lib/focus_detector.dart:54:20: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.
This package treats visibility and focus as synonymous but they are not.
On android, for example...you'd have to use onWindowFocusChanged to detect whether the app has regained focus after switching back to it.
The clipboard, for example, cannot be accessed until the app is in focus and accessing the clipboard on "onFocusGained" from this package returns null because there is a brief delay between onResume and when the app actually gains focus. The code below can be used to detect focus on android:
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if(hasFocus)
Toast.makeText(context, text, duration).show();
}
When I quickly switched widgets, there was no response; slowing down was normal
onFocusGained is fired with a short delay which is undesirable in my case causing the widget to refresh its contents about .5-1sec after the user returns to the screen.
It seems visibility_detector has implemented a default delay which can be overridden by setting the instance updateInterval. This option does not seem to be available in focus_detector.
I was able to workaround this issue by adding the visibility_detector package directly to my project (which is not ideal) and setting the updateInterval from there.
VisibilityDetectorController.instance.updateInterval = Duration.zero;
I checkout my project with my new MacBook Pro, chip Apple M1
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.3.4, on macOS 13.0.1 22A400 darwin-arm (Rosetta), locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.3)
[✓] VS Code (version 1.75.0)
[✓] Connected device (2 available)
[✓] HTTP Host Availability
dependencies:
focus_detector:
git:
url: https://github.com/ifnyas/focus_detector.git
ref: master
And got an error after run: flutter pub get
Error on line 1, column 7: "name" field doesn't match expected name "focus_detector".
╷
1 │ name: focus_detector_v2
│ ^^^^^^^^^^^^^^^^^
╵
pub get failed (65; ╵)
exit code 65
Currently i cannot upgrade visibility detector (because of focus_detector not allowing it) ..
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.