![[Flutter]debugとreleaseビルドをコードから判別する方法](https://www.yukiiworks.com/wp-content/uploads/2020/08/flutter.png)
はじめに
Flutterにてビルド時のdebug or releaseをコードから判別する方法のメモです。
flutter run --debugやflutter run --releaseもしくはflutter build appbundle --debugとかflutter build appbundle --releaseのdebug or releaseを判別する方法です。
APIの向き先の切り替えとか諸々で使えるのかなと。
方法
以下のコードで取得できます。
1 | static const isRelease = const bool.fromEnvironment('dart.vm.product'); |
trueであればreleaseです。
dart-defineのdart.vm.productとして真偽値が環境変数に渡されている模様。
必ずconstの定数として取得してください。
以上です。
![[Flutter]flutter_svgにてEXCEPTION CAUGHT BY SVG](https://www.yukiiworks.com/wp-content/uploads/2020/08/flutter-300x144.png)
![[Docker]different lower_case_table_names settings for server ('1') and data dictionary ('0').エラーでコンテナが起動できない問題について](https://www.yukiiworks.com/wp-content/uploads/2019/08/docker-logo-2-300x169.png)
![[AltBeacon]E/CycledLeScannerForLollipop: Scan failed: app cannot be registeredエラーについて](https://www.yukiiworks.com/wp-content/uploads/2019/10/android-studio-e1585186990750-150x150.jpg)
![[Swift]TableViewの区切り線の余白を調整する](https://www.yukiiworks.com/wp-content/uploads/2019/04/swift-150x150.png)
![[bootstrap-tagsinput]タグ入力欄でEnterキー押下時にSubmitさせない方法](https://www.yukiiworks.com/wp-content/uploads/2019/05/javascript-150x150.png)
![[Laravel]name属性の配列要素をoldで取得する方法](https://www.yukiiworks.com/wp-content/uploads/2019/05/laravel-150x150.png)
![[AWS]Node.jsでSSMパラメータストアの値を取得する](https://www.yukiiworks.com/wp-content/uploads/2020/03/aws-eyecatch-960x504-1-150x150.png)
![[Python3]Enumで定義した値のリストを取得する](https://www.yukiiworks.com/wp-content/uploads/2019/11/python-logo-150x150.png)

