iTranslated by AI
How to force Mobile or Desktop view on iPad with flutter_inappwebview v6
Conclusion
Set preferredContentMode.MOBILE and userAgent in initialSettings.
Example (Forcing mobile version display)
// Fix display to mobile version
InAppWebView(
initialSettings: InAppWebViewSettings(
userAgent:
'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1',
preferredContentMode: UserPreferredContentMode.MOBILE),
When only one is included
I initially tried without including the userAgent, and it didn't work for most sites.
Therefore, I think it's better to include the userAgent for the size you want to fix.
I copied the ones for Safari and iOS from the link below.
Since I'm only using it for mobile detection, I haven't separated them by OS this time.
Recommendations
I've summarized my personal recommendations for starting app development with Flutter.
I think it's a good idea to read the latest books for free using Kindle Unlimited.
Recommended Books
If you're starting now, you should avoid reading books written during the Flutter 1.x era.
The reason is that since Flutter 2.x, a feature called null-safety was introduced, and the coding style changed significantly.
I started Flutter around the time 2.x was released, and I struggled quite a bit because the information wasn't reliable.
For Beginners 【Free with Kindle Unlimited】
Let's build an app that runs on a smartphone! Flutter Practical Introduction from Scratch ①: Let's build a simple app
Detailed Flutter Explanation by a Beginner for Beginners
For Post-Beginners (Includes specific implementation methods and techniques such as in-app purchase implementation)
Practical Flutter Development Introduction for the Field
Discussion