Issue
Is there a way to force an Flutter Android App to behave like it is on an iOS Device?
I'm not referring to the Cupertino package.
Here is what I mean with Android/iOS Style
iOS Style:
Android style:
Solution
You can set the platform parameter in the ThemeData of the app to TargetPlatform.iOS. Then the app will behave as if it were running on an iOS device, including showing iOS text controls, etc. Very useful for testing things out at least!
Here's a full app that will use iOS stylings even when run on an Android device:
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
void main() {
runApp(
MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
// The line below forces the theme to iOS.
platform: TargetPlatform.iOS,
),
home: Scaffold(
body: Center(
child: TextField(),
),
),
),
);
}
Answered By - Justin McCandless
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.