How do you detect the host platform from Dart code?

前端 未结 9 2216
情书的邮戳
情书的邮戳 2020-12-02 08:57

For UI that should differ slightly on iOS and Android, i.e. on different platforms, there must be a way to detect

9条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-02 09:34

    You can do

    defaultTargetPlatform == TargetPlatform.iOS
              ? kIOSTheme
              : kDefaultTheme,
    

    from import 'package:flutter/foundation.dart';

提交回复
热议问题