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!

9
  • I don't know if app widgets could be built in flutter or not, but the opposite is definitely possible. Commented Dec 18, 2017 at 17:08
  • What do you mean by 'the opposite'? Including flutter in a native iOS/Android project? Commented Dec 18, 2017 at 18:07
  • I meant write app widgets natively and use them with flutter Commented Dec 18, 2017 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... Commented Dec 18, 2017 at 19:24
  • I meant, create your home screen widgets natively and You can have application UI with flutter widgets Commented Dec 19, 2017 at 2:05

1 Answer 1

49

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.

Sign up to request clarification or add additional context in comments.

5 Comments

Any idea to pass data to the widget button from flutter app. I need to call an API from the widget button.
Your implementation is Android-only. Flutter is a cross-platform framework
I just wanted to show the proof of concept of having native Android Widgets with flutter. Will try to add an example for IOS too. Or if you could please do, PRs are welcome :). Thanks @IhorKlimov.
You're using Android views to render the widget. Is it possible to render the widget using flutter?
AFAIK no, you cannot.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.