Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android lock-screen Widget in Flutter?

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.

like image 774
matanlurey Avatar asked May 22 '17 18:05

matanlurey


2 Answers

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.

like image 123
Collin Jackson Avatar answered Oct 15 '22 06:10

Collin Jackson


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

like image 32
Jeslin Jacob Avatar answered Oct 15 '22 04:10

Jeslin Jacob