![[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)
![[Laravel]バリデーションルールを使って特定のカラムで存在チェックする方法](https://www.yukiiworks.com/wp-content/uploads/2019/05/laravel-150x150.png)
![[Flutter]iOS実機ビルド時に"iproxy"は、開発元を検証できないため開けません。と表示された場合の対処法](https://www.yukiiworks.com/wp-content/uploads/2020/08/flutter-150x150.png)
![[Swift3]画面の幅、高さを取得する(画面サイズ)](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)
![[AndroidX対応]Error inflating class android.support.design.widget.BottomNavigationViewエラーについて](https://www.yukiiworks.com/wp-content/uploads/2019/04/android-150x150.jpg)
