Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to run a function depending on sensors_value and without using onPressed/onTap #7

Open
Tanelo opened this issue Mar 16, 2021 · 1 comment

Comments

@Tanelo
Copy link

Tanelo commented Mar 16, 2021

Is it possible to run a function (like navigate between two pages/uploading a file) which is normally activated through onPressed, but depending on sensors_value like a boolean (proximity sensor value). Thanks

@NarekManukyan
Copy link

@Tanelo you can add a listener for the proximity sensor and do your navigation in it. You can use all_sensors2

_streamSubscriptions.add(
      proximityEvents.listen(
        (ProximityEvent event) {
          if (event.getValue()) {
            Navigator.push(
              context,
              MaterialPageRoute(builder: (context) => SecondRoute()),
            );
          }
        },
      ),
    );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants