How do I build different versions of my Flutter app for qa/dev/prod?

后端 未结 9 1612
清歌不尽
清歌不尽 2020-12-01 00:14

I am building a Flutter app, and I have variables with different values for different environments (QA, dev, prod, etc). What\'s a good way to organize my app so I can easil

9条回答
  •  庸人自扰
    2020-12-01 01:06

    import 'package:flutter/foundation.dart';
    

    And use following const values:

    if (kReleaseMode) {
      // App is running in release mode. 
    } else if (kProfileMode) {
      // App is running in profile mode.
    } else if (kDebugMode) {
      // App is running in debug mode.
    } else if (kIsWeb) {
      // App is running on the web.
    }
    

提交回复
热议问题