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

Update ambient_widget.dart #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/src/ambient_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class AmbientMode extends StatefulWidget {
final Widget? child;

/// Called each time the the wear device triggers an ambient update request.
final VoidCallback? onUpdate;
final Function(WearMode)? onUpdate;

/// Get current [WearMode].
static WearMode wearModeOf(BuildContext context) {
Expand Down Expand Up @@ -72,6 +72,7 @@ class _AmbientModeState extends State<AmbientMode> with AmbientCallback {
void _updateMode(bool isAmbient) {
if (mounted) {
setState(() => _ambientMode = isAmbient ? WearMode.ambient : WearMode.active);
if(widget.onUpdate != null) widget.onUpdate!(_ambientMode);
}
}

Expand All @@ -84,7 +85,6 @@ class _AmbientModeState extends State<AmbientMode> with AmbientCallback {
@override
void onUpdateAmbient() {
_updateMode(true);
widget.onUpdate?.call();
}
}

Expand Down