15

Cross-posted from /r/dartlang on Reddit:

I saw the Flutter/Dart Google IO presentation and decided I wanted to make a stupid silly Android app. It was pretty easy to get started, but I couldn't find anywhere on how to do a simple lock-screen widget.

Basically I just want an app that periodically polls a JSON API and displays some data on the android lock screen. Is this possible to do with Flutter at the moment?

Disclaimer: I'm an infrastructure/backend python/golang developer who has never written anything close to a mobile app.

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
matanlurey
  • 8,096
  • 3
  • 38
  • 46
  • 1
    The Android lock screen has not supported app widgets since Android 5.0. – CommonsWare May 22 '17 at 18:53
  • The user might have been asking about desktop widgets then. – matanlurey May 22 '17 at 18:54
  • What's the difference between an app widget or a desktop widget? All I want is to show some live data from the notification pull-down and the lock-screen. There are plenty of apps that seem to do this (BeyondPod comes to mind). – Victor Trac May 22 '17 at 19:09
  • Flutter has a concept of "widgets" that are the fundamental UI element in Flutter apps. Similar to React "components". I think this conversation is confusing android widgets and Flutter widgets. – JTE May 22 '20 at 10:29

2 Answers2

14

App Widget layouts are based on RemoteViews, which do not support many types of view widgets. Because FlutterView extends SurfaceView to get access to low-level graphics APIs, it can't be embedded in an app widget.

To quote CommonsWare: "At best, you can try to write your own home screen implementation that does this." But that is a much bigger project than you probably had in mind.

Collin Jackson
  • 110,240
  • 31
  • 221
  • 152
8

If you are looking for homescreen widgets for flutter use home_widget: ^0.1.5 .

HomeWidget is a Plugin to make it easier to create HomeScreen Widgets on Android and iOS. HomeWidget does not allow writing Widgets with Flutter itself. It still requires writing the Widgets with native code. However, it provides a unified Interface for sending data, retrieving data and updating the Widgets

Widget implemented on android Widget implemented on IOS

Dharman
  • 30,962
  • 25
  • 85
  • 135
Jeslin Jacob
  • 570
  • 6
  • 8