![[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][Kotlin]Error while saving scan status to file: Cannot delete existing file.エラーについて](https://www.yukiiworks.com/wp-content/uploads/2019/10/android-studio-e1585186990750-150x150.jpg)

![[bootstrap-tagsinput]タグ入力欄でEnterキー押下時にSubmitさせない方法](https://www.yukiiworks.com/wp-content/uploads/2019/05/javascript-150x150.png)
![[Swift]iOSのChartsで凡例を非表示にする方法](https://www.yukiiworks.com/wp-content/uploads/2019/04/swift-150x150.png)
![[PHP]local.ERROR: compact(): Undefined variable:エラーについて](https://www.yukiiworks.com/wp-content/uploads/2019/06/php-150x150.jpg)
![[Python][Crypto]Module Not Found Error](https://www.yukiiworks.com/wp-content/uploads/2019/11/python-logo-150x150.png)
![[AWS]Lambdaの環境変数をCLIコマンドで設定する](https://www.yukiiworks.com/wp-content/uploads/2020/04/lambda30-150x150.png)

