0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

背景(画像)の追加方法

Posted at

背景を追加しようと考えた理由

現在は入道雲が出現したらそれをお知らせしてくれるアプリケーションの制作を進めています。
その中で東西南北のどこに入道雲が出現したかを表示する際に、文字で記入すると分かりづらいと思い、背景に地図を設置することで分かりやすいUIになるのではないかと考えました。

背景の追加方法

基本的にこの資料に沿って進めていきました。

プロジェクト直下にassetsフォルダーとimageフォルダーを作成し、
imageフォルダーの中に「入道雲写真.png」という画像を置きました。

コード

      body: Container(
          decoration: const BoxDecoration(
          image: DecorationImage(
          image: AssetImage('image/入道雲写真.png'),
          fit: BoxFit.cover,// 画像を全体に表示
          )
          ),
      )

エラーの出現

実行をすると以下のようなエラーが出ました

Unable to load asset: "image/入道雲写真.png".
Exception: Asset not found

このエラーが出た時に、依存関係のクリアなどを行っても意味がありませんでしたが、プロジェクトを開き直したら動くようになりました。

実装結果

※青のところは大学の位置です

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?