43

I took a look at flutter for building a mobile app. Is it possible to create Widgets (not flutter-widgets, but App Widgets (Android) and Today Extensions (iOS)) in a flutter app? I guess it can't be done with dart, but is there a way of implementing them native in Java/Swift and include them in the flutter-app?

Thanks!

hendra
  • 2,531
  • 5
  • 22
  • 34
  • I don't know if app widgets could be built in flutter or not, but the opposite is definitely possible. – Hemanth Raj Dec 18 '17 at 17:08
  • What do you mean by 'the opposite'? Including flutter in a native iOS/Android project? – hendra Dec 18 '17 at 18:07
  • I meant write app widgets natively and use them with flutter – Hemanth Raj Dec 18 '17 at 18:08
  • @HemanthRaj are you sure? Widget are created with Skia. How can you use native widget? I think you can create your set of graphic widget via Skia... – Alessandro Caliaro Dec 18 '17 at 19:24
  • I meant, create your home screen widgets natively and You can have application UI with flutter widgets – Hemanth Raj Dec 19 '17 at 02:05
  • @hendra Yes, you can include flutter view to IOS/Android project. – Hemanth Raj Dec 19 '17 at 05:33
  • @HemanthRaj Thanks! Just to make things clear: I'm talking about Home Screen Widgets, not Flutter Widgets :D Can you give me an entry point (link to documentation, blog post, example project) where a native homescreen-widget has been included into a flutter app? – hendra Dec 19 '17 at 11:42
  • @hendra I just answered your question. Do accept if it was what you were looking for. – Hemanth Raj Dec 19 '17 at 12:46
  • It should be possible to implement communication between Android widget and the Flutter component, but there seems to be a bug. Please compare https://stackoverflow.com/questions/53940400/invoke-flutter-dart-code-from-native-android-home-screen-widget – Timo Bähr Apr 26 '19 at 13:53

1 Answers1

50

There is no guide or docs showing how to implement a App Widget for a flutter app. It is definitely possible to implement a app widget with native code. Just create a flutter project and open the android part with android studio, just implement your home screen widget, it'll work like a charm.

I just wrote a simple app widget for a flutter app that takes you to https://flutter.io link when tapped. Here is the simple app created with flutter and a app widget added with native code. Install it and look for home_widget_example on Home Screen Widgets.

Gif image

If you wanted to look into the source code, and build app from source. Here it is.

Christopher Moore
  • 15,626
  • 10
  • 42
  • 52
Hemanth Raj
  • 32,555
  • 10
  • 92
  • 82