When mistreatment cross-platform frameworks, folks may forget the nuances of every of the platforms they need their code to run on. This text aims to handle that.
Specifically, people sometimes confuse it with the older Web-based mobile (and desktop) cross-platform frameworks, which basically were just Web pages running within browsers running within a wrapper app.
That was truly cross-platform in the sense that the interfaces were the same anyway because you only had access to the interfaces normally accessible on the Web.
Flutter isnt that, though: it runs natively on each platform, and it means each app runs just like it would run if it were written in Java/Kotlin or Objective-C/Swift on Android and iOS, pretty much. You need to know that because this implies that you need to take care of the many differences between these very diverse platforms.
I recently wrote on my diary concerning the necessity for a special approach to storing JWTs in net apps compared to mobile apps. That is due to the various nature of the platforms storage choices, and therefore the got to recognize every and their native development tools.
When you write a Web app, the storage options you have are:
1 Downloading/uploading files to/from disk, which requires user interaction and is therefore only suitable for files meant to be read or created by the user.
2. Using cookies, which may or may not be accessible from JS (depending on whether or not theyre httpOnly) and are automatically sent along with requests to a given domain and saved when they come as part of a response.
3. Using JS localStorage and sessionStorage, accessible by any JS on the website, but only from JS that is part of the pages of that website.
The situation when it comes to mobile apps is completely different. The storage options are the following:
1. Local app documents or cache storage, accessible by that app.
2. Other local storage paths for user-created/readable files.
3. NSUserDefaults and SharedPreferences respectively on iOS and Android for key-value storage.
4. Keychain on iOS and KeyStore on Android for secure storage of, respectively, any data and cryptographic keys.
Using the Flutter shared_preferences package uses localStorage on the Web, SharedPreferences on Android, and NSUserDefaults on iOS. Those have utterly completely different implications for your app, particularly if youre storing sensitive info like session tokens: localStorage are often scanned by the shopper, thus its a tangle if youre prone to XSS. although mobile apps arent very prone to XSS, SharedPreferences and NSUserDefaults don't seem to be secure storage ways as a result of they will be compromised on the shopper-facet since they're not secure storage and not encrypted.
Thats as a result of they're meant for user preferences, as mentioned here within the case of iOS and here within the robot documentation once talking concerning the protection library that is meant to produce wrappers to the SharedPreferences specifically to inscribe the info before storing it.
The only secure storage solutions on mobile are Keychain and KeyStore on iOS and Android respectively, whereas there is no secure storage on the Web. The Keychain and KeyStore area unit terribly completely different in nature, though: Keychain could be a generic credentials storage resolution, whereas the KeyStore is employed to store (and will generate) science keys, either stellate keys or public/private keys.
This means that if, for example, you would like to store a session token, on iOS you'll be able to let the OS manage the coding half and simply send your token to the Keychain, whereas on humanoid its a small amount a lot of manual expertise as a result of you would like to get (not hard-code, thats bad) a key, use it to cypher the token, store the encrypted token in SharedPreferences and store the key within the KeyStore.
There area unit completely different approaches to it, as area unit most things in security, however, the only is perhaps to use stellate coding, as there's no want for public-key cryptography since your app each encrypts and decrypts the token. Obviously, you dont have to be compelled to write mobile platform-specific code that will all of that, as there is a Flutter plugin that does all of that, for instance.
Those areas arent accessible by JS and are sent solely to your server. the problem thereupon is that theyre continuously sent to your server, notwithstanding one amongst your users clicks on a GET request address on somebody elses web site which GET request has aspect effects you or your user wont like. This really works for different request varieties moreover, its simply a lot of sophisticated. Its referred to as Cross-Site Request Forgery and you dont wish that.
Its among the net security threats mentioned in Mozillas MDN docs, wherever you'll be able to notice a lot of complete rationalization. There area unit interference strategies. the foremost common one has 2 tokens, actually: one amongst them aiming to the shopper as Associate in Nursing httpOnly cookie, the opposite as a part of the response.
The latter must be held on in localStorage and not in cookies as a result of we have a tendency to dont wish it to be sent mechanically to the server.
What if you have both a mobile app and a Web app?
That can be dealt with in one of two ways:
1. Use the same backend endpoint, but manually get and send the cookies using the cookie-related HTTP headers;
2. Create a separate non-Web backend endpoint that generates different token than either token used by the Web app and then allow for regular JWT authorization if the client is able to provide the mobile-only token.
Running Different Code On Different Platforms
Now, lets see how we can run different code on different platforms in order to be able to compensate for the differences.
Especially to unravel the matter of storage, a technique you'll do this is with a plugin package: plugins offer a typical Dart interface and might run totally different code on different platforms, together with native platform-specific Kotlin/Java or Swift/Objective-C code. Developing packages and plugins is quite complicated, however, its explained in several places on the net et al. (for example in Flutter books), together with the official Flutter documentation.
For mobile platforms, for example, there already may be a secure storage plugin, and thats flutter_secure_storage, that you'll notice associate example of the usage here, however that doesnt work on the net, as an example.
On the opposite hand, for easy key-value storage that additionally works on the net, theres a cross-platform Google-developed first-party plugin package known as shared_preferences, that incorporates a Web-specific part known as shared_preferences_web that uses NSUserDefaults, SharedPreferences or localStorage reckoning on the platform.
After importing package:flutter/foundation.dart, you can compare Theme.of(context).platform to the values:
TargetPlatform.android
TargetPlatform.iOS
TargetPlatform.linux
TargetPlatform.windows
TargetPlatform.macOS
TargetPlatform.fuchsia
and write your functions so that, for each platform you want to support, they do the appropriate thing. This will come especially useful for the next example of platform difference, and that is differences in how widgets are displayed on different platforms.
For that use case, in particular, there is also a reasonably popular flutter_platform_widgets plugin, which simplifies the development of platform-aware widgets.
You cant simply write cross-platform code and fake a browser, a phone, a computer, and a smartwatch area unit a similar factor unless you wish your humanoid and iOS app to be a WebView and your desktop app to be designed with lepton.
There area unit many reasons to not try this, and its not the purpose of this piece to convert you to use frameworks like Flutter instead that keep your app native, with all the performance and user expertise blessings that go with it, whereas permitting you to jot down code that's progressing to be a similar for all platforms most of the time.
That requires care and a focus, though, and a minimum of a basic data of the platforms you wish to support, their actual native genus Apis, and every one of that.
React Native users have to be compelled to pay even additional attention thereto as a result of that framework uses the inherent OS widgets, thus you really have to be compelled to pay even additional attention to however the app appearance by testing it extensively on each platform, while not having the ability to modify between iOS and Material device on the fly like its potential with Flutter.
There are some aspects of the UI of your app that are automatically changed when you switch platforms. This section also mentions what changes between Flutter and React Native in this respect.
Flutter is capable of rendering Material widgets on iOS (and Cupertino (iOS-like) widgets on Android), however, what it DOESNT do is show precisely the same factor on robot and iOS: Material theming particularly adapts to the conventions of every platform.
For instance, navigation animations and transitions and default fonts area units completely different, however, those dont impact your app that abundant. What might have an effect on a number of your decisions once it involves aesthetics or wife is that the indisputable fact that some static components conjointly modification.
Specifically, some icons modification between the 2 platforms, app bar titles area unit within the middle on iOS and on the left on robot (on the left of the on the market area just in case there's a back button or the button to open a Drawer (explained here within the Material style pointers and conjointly called a hamburger menu). Heres what a fabric app with a Drawer feels like on Android:
And what the same, very simple, Material app looks like on iOS:
On the online there's a small amount of a unique state of affairs, as mentioned conjointly during this Smashing article regarding Responsive net Development with Flutter:
specifically, additionally to having to optimize for larger screens and account for the means folks expect to navigate through your web site that is that the main focus of that article you have got to stress regarding the very fact that generally widgets square measure placed outside of the browser window.
Also, some phones have notches within the high a part of their screen or different impediments to the proper viewing of your app attributable to some form of obstruction. Both of those issues may be avoided by wrapping your conveniences during a SafeArea widget, that may be a explicit reasonably cushioning convenience that makes certain your widgets comprise an area wherever they will really be displayed empty preventive the users ability to envision them, be it a hardware or code constraint.
React Native needs far more attention and a way deeper information of every platform, additionally to requiring you to run the iOS machine furthermore because the mechanical man human at the terribly least so as to be able to check your app on each platform: its not identical and it converts its JavaScript UI parts to platform-specific widgets.
In alternative words, your React Native apps can invariably seem like iOS with Cupertino UI parts as they're generally known as and your mechanical man apps can invariably seem like regular Material style mechanical man apps as a result of its victimization the platforms widgets. The distinction here is that Flutter renders its widgets with its own low-level rendering engine, which implies you'll be able to check each app versions on one platform.
Getting Around That Issue
But that also means that you can do most of your Flutter development on a Linux or Windows workstation without sacrificing the experience of your iOS users, and then just build the app for the other platform and not have to worry about thoroughly testing it.
Next Steps
Cross-platform frameworks are awesome, but they shift responsibility to you, the developer, to understand how each platform works and how to make sure your app adapts and is pleasant to use for your users. Other small things to consider may be, for example, using different descriptions for what might be in essence the same thing if there are different conventions on different platforms.
Its great to not have to build the two (or more) apps separately using different languages, but you still need to keep in mind you are, in essence, building more than one app and that requires thinking about each of the apps you are building.
We will be happy to answer your questions on designing, developing, and deploying comprehensive enterprise web, mobile apps, and customized software solutions that best fit your organization's needs.
As a reputed Software Solutions Developer we have expertise in providing dedicated
remote and outsourced technical resources for software services at a very nominal cost. Besides experts in full stacks, We also build web solutions, mobile apps, and work on system integration, performance enhancement, cloud migrations, and big data analytics. Dont hesitate to get in touch with us!
This email address is being protected from spambots. You need JavaScript enabled to view it.
For more information:
The rest is here:
Solving common cross-platform issues when working with flutter - WhaTech
- Make Money from Images, Documents and Photos Uploading - December 18th, 2016 [December 18th, 2016]
- Immortal but Damned to Hell on Earth - The Atlantic - January 29th, 2017 [January 29th, 2017]
- Hands on review: Zencastr podcast maker - The Sydney Morning Herald - February 7th, 2017 [February 7th, 2017]
- How to keep your children safe online as it's revealed half of six-year-olds use the internet - Mirror.co.uk - February 7th, 2017 [February 7th, 2017]
- Yetunde Olasiyan: Between Having a Voice & the Need to Show Off on Social Media - Bella Naija - February 7th, 2017 [February 7th, 2017]
- How a WiFi Pilot Program Is Helping Students in the Rio Grande Valley - KUT - February 7th, 2017 [February 7th, 2017]
- These Shows Understand Why TV Cannot Survive Without The Internet And They're Doing Something About It - Decider - February 8th, 2017 [February 8th, 2017]
- 10 reasons to not miss John Bender at El Club this weekend - Detroit Metro Times - February 8th, 2017 [February 8th, 2017]
- Ideal Flatmate promises to stamp out all roommate worries - The Tech Portal - February 8th, 2017 [February 8th, 2017]
- Five ways to ensure your kids are safe as they go 'online' - The Standard (press release) - February 8th, 2017 [February 8th, 2017]
- How to improve your LinkedIn profile - ArabianBusiness.com - February 9th, 2017 [February 9th, 2017]
- Deal: New customers can get Google Play Music and YouTube Red free for 4 months - Android Authority (blog) - February 10th, 2017 [February 10th, 2017]
- Breaking Down Global Silos (Part 2): Lessons Learned from Conflict - Spend Matters - February 14th, 2017 [February 14th, 2017]
- Issa Rae New Series Giants Is A Must Watch - CampusLATELY (blog) - February 15th, 2017 [February 15th, 2017]
- Fake news, who benefits? - Shelbyville Times-Gazette (blog) - February 16th, 2017 [February 16th, 2017]
- GST beneficial for traders, says official - The Hindu - February 16th, 2017 [February 16th, 2017]
- It's time to get tech-savvy with The Mind Lab by Unitec! - Scoop.co.nz - February 16th, 2017 [February 16th, 2017]
- 'Being an Irish author is more of a Grimm fairytale than a Cinderella story' - Irish Times - February 17th, 2017 [February 17th, 2017]
- Barbie becomes a hologram version of herself - TechCrunch - February 18th, 2017 [February 18th, 2017]
- PLYMOUTH BUSINESS EXPANSION: MycomPETibility.com goes nationwide - Wicked Local Kingston - February 20th, 2017 [February 20th, 2017]
- The three reasons YouTubers keep imploding, from a YouTuber - Polygon - February 22nd, 2017 [February 22nd, 2017]
- SnailBlitz 2017: Citizen Scientists Wanted - NBC Southern California - February 22nd, 2017 [February 22nd, 2017]
- Nikon D5600 Review: Hoping to Make Photo Transfers a Snap - Huffington Post - February 27th, 2017 [February 27th, 2017]
- Appealing Social Security Decisions Online - CBN News - February 28th, 2017 [February 28th, 2017]
- How to file your social security appeal online - WZZM13.com - February 28th, 2017 [February 28th, 2017]
- Meteor is OpenSignal's own speed test app - SlashGear - March 1st, 2017 [March 1st, 2017]
- Data limits are the worsthere's how to stay under yours - Popular Science - March 3rd, 2017 [March 3rd, 2017]
- Overcome problems with public cloud storage providers - TechTarget - March 3rd, 2017 [March 3rd, 2017]
- When Words Beget Blows - Outlook India - March 4th, 2017 [March 4th, 2017]
- A man with vitiligo who was called 'zebra' by bullies has defied their cruel comments by becoming a model - The Sun - March 8th, 2017 [March 8th, 2017]
- Shark Tank's Robert Herjavec coaches kids to fuel entrepreneurial spirit - VentureBeat - March 9th, 2017 [March 9th, 2017]
- Everything new in Stellaris: Utopia, one of Paradox's biggest game updates ever - PC Gamer - March 10th, 2017 [March 10th, 2017]
- IN TRANSIT: The Idol Maker - Mumbai Mirror - March 11th, 2017 [March 11th, 2017]
- Paytm to continue free uploading of money - Business Standard - March 11th, 2017 [March 11th, 2017]
- The perils and false rewards of parenting in the era of 'digi-discipline' - Minnesota Public Radio News - April 8th, 2017 [April 8th, 2017]
- Showtime docu-series sees the 'Dark' side of tech - LA Daily News - April 8th, 2017 [April 8th, 2017]
- Elon Musk: Australian man pens desperate letter to download his brain - NEWS.com.au - April 8th, 2017 [April 8th, 2017]
- How Vestas Wind Systems used outsourced machine learning to transform contract management - Diginomica - June 7th, 2017 [June 7th, 2017]
- Wednesday Web Artist of the Week: Eva Papamargariti - ArtSlant - June 7th, 2017 [June 7th, 2017]
- Your Obsolete Brain: Life and Death in the Age of Superintelligent Machines - Digital Journal - June 7th, 2017 [June 7th, 2017]
- Under Armour launches its first customisable shoes - just-style.com (subscription) - June 8th, 2017 [June 8th, 2017]
- I Don't Care What You Think, I Love My Facial Birthmark - SELF - June 9th, 2017 [June 9th, 2017]
- Cable: Where Are We Headed After This Political Meltdown? - Seeking Alpha - June 9th, 2017 [June 9th, 2017]
- Best Screen Recorders Top 10 Screen Capture Software - Gazette Review - June 10th, 2017 [June 10th, 2017]
- Nigeria just got a verified Twitter handle - TechCabal - June 12th, 2017 [June 12th, 2017]
- Just keep pinning: why your business should be on Pinterest - Cambridge Network - June 12th, 2017 [June 12th, 2017]
- Track-by-Track of Paramore's 'Riot!' Read Through Emo Teen Memories - Noisey - June 13th, 2017 [June 13th, 2017]
- Decision day for Go Forward Pine Bluff - Pine Bluff Commercial - June 13th, 2017 [June 13th, 2017]
- Addressing rape culture - News24 - June 14th, 2017 [June 14th, 2017]
- Italy's Samantha Cristoforetti Says Being a Good Astronaut is All About Teamwork - Fortune - June 16th, 2017 [June 16th, 2017]
- Google Drive will soon make it easy to Backup and Sync PCs, Macs - SlashGear - June 16th, 2017 [June 16th, 2017]
- What's worse than getting phished? Getting phished *and* sending a selfie of your Photo ID and credit card - Graham Cluley Security News - June 17th, 2017 [June 17th, 2017]
- Track Of The Day 16/6 - Maximillian - Clash Magazine - June 17th, 2017 [June 17th, 2017]
- AROUND TOWN: GOP chairman questions Ossoff's London office - MDJOnline.com - June 20th, 2017 [June 20th, 2017]
- RESEARCH & TECHNOLOGY/INNOVATION: ITS Fiber brings fast connections, data center services to local business - TCPalm - June 20th, 2017 [June 20th, 2017]
- Fiberlink Internet Packages & Prices 2017 - TechJuice (press release) (blog) - June 20th, 2017 [June 20th, 2017]
- CS Editors: Creating Content - Security Sales & Integration - June 20th, 2017 [June 20th, 2017]
- How to post a GIF to Facebook - Tech Advisor (registration) - June 21st, 2017 [June 21st, 2017]
- The Living Vampire / Real Vampire FAQ (Frequently Asked Questions) - HuffPost - June 21st, 2017 [June 21st, 2017]
- Facebook Is Introducing New Tools to Protect Women in India - Fortune - June 21st, 2017 [June 21st, 2017]
- Mum drops off daughter at college then sends her hilarious texts with football team - NEWS.com.au - June 22nd, 2017 [June 22nd, 2017]
- Is Chrome OS right for you? A 3-question quiz to find out - Computerworld - June 22nd, 2017 [June 22nd, 2017]
- Facebook wants to stop creeps from downloading your profile picture - TNW - June 23rd, 2017 [June 23rd, 2017]
- Action and Emotion - lareviewofbooks - June 26th, 2017 [June 26th, 2017]
- 6 ways to be more hirable and 1 that could land a job today - Deseret News - June 27th, 2017 [June 27th, 2017]
- Searching for a Career? Set up a Free Profile at AutoCareCareers.org - PR Newswire (press release) - June 27th, 2017 [June 27th, 2017]
- Industry Job Seekers Can Set Up A Free Profile At AutoCareCareers.Org - AftermarketNews.com (AMN) - June 29th, 2017 [June 29th, 2017]
- Steve Mitchell The Mind of Watercolor Blog - June 29th, 2017 [June 29th, 2017]
- How to Upload to Google Drive - Cloudwards - July 1st, 2017 [July 1st, 2017]
- Stevie Ryan, YouTube personality, found dead at home - Blasting News - July 4th, 2017 [July 4th, 2017]
- 5 tips to a delicious food photo - Orlando Sentinel - July 5th, 2017 [July 5th, 2017]
- Gordon Hayward the best Jazz wing player of all time? Not what the numbers say. - SLC Dunk - July 5th, 2017 [July 5th, 2017]
- 36 Years of Loretta's - Racer X Online - July 6th, 2017 [July 6th, 2017]
- How to Work on Your Laptop at a Coffee Shop Without Being a Jerk - Lifehacker - July 8th, 2017 [July 8th, 2017]
- There's a new most-viewed Youtube video, pushing Gangnam Style off the top spot - Buzz.ie - July 12th, 2017 [July 12th, 2017]
- How to prevent bandwidth throttling with a VPN - T3 - July 14th, 2017 [July 14th, 2017]
- Google will now let you back up your entire computer for FREE on its servers - Mirror.co.uk - July 15th, 2017 [July 15th, 2017]
- Google Drive Backup and Sync lets you backup your entire computer: Here's how it works - BGR India - July 17th, 2017 [July 17th, 2017]
- Why Mythology Still Matters: Wisdom from Game of Thrones' 'Dragonstone' - Big Think - July 17th, 2017 [July 17th, 2017]
- Mum somehow manages to convince her daughter her nipple's fallen off in hilarious text exchange - Metro - July 18th, 2017 [July 18th, 2017]