Do iOS and Android Flutter widgets also work on Flutter Web(PWA) - flutter

I'm interested in using Flutter primarily for my startup MVP on Web and possibly Android. I see the flutter community has made a lot of widgets but a lot of them are tagged iOS or Android. Since Futter is all about using one codebase is it wrong to assume that these widgets would work on web too? I imagine the setup would be different but similar with a Flutter web app as opposed to a Flutter Android app.
I couldn't find a whole lot about this on the Flutter site. I also know that web is still beta but by the time I'm done with the MVP it'll probably be at stable release or close enough.

Well... It depends. If the widget has some sort of native code the answer is no. In Flutter there are two type of packages: the "normal" package, and the plugin.
The packages are made only of dart code, so there are no bounds to native, and you can use everywhere dart (and Flutter) can run.
The plugins are packages with native code and you can use only on the platform supported by that plugin.
For example the package provider, it's a package, and you can use in every supported platform where dart (and Flutter) can run. But url_launcher, it's a plugin, so you can run only on Android, iOS, and web, but for example on desktop, it will no work.
If the package if you found it's only a widget, you should be able to use on the web.
TLDR: No,a PWA it's a web app, so it can't run Android or iOS specific code.

Related

Does Flutter 3 support Webview on Desktop?

Flutter 3 was released recently with Desktop platform support for Windows, Linux and macOS.
Can Flutter developers clarify if Flutter 3 also supports Webview on Windows, Linux and macOS? Flutter documentation seems to suggest Webview support exists only for Android and ios.
Would appreciate some insights as I have a project that requires Webview, and if Flutter 3 supports it on all platforms it would make my work a lot easier. (I am asking here before trying out Flutter myself as I am completely unfamiliar with Flutter, and need to know about Webview status before I invest my time to learn Flutter).
(Note: Please do not go on a tangent and focus on "why webview" or whether it is apt etc. as I have no choice in the matter - it's one of the stated requirement of the project and I cannot change it).
No Flutter 3 Does not support Webview on Desktop, however you can use a package -
https://pub.dev/packages/desktop_webview_window

Flutter Ambient UI - What should be the optimised approach for production level responsive app in web, android and ios platform using single codebase?

I was trying out flutter platform to create a multipage website with android and ios responsiveness using single codebase for my flutter app. I've already tried some single page samples in flutter which are following,
Flutter web, android & ios using Stacked architecture & Responsive_builder
Flutter web, android & ios using MVVM & Responsive_Framework
Flutter web, android & ios using simple Getx package.
All of them are working fine, but what I want is to collect your opinions who have already created a production ready app in flutter web.
Should we consider using Navigator 2.0 for flutter web responsiveness?
Does responsive_framework package work fine if we have complex designs because I'm not confident about the font size and styling application using it?
Can we use any other app architecture, responsive package, design pattern or any other concepts for multipage production level use cases.
Any suggestions would be appreciated.
Thanks.

Flutter IOS & ANDROID Widgets Implementation

I wanted to ask about the implementation of IOS & Android Widgets for Flutter.
Current Scenario :
Basically, i have developed the app on android platform and now i want to convert it to IOS platform. Since this is my first app, i really need some experienced voice on some issues i am facing.
Questions :
1 - Is there any simple way to detect that the widgets currently used are of Android/IOS Platform ?
How can we know for sure that a specific widget is of Android platform and is not going to work on IOS platform and vice versa.
2 - If somehow we know for sure that the current widget we are using is of Android platform, then how can we find its equivalent widget to implement for IOS platform.
3 - Are these widgets specifically required when we are going to upload/publish to these platforms respective stores. For example in a scenario where i hadn't converted all of my android app widgets to ios widgets and when i try to publish the app for IOS store, does the IOS Store rejects that or not?
Any suggestions or help is greatly appreciated.
All standard widgets will work on iOS as is. Flutter paints the UI, rather than call the native APIs. You might use a plugin that does not support iOS, but I have not yet come across such a plugin on pub.dev.
If you want to write platform specific code, you can import dart:io and use the boolean Platform.isIOS or Platform.isAndroid.
Both the App Store and Play Store have specific requirements before your app is approved.
In case you really want to have Android specific widgets on Android devices and iOS specific widgets on iOS devices, then use the Flutter Platform Widgets package. This will exactly do that - drawing iOS buttons using the Cupertino library and Android buttons using the Android library (and most other widgets as well).
As #Mudassir mentioned in the other comment this is not a requirement. In case you go with the default widgets, you will have the same look on all devices (even web, Windows, etc.).

FLUTTER WEB: How can we have a single codebase for the Flutter app & Web?

We have a single codebase for Android & iOS in Flutter.
We tried to use the same codebase for Web in Flutter too, but it hadn't gone well.
As of some libraries/plugins, currently unsupported by Flutter SDK.
To mitigate these issues, we are maintaining two separate repositories, one for Android-iOS and other for Web.
Also, to add up here, for separate repositories because each Flutter product has a unique pubspec.yaml file. Now there are a few plugins that are currently supported in App but Not yet on Flutter Web, namely Awesome Notifications, Clevertap plugin, etc.
Integrating those plugins on the web, stops the web to run. So keeping the same codebase for both is getting technically complicated as the app has many many functions.
It takes so much time in simultaneously testing, debugging and resolving issues in Web.
So, how we can maintain same code for all platforms i.e., Android, iOS & Web, without doing it in other repository for Web and gaining advantage in streamlining our codebase into one for all platforms?
For Ex. If I commented the package awesome_notifications for Web in pubspec file, the issue arises (as shown in the screenshot) in code wherever we used its functionalities.
For successfully working on both Mobile & Web, are there any methods available we can use packages for both (Mobile & Web)?
Ideally you’d want to use a single codebase to host both the web and mobile versions, to minimise code maintenance and improve efficiency. To do this, you’ll need to be able to find the platform the code is running on, so that code can be called programmatically.
You can use the constant kIsWeb to check if the application is compiled for the web, and you can then use that condition to only run platform-specific code (such as the awesome_notifications package) if you’re on a platform that supports it. That way you’ll still be able to import the required packages, but only call them when the app is running on the mobile version of your app.
That should allow you to condense your codebase into one repository without sacrificing any functionality that may not work across all platforms.

Setting Flutter project: iOS and Android languages

When I create a new Flutter project, it asks me to choose between Java/Kotlin for Android and Objective-c/Swift for iOS. But, what does this mean? Is it in case I want to write something for Android or iOS specifically?
Yes that is correct. In Flutter you have the option to call into platform-specific APIs. This is especially useful if you need to access functionality that is not available in Flutter directly (e.g. accessing the keychain on iOS or the keystore on Android).
To do so you can open up a message channel which bridges the Dart world with the platform-specific world. You can use this message channel to send a message from Dart to you platform-specific code. This platform-specific code is either Java/Kotlin for Android or Objective-C/Swift for iOS, depending on your selections during the creation of the project.
More detailed information can be found in the Flutter documentation here: https://flutter.dev/docs/development/platform-integration/platform-channels
Just a heads up, the Flutter team and the Flutter community already wrote a lot of OSS packages and plugins that will take care of the platform-specific stuff and offer you an easy Dart API. You can search for these packages in the Pub: https://pub.dev