Flutter Image picker for web and mobile - flutter

I need to develop a cross platform app using flutter that supports mobile as well as web platforms. I need an image picker that works for mobile as well as web. Currently I am using image picker flutter plugin for mobile and flutter_web_image_picker for web. But the build fails as flutter_web_image_picker uses dart:HTML and it is not supported for mobile builds. I need to know that how shall I conditionally render web pickers for their respective platforms as having two separate code bases won't make any sense?

Might be very late, but this is how we can execute any code conditionally for different platforms in flutter.
import 'package:flutter/foundation.dart' show kIsWeb;
Then in the function code -
if(kIsWeb){
... web specific code
} else {
... mobile specific code
}

Related

Is it possible to create a custom share sheet in Flutter?

I want to build this custom share sheet shown in the screenshot depending on the apps that are on the mobile, could anyone tell me if it's possible? screenshot
i am currently using flutter's share_plus package, but the share method summons the platform's share sheet, is it possible to customize my own share sheet and use it for both platforms android and ios?
Using the Flutter Availability package you can customize this by styling BottomSheet from scratch. Still, this package is only for Android devices. Unfortunately, iOS does not provide any API to get the installed APPs information.
I guess You'll have to work with a modalBottomSheet and https://pub.dev/packages/url_launcher
You can check if an application is installed, but this would work only for android Is there any way to identify that a particular application is installed in my android/ios device through flutter and dart?

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 RevenueCat SDK not working on web

For my flutter IOS/Android app i use https://pub.dev/packages/purchases_flutter ( RevenueCat ) to manage subscription and it's working perfectly well.
Now i want to export my flutter into a webapp using : Flutter build web
I got that error :
''No implementation found for method setupPurchases on channel purchases_flutter''
That's because purchases_flutter is not made for webapp for now.
My question:
I really need to export my application into a webapp, is there a way i can avoid that kind of error? Can i trick my code to skip every part that refer to that package?
I found that you can put a condition before initializing revenuecat plugin so if you are on the web it skip that part and the application can build correctly
To check if you are on web
import 'package:flutter/foundation.dart' show kIsWeb;
if (kIsWeb) {
// running on the web!
} else {
// NOT running on the web! You can check for additional platforms here.
}

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.).

How to dynamically download and execute Dart code in a flutter app?

I have a flutter mobile app and i would like to be able to download dart code into the app and execute it. The downloaded code is fully trusted i.e. it comes from API calls to the mobile apps backend. There are two cases.
Non UI downloaded code: This is downloaded dart code that can interact with the network and and do some data structure transformations. It might also want to interact with the SQLLite database used by the app.
UI code: code that can interact with specific widgets on the screen or draw new widgets?
Can the above two dynamic code execution be done in a production flutter app that has been complied to native code?