0

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.

Jammer
  • 9,969
  • 11
  • 68
  • 115
  • You could design custom drawers for each platform and show a specific one using the ``kIsWeb``. More info https://stackoverflow.com/a/50744481/5882307 – OMi Shah Aug 08 '21 at 12:42
  • 1
    BOOM!! EXACTLY what I was looking for. Please add as an answer so I can give you some rep. Thank you. – Jammer Aug 08 '21 at 12:45
  • just added as an answer. :) – OMi Shah Aug 08 '21 at 17:17
  • 1
    Does this answer your question? [How do you detect the host platform from Dart code?](https://stackoverflow.com/questions/45924474/how-do-you-detect-the-host-platform-from-dart-code) – snakecharmerb Aug 08 '21 at 17:21

1 Answers1

1

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

OMi Shah
  • 5,768
  • 3
  • 25
  • 34