Microsoft announces new progress in Flutter support for foldable devices

Microsoft announces new progress in Flutter support for foldable devices

Microsoft has released an update on supporting the development of foldable devices with Flutter. Previously, they showed users the PRs opened on Flutter Framework and Engine. The Engine PR has been merged; the original Framework PR was split into smaller PRs, some of which have also been merged.

Figure: Flutter foldable PR progress

MediaQuery now has Display Features

Display Features are parts of the display that can be hindered by hardware features. The hinge on the Surface Duo is such a display feature.

The MediaQuery PR has now been merged, which means that if you switch to the master channel in your local Flutter settings, you can access a property called displayFeatures. Some devices can have multiple display features, not just one, so this new property is a list. This is the structure of the items in the list:

 class DisplayFeature {
final Rect bounds ;
final DisplayFeatureType type ;
final DisplayFeatureState state ;
}

For more details, see the official documentation.

If you find that your code is always filtering the display features list to get hinges, you can use this extension method in your code:

 /// Extension method that helps with working with the hinge specifically.
extension MediaQueryHinge on MediaQueryData {
DisplayFeature ? get hinge {
for ( final DisplayFeature e in displayFeatures ) {
if ( e . type == DisplayFeatureType . hinge )
return e ;
}
return null ;
}
}

DisplayFeatureSubScreen has also been merged

When you only want to display content on one screen of the Surface Duo (which is the case when showing a dialog), you now have the option of using the DisplayFeatureSubScreen widget. This widget is primarily used for modal routes and is used heavily in the "Dialog and popup support" PR. In this sense, it is a stepping stone to full dialog support. If you have custom modal routes in your app, you may want to consider wrapping them with this widget.

 class _MyRoute < T > extends PopupRoute < T > {
@ override
Widget buildPage ( ... ) {
return DisplayFeatureSubScreen (
child : _myPageLayout (),
anchorPoint : Offset . infinite ,
);
}
}

Andrei Diaconu, senior software engineer for Surface Duo Experience, said that there are still some contributions that have not been merged, but the situation is much simpler than when these changes were first proposed. "Back then you had to configure a custom Flutter Engine, and now things are much simpler."

In addition, Microsoft has added some new samples for Flutter that showcase design patterns for foldable devices.

For more details, please visit the official blog.

This article is reproduced from OSCHINA

Title of this article: Microsoft announces new progress in Flutter foldable device support

Article URL: https://www.oschina.net/news/184674/foldable-flutter-update

<<:  Research on compatibility solutions for frosted glass CSS special effects

>>:  Finally supports personalized ringtones and HD videos! WeChat new version experience

Recommend

See if you can overcome these ten hurdles like Jack Ma?

Alibaba Group is about to set a global financing ...

Ali Xianyu’s event promotion and marketing rules!

To organize a good event, you cannot rely on sudd...

Maizi Interactive Entertainment - Douyin Local Lifestyle Entity Merchant Advanced Services

Course Catalog├──How to shoot and edit product dis...

How much does it cost to develop a wine utensils mini app in Xi'an?

How much does it cost to develop a Xi’an wineware...

Do you know what threats your mobile devices face?

Phishing and scams When phishing occurs, cybercri...

Avocado is a calorie bomb, so why do so many people eat it to lose weight?

There is a kind of fruit whose reputation is very...

Super practical SEM promotion case in vocational training industry

This article shares with you the SEM promotion ca...

In addition to SEM promotion, why do we need to invest in native advertising?

The key differences between native advertising an...

“Zero-base” facial expression recognition

1. Introduction In recent years, artificial intel...

Jinsheng Insurance: How to determine SEO keywords for a new website?

After a website is built, good keywords are very ...

Please, gentlemen, please stop giving your girlfriends Blue Roses, okay? !

On the brand new calendar, spring has already beg...