Jammer
Jammer

Reputation: 10208

Flutter Platform Specific Navigation Approaches

I've just looking at Flutter for the first time and have a question around navigation. I have a single project targeting iOS, Android and Web.

I'm looking at Navigation Drawers here:

https://material.io/components/navigation-drawer/flutter#using-a-navigation-drawer

Is it possible to use a Standard Drawer if the target is Web and a Modal if targeting mobile?

I can't quite find anything in the docs around varying things on different platforms or idioms.

Upvotes: 0

Views: 209

Answers (1)

OMi Shah
OMi Shah

Reputation: 6186

You could design custom drawers for each platform and show the specific one by checking the user's platform using the kIsWeb constant.

For example:

import 'package:flutter/foundation.dart' show kIsWeb;

if (kIsWeb) {
  // how the web version drawer widget
} else {
  // show the non-web version drawer widget
}

Reference taken from https://stackoverflow.com/a/50744481/5882307

Upvotes: 1

Related Questions