host.docker.internalというドメインが初見だったので調べてみると、Docker Desktop for xxで利用できる、コンテナから参照する場合のhostを指すドメインだということです。わたしの環境はDocker Desktop for Macを利用しているので利用できるはずです。
$ git diff Gemfile diff --git a/api/Gemfile b/api/Gemfile --- a/api/Gemfile +++ b/api/Gemfile @@ -76,6 +76,7 @@ group :test do gem "capybara" gem "selenium-webdriver" gem "webdrivers" + gem "committee-rails" end
1 2 3 4 5 6 7 8 9 10 11
$ docker-compose run --rm api ./bin/bundle install Using devise-i18n 1.10.2 Using devise_token_auth 1.2.1 Installing openapi_parser 0.15.0 Installing json_schema 0.21.0 Fetching committee 4.4.0 Installing committee 4.4.0 Fetching committee-rails 0.6.1 Installing committee-rails 0.6.1 Bundle complete! 29 Gemfile dependencies, 114 gems now installed. Use `bundle info [gemname]` to see where a bundled gem is installed.
RSpec.describe "API::Auth::RegistrationsController", type: :request do describe "POST /api/v1/auth" do it "returns 200" do post "/api/v1/auth", params: { email: "example@example.com" } assert_response_schema_confirm(200) end
it "returns 422" do post "/api/v1/auth", params: { password: "password" } assert_response_schema_confirm(422) end end end
specの実行
では実行します。
1 2 3 4 5 6 7 8 9 10
$ docker-compose run --rm api ./bin/rspec spec/api/v1/auth/registrations_controller_spec.rb
(省略)
Failures: 1) API::Auth::RegistrationsController POST /api/v1/auth return 200 Failure/Error: <p><%= link_to t('.confirm_account_link'), confirmation_url(@resource, {confirmation_token: @token, config: message['client-config'].to_s, redirect_url: message['redirect-url']}).html_safe %></p> ActionView::Template::Error: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true
$ docker-compose run --rm api ./bin/rspec spec/api/v1/auth/registrations_controller_spec.rb
(省略)
API::Auth::RegistrationsController POST /api/v1/auth [DEPRECATION] Committee: please set query_hash_key = rack.request.query_hash because we'll change default value in next major version. [DEPRECATION] Committee: please set parse_response_by_content_type = false because we'll change default value in next major version.
$ flutter pub add shared_preferences ╔════════════════════════════════════════════════════════════════════════════╗ ║ A new version of Flutter is available! ║ ║ ║ ║ To update to the latest version, run "flutter upgrade". ║ ╚════════════════════════════════════════════════════════════════════════════╝
$ git status On branch master Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git restore <file>..." to discard changes in working directory) modified: pubspec.lock modified: pubspec.yaml
$ git diff pubspec.yaml diff --git a/pubspec.yaml b/pubspec.yaml index 037db97..2c583dc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -34,6 +34,7 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 + shared_preferences: ^2.0.13 dev_dependencies: flutter_test:
$ flutter upgrade Upgrading Flutter to 2.10.4 from 2.10.3 in /Users/user/flutter... Downloading Dart SDK from Flutter engine 57d3bac3dd5cb5b0e464ab70e7bc8a0d8cf083ab... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed
$ flutter run Launching lib/main.dart on iPhone 13 in debug mode... Running Xcode build... └─Compiling, linking and signing... 4.3s Xcode build done. 12.6s Syncing files to device iPhone 13... 90ms
Flutter run key commands. r Hot reload. 🔥🔥🔥 R Hot restart. h List all available interactive commands. d Detach (terminate "flutter run" but leave application running). c Clear the screen q Quit (terminate the application on the device).
💪 Running with sound null safety 💪
An Observatory debugger and profiler on iPhone 13 is available at: http://127.0.0.1:57320/EBquF8FZZxI=/ The Flutter DevTools debugger and profiler on iPhone 13 is available at: http://127.0.0.1:9100?uri=http://127.0.0.1:57320/EBquF8FZZxI=/
$ ~/Library/Android/sdk/emulator/emulator -avd Pixel_5_API_30 INFO | Android emulator version 31.2.8.0 (build_id 8143646) (CL:N/A) WARNING | unexpected system image feature string, emulator might not function correctly, please try updating the emulator. INFO | configAndStartRenderer: setting vsync to 60 hz WARNING | cannot add library /Users/user/Library/Android/sdk/emulator/qemu/darwin-x86_64/lib64/vulkan/libvulkan.dylib: failed INFO | added library /Users/user/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib INFO | Started GRPC server at 127.0.0.1:8554, security: Local INFO | Advertising in: /Users/user/Library/Caches/TemporaryItems/avd/running/pid_77656.ini INFO | Your emulator is out of date, please update by launching Android Studio: - Start Android Studio - Select menu "Tools > Android > SDK Manager" - Click "SDK Tools" tab - Check "Android Emulator" checkbox - Click "OK"
$ flutter run Using hardware rendering with device Android SDK built for x86. If you notice graphics artifacts, consider enabling software rendering with "--enable-software-rendering". Launching lib/main.dart on Android SDK built for x86 in debug mode... Checking the license for package Android SDK Tools in /Users/user/Library/Android/sdk/licenses License for package Android SDK Tools accepted. Preparing "Install Android SDK Tools (revision: 26.1.1)". "Install Android SDK Tools (revision: 26.1.1)" ready. Installing Android SDK Tools in /Users/user/Library/Android/sdk/tools "Install Android SDK Tools (revision: 26.1.1)" complete. "Install Android SDK Tools (revision: 26.1.1)" finished. Checking the license for package Android SDK Build-Tools 29.0.2 in /Users/user/Library/Android/sdk/licenses License for package Android SDK Build-Tools 29.0.2 accepted. Preparing "Install Android SDK Build-Tools 29.0.2 (revision: 29.0.2)". "Install Android SDK Build-Tools 29.0.2 (revision: 29.0.2)" ready. Installing Android SDK Build-Tools 29.0.2 in /Users/user/Library/Android/sdk/build-tools/29.0.2 "Install Android SDK Build-Tools 29.0.2 (revision: 29.0.2)" complete. "Install Android SDK Build-Tools 29.0.2 (revision: 29.0.2)" finished. Checking the license for package Android SDK Platform 31 in /Users/user/Library/Android/sdk/licenses License for package Android SDK Platform 31 accepted. Preparing "Install Android SDK Platform 31 (revision: 1)". "Install Android SDK Platform 31 (revision: 1)" ready. Installing Android SDK Platform 31 in /Users/user/Library/Android/sdk/platforms/android-31 "Install Android SDK Platform 31 (revision: 1)" complete. "Install Android SDK Platform 31 (revision: 1)" finished. Running Gradle task 'assembleDebug'... 157.2s ✓ Built build/app/outputs/flutter-apk/app-debug.apk. Installing build/app/outputs/flutter-apk/app.apk... 1,035ms Syncing files to device Android SDK built for x86... 116ms
Flutter run key commands. r Hot reload. 🔥🔥🔥 R Hot restart. h List all available interactive commands. d Detach (terminate "flutter run" but leave application running). c Clear the screen q Quit (terminate the application on the device).
💪 Running with sound null safety 💪
An Observatory debugger and profiler on Android SDK built for x86 is available at: http://127.0.0.1:58754/V-rtq-7NtAg=/ The Flutter DevTools debugger and profiler on Android SDK built for x86 is available at: http://127.0.0.1:9100?uri=http://127.0.0.1:58754/V-rtq-7NtAg=/
$ flutter create -i swift -a kotlin --androidx --org org.book-reviews --description 'flutter sample app' flutter_sample_app Could not find an option named "androidx".
Run 'flutter -h' (or 'flutter <command> -h') for available flutter commands and options.
$ flutter upgrade Flutter is already up to date on channel stable Flutter 2.10.3 • channel stable • https://github.com/flutter/flutter.git Framework • revision 7e9793dee1 (2 weeks ago) • 2022-03-02 11:23:12 -0600 Engine • revision bd539267b4 Tools • Dart 2.16.1 • DevTools 2.9.2
もともと最新だったようです。再度実行してみます。
1 2 3 4
$ flutter create -i swift -a kotlin --androidx --org org.book-reviews --description 'flutter sample app' flutter_sample_app Could not find an option named "androidx".
Run 'flutter -h' (or 'flutter <command> -h') for available flutter commands and options.
If run on a project that already exists, this will repair the project, recreating any files that are missing.
Global options: -h, --help Print this usage information. -v, --verbose Noisy logging, including all shell commands executed. If used with "--help", shows hidden options. If used with "flutter doctor", shows additional diagnostic information. (Use "-vv" to force verbose logging in those cases.) -d, --device-id Target device id or name (prefixes allowed). --version Reports the version of this tool. --suppress-analytics Suppress analytics reporting when this command runs.
Usage: flutter create <output directory> -h, --help Print this usage information. --[no-]pub Whether to run "flutter pub get" after the project has been created. (defaults to on) --[no-]offline When "flutter pub get" is run by the create command, this indicates whether to run it in offline mode or not. In offline mode, it will need to have all dependencies already available in the pub cache to succeed. --[no-]overwrite When performing operations, overwrite existing files. --description The description to use for your new Flutter project. This string ends up in the pubspec.yaml file. (defaults to "A new Flutter project.") --org The organization responsible for your new Flutter project, in reverse domain name notation. This string is used in Java package names and as prefix in the iOS bundle identifier. (defaults to "com.example") --project-name The project name for this new Flutter project. This must be a valid dart package name. -i, --ios-language The language to use for iOS-specific code, either ObjectiveC (legacy) or Swift (recommended). [objc, swift (default)] -a, --android-language The language to use for Android-specific code, either Java (legacy) or Kotlin (recommended). [java, kotlin (default)] --platforms The platforms supported by this project. Platform folders (e.g. android/) will be generated in the target project. This argument only works when "--template" is set to app or plugin. When adding platforms to a plugin project, the pubspec.yaml will be updated with the requested platform. Adding desktop platforms requires the corresponding desktop config setting to be enabled. [ios (default), android (default), windows (default), linux (default), macos (default), web (default)] -t, --template=<type> Specify the type of project to create.
[app] (default) Generate a Flutter application. [module] Generate a project to add a Flutter module to an existing Android or iOS application. [package] Generate a shareable Flutter project containing modular Dart code. [plugin] Generate a shareable Flutter project containing an API in Dart code with a platform-specific implementation for Android, for iOS code, or for both. [skeleton] Generate a List View / Detail View Flutter application that follows community best practices.
-s, --sample=<id> Specifies the Flutter code sample to use as the "main.dart" for an application. Implies "--template=app". The value should be the sample ID of the desired sample from the API documentation website (http://docs.flutter.dev/). An example can be found at: https://api.flutter.dev/flutter/widgets/SingleChildScrollView-class.html --list-samples=<path> Specifies a JSON output file for a listing of Flutter code samples that can be created with "--sample".
Run "flutter help" to see global options.
見たところ、--androidxというオプションはなさそうなので、なしで実行してみます。
1 2 3 4 5 6 7 8 9 10 11 12
$ flutter create -i swift -a kotlin --org org.book-reviews --description 'flutter sample app' flutter_sample_app Creating project flutter_sample_app... Running "flutter pub get" in flutter_sample_app... 2,764ms Wrote 96 files.
All done! In order to run your application, type:
$ cd flutter_sample_app $ flutter run
Your application code is in flutter_sample_app/lib/main.dart.
作成できました!
アプリケーションの起動
プロジェクト作成後のメッセージにアプリケーションの起動方法が書かれていたので早速実行してみます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
$ cd flutter_sample_app $ flutter run Launching lib/main.dart on Chrome in debug mode... Waiting for connection from debug service on Chrome... 15.4s This app is linked to the debug service: ws://127.0.0.1:52600/qyihwl33cdE=/ws Debug service listening on ws://127.0.0.1:52600/qyihwl33cdE=/ws
💪 Running with sound null safety 💪
🔥 To hot restart changes while running, press "r" or "R". For a more detailed help message, press "h". To quit, press "q".
An Observatory debugger and profiler on Chrome is available at: http://127.0.0.1:52600/qyihwl33cdE= A message on the flutter/keyevent channel was discarded before it could be handled. This happens when a plugin sends messages to the framework side before the framework has had an opportunity to register a listener. See the ChannelBuffers API documentation for details on how to configure the channel to expect more messages, or to expect messages to get discarded: https://api.flutter.dev/flutter/dart-ui/ChannelBuffers-class.html
Chromeが起動し、Flutter Demo Home Pageが表示されました。右下の+ボタンをクリックすると、真ん中に表示されている数字が増えていきます。