![[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)

![[bootstrap-tagsinput]タグ入力欄でEnterキー押下時にSubmitさせない方法](https://www.yukiiworks.com/wp-content/uploads/2019/05/javascript-150x150.png)
![[iOS]Can’t end BackgroundTask: no background task exists with identifier 1 (0x1), or it may have already been ended. Break in UIApplicationEndBackgroundTaskError() to debug.エラーについて](https://www.yukiiworks.com/wp-content/uploads/2019/09/Xcode-150x150.png)
![[Swift4]Viewの角を丸くする方法](https://www.yukiiworks.com/wp-content/uploads/2019/04/swift-150x150.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-150x150.png)
![[Laravel]ランダムな文字列を生成する](https://www.yukiiworks.com/wp-content/uploads/2019/05/laravel-150x150.png)
![[Pixcel 3a] 開発者モード設定方法](https://www.yukiiworks.com/wp-content/uploads/2019/04/android-150x150.jpg)
