In Ionic I can build one app and at runtime Ionic choose the right skin Cupertino or Android.
Can Flutter do the same? I have read the documentation but I can't see any wrappers around the Android and Cupertino widgets.
If you want to create separate iOs and Android "looks", you can use a plugin like this one:
https://pub.dartlang.org/packages/flutter_platform_widgets#-readme-tab-
You have full control over which parts of your UI should be platform-specific, and which parts you want to keep uniform. For example, you can create your own custom button instead of using Cupertino button on iOs and RaisedButton on Android, but you may want to use different TextField widgets on iOs and Android.
It does and it does not, some widgets behave differently out of the box depending on the platform. Like the ScrollView, which bounces on iOS and creates a wave like overlay on Android.
But for the real native experience you have to create your own widgets that build either Material or Cupertino UI.
Example:
...
Widget _customButton() {
return Platform.isIOS
? CupertinoButton(
child: Text('Tap me'),
onPressed: () {},
)
: RaisedButton(
child: Text('Tap me'),
onPressed: () {},
);
}
...
Related
I'm building a screen and flutter where the user will visualize some data and when user user touche the screen I want to show up some options just like youtube app's player does.
For example, user is using the app in landscape orientation:
When it touches the screen I want to show some options just like that:
What are the options to achieve this behavior in my flutter app?
You can wrap the whole thing with GestureDetector
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () => {// show the controls},
child: DataVisualizer(),
),
Be careful that using this method will also trigger the click or press method of the GestureDetector if they are tappable.
I don't even think this is possible but, what I'm looking for is to allow the showMenu() popup to go beyond the application window.
Currently, I'm using:
showMenu(
context: context,
items: <PopupMenuEntry>[
PopupMenuItem(
value: 1,
child: Row(
children: const <Widget>[
Icon(Icons.delete),
Text("Delete"),
],
),
)
],
position: RelativeRect.fromLTRB(0, 0,0,0),
);
Simply changing the position field to be below the height bounds of the application window doesn't work for me.
Edit: I do know that it is possible with a C# desktop app where a dropdown popup can go outside the bounds of the application window, so I figured flutter could do this as well.
Currently Flutter only supports a single window, so there's no way to do this from Dart at the moment.
If it's a critical feature for your application, you would need to build a plugin that shows a native popup. The menu's UI would need to be native as well, unless you bring up a second Flutter engine just to draw it.
I am learning Flutter. The version I am using is Flutter 1.24.0-10.2.pre • channel dev.
I am working on a project that could run on Windows 10 and Android. Therefore I use the dev channel. The project is a notebook, each note has a title, content and tags. I use a ListView to show the titles.
Is it possible to show an edit icon on that row and covers parts of the title when user tap the title? The icon is hidden when the row is not highlighted, tapped.
I did try to put a Scaffold inside a Scaffold, but it fail.
Thank you very much!
If you use a stateful widget, then onTap: () setState(() => listViewTileTabbed[index] = true),
and in the tile you also add
leading: listViewTileTabbed[index] ? Text('Edit') : null,
I noticed that a Flutter Web project that I am making with the font_awesome_flutter plugin is being slowed down by the font_size download. I'm only using one icon from the font. Is there any way I can get this smaller?
Here is the data from webpagetest.org:
Remove the Font Awesome plugin from your project
Remove the font_awesome_flutter plugin from pubspec.yaml and wherever you are using it in your project.
Generate a font with only the icons that you need
You can just extract the icons you need from the font and discard the rest. An east way to do this is to use the IcoMoon site. For example I used the site to generate a font with only the Apple logo icon.
Note the code (eabe). You'll use it later.
Add the font in Flutter
You get get instructions for doing that here. I called my font family Apple.
Use the icon in your app
To use your icon just use a Text widget with the code as the text and specify the font family that you registered in step 2.
FlatButton(
child: Text(
'\ueabe',
style: TextStyle(fontFamily: 'Apple', fontSize: 24),
),
onPressed: () {
model.onApplePressed();
},
),
Here is what it looks like in the app:
Check the size
Rebuild your Flutter web app and put it online.
Here is retesting the site at webpagetest.org.
It's not as small as I expected but the font size is definitely better. (The site is also using Material Design icons so that may be contributing to the remaining font size.)
I want to track if a widget is show on the screen. Like a card in a list view.
There is a widget in Flutter like GestureDetector for impression or tracking?
You might want to look into the firebase_analytics plugin. You can set it up to track when users look at certain pages. See the plugin page for more info.
I wrote a library for this https://github.com/623637646/flutter_impression
ImpressionDetector(
impressedCallback: () {
debugPrint('impressed');
},
child: MyWidget(),
)