Adding conditional dependencies based on platform version in flutter

160 Views Asked by At

I have a flutter app in which we need to add a package that only supports iOS 13 and above, how can we add that package only for users above version 13 in iOS and not for users below it?

Is there any better way other than having 2 seperate versions of the app, one with the package and one without?

I am currently having 2 versions of the ios app, one for 13+ users and one for others, need a better solution.

1

There are 1 best solutions below

0
On

You may try to wrap this dependency in a separate plugin, just for iOS and then provide appropriate implementations depending on the iOS version.

Thus, by passing your calls to your dependency through version-specific checks you may just have one dependency for your app

if #available(iOS 13, *) {
    print("This code only runs on iOS 15 and up")
} else {
    print("This code only runs on iOS 14 and lower")
}