glance_widget_android 2.0.1 copy "glance_widget_android: ^2.0.1" to clipboard
glance_widget_android: ^2.0.1 copied to clipboard

PlatformAndroid

Android implementation of the glance_widget plugin using Jetpack Glance.

example/README.md

Example #

This package is the Android implementation of glance_widget, and it is endorsed: depending on glance_widget pulls it in, and there is no separate API to call. So the runnable example is the one in the app-facing package — glance_widget/example, which exercises all seven templates against this implementation on a device.

// Nothing here mentions this package. That is the point of endorsement.
import 'package:glance_widget/glance_widget.dart';

await GlanceWidget.updateSimpleWidget(
  const SimpleWidgetData(
    widgetId: 'crypto_btc',
    title: 'Bitcoin',
    value: r'$67,432',
    subtitle: '+2.4%',
  ),
);

What is worth looking at here instead #

The part of this package a developer actually has to touch is the Android manifest, not Dart. Each template needs its receiver declared with android:exported="true" — a receiver registered with false installs without complaint and then never appears in the widget picker, which is the single most common way to get this wrong.

dart run glance_widget:doctor reads the manifest and names what is missing, and the manifest it checks against is the example app's.