An open API service indexing awesome lists of open source software.

https://github.com/nicosnicolaou16/android_widget_with_compose_with_flutter

This project sets up the Widget in Flutter using Jetpack Compose Glance for Android.
https://github.com/nicosnicolaou16/android_widget_with_compose_with_flutter

android-compose android-widget compose dart flutter flutter-app kotlin kotlin-android widget

Last synced: 11 months ago
JSON representation

This project sets up the Widget in Flutter using Jetpack Compose Glance for Android.

Awesome Lists containing this project

README

          

# Android_widget_with_compose_with_flutter

This project sets up the Widget in Flutter using Jetpack Compose Glance for Android.

> [!IMPORTANT]
> NOTE: EXAMPLE FOR ANDROID ONLY.

# Setup

## Step 1 add the follow dependencies libraries

```Kotlin
val composeGlanceWidgetVersion by extra("1.1.1")

dependencies {

//...
//Glance Widget
implementation("androidx.glance:glance-appwidget:$composeGlanceWidgetVersion")
//Using Material 2
implementation("androidx.glance:glance-material:$composeGlanceWidgetVersion")
//Using Material 3
implementation("androidx.glance:glance-material3:$composeGlanceWidgetVersion")
}
```

## Steps 2 Create the Glance Receiver class that extend GlanceAppWidgetReceiver() and return the Widget Class

```Kotlin
class MyAppWidgetReceiver : GlanceAppWidgetReceiver() {
override val glanceAppWidget: GlanceAppWidget
get() = MyAppWidget()
}
```

## Step 3 Create the xml file into the xml directory (configuration to declare the size etc.)

```XML

```

## Step 4 Register the Receiver Class into the Manifest and set the xml configuration for the Glance Widget

```XML




```

## Step 5 Create the Widget that extend GlanceAppWidget() class

```Kotlin
//...
class MyAppWidget : GlanceAppWidget() {

override suspend fun provideGlance(context: Context, id: GlanceId) {
provideContent {
MyContent(context) //Compose UI
}
}
//....
}
```

> [!IMPORTANT]
> Check my article for the setup :point_right: [Android Widget Setup with Jetpack Compose Glance (with a Flutter example) - Medium](https://medium.com/@nicosnicolaou/android-widget-setup-with-jetpack-compose-glance-with-a-flutter-example-e07fb63c9466) :point_left:

> [!IMPORTANT]
> Similar project with (Kotlin Language) :point_right: [AndroidWidgetWithCompose](https://github.com/NicosNicolaou16/AndroidWidgetWithCompose) :point_left:

# Versioning

Flutter SDK version: 3.27.1

Dart Version: 3.6.0

# References

https://developer.android.com/jetpack/compose/glance/create-app-widget