teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

8

修正

2021/01/25 15:01

投稿

narururu
narururu

スコア172

title CHANGED
@@ -1,1 +1,1 @@
1
- 【flutter】DecorationImage内に変数に格納した画像を表示させたい
1
+ 【flutter】画像を円形にしたい
body CHANGED
File without changes

7

修正

2021/01/25 15:00

投稿

narururu
narururu

スコア172

title CHANGED
File without changes
body CHANGED
@@ -48,7 +48,7 @@
48
48
 
49
49
  ##
50
50
 
51
- ちなみに、elseのコードを以下のようにすれば画像は表示さますが、整形したいのでDecorationImageを使用しています。しかし、そうするとエラーとなってしまうのです。。。
51
+ ちなみに、elseのコードを以下のようにすれば画像は表示さますが、整形したいのでDecorationImageを使用しています。しかし、そうするとエラーとなってしまうのです。。。
52
52
  ```ここに言語を入力
53
53
  else {
54
54
  return Image.file(imageFile, width: 110, height: 110,);

6

修正

2021/01/25 01:55

投稿

narururu
narururu

スコア172

title CHANGED
@@ -1,1 +1,1 @@
1
- 【flutter】DecorationImage内に変数に格納したローカル画像を表示させたい
1
+ 【flutter】DecorationImage内に変数に格納した画像を表示させたい
body CHANGED
File without changes

5

追記

2021/01/25 01:54

投稿

narururu
narururu

スコア172

title CHANGED
File without changes
body CHANGED
@@ -47,6 +47,13 @@
47
47
  ```
48
48
 
49
49
  ##
50
+
51
+ ちなみに、elseのコードを以下のようにすれば画像は表示させますが、整形したいのでDecorationImageを使用しています。しかし、そうするとエラーとなってしまうのです。。。
52
+ ```ここに言語を入力
53
+ else {
54
+ return Image.file(imageFile, width: 110, height: 110,);
55
+ }
56
+ ```
50
57
  どうすればエラーを解消し、画像データを表示させることができるのかわかりません。
51
58
  どなたかアドバイスいただけますと助かります。
52
59
  よろしくお願いいたします。

4

追記修正

2021/01/25 01:51

投稿

narururu
narururu

スコア172

title CHANGED
@@ -1,1 +1,1 @@
1
- 【flutter】変数に格納したローカル画像を表示させたい
1
+ 【flutter】DecorationImage内に変数に格納したローカル画像を表示させたい
body CHANGED
@@ -25,7 +25,7 @@
25
25
  decoration: BoxDecoration(
26
26
  shape: BoxShape.circle,
27
27
  image: DecorationImage(
28
- image: Image.memory(imageFile)),
28
+ image: MemoryImage(imageFile)),
29
29
  ),
30
30
  );
31
31
  }
@@ -35,22 +35,15 @@
35
35
  ## エラー
36
36
  エラーの原因箇所は下記です。
37
37
  ```ここに言語を入力
38
- image: Image.memory(imageFile)),
38
+ image: MemoryImage(imageFile)),
39
39
  ```
40
40
 
41
41
  ## エラーコード
42
42
  ```ここに言語を入力
43
- lib/main.dart:113:35: Error: The argument type 'File' can't be assigned to the parameter type 'Uint8List'.
43
+ lib/main.dart:113:40: Error: The argument type 'File' can't be assigned to the parameter type 'Uint8List'.
44
44
  - 'File' is from 'dart:io'.
45
45
  - 'Uint8List' is from 'dart:typed_data'.
46
- image: Image.memory(imageFile)),
46
+ image: MemoryImage(imageFile),
47
- ^
48
- lib/main.dart:113:28: Error: The argument type 'Image' can't be assigned to the parameter type 'ImageProvider<Object>'.
49
- - 'Image' is from 'package:flutter/src/widgets/image.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/image.dart').
50
- - 'ImageProvider' is from 'package:flutter/src/painting/image_provider.dart' ('/C:/src/flutter/packages/flutter/lib/src/painting/image_provider.dart').
51
- - 'Object' is from 'dart:core'.
52
- image: Image.memory(imageFile)),
53
-
54
47
  ```
55
48
 
56
49
  ##

3

追記

2021/01/25 01:23

投稿

narururu
narururu

スコア172

title CHANGED
File without changes
body CHANGED
@@ -2,6 +2,7 @@
2
2
  変数に格納したローカルの画像データを表示させたいです。
3
3
 
4
4
  ## コード
5
+ ※エラーが出力されている原因となるコードのみを記載しております。
5
6
  ```ここに言語を入力
6
7
  Widget _decideImageView() {
7
8
  if(imageFile == null) {

2

修正

2021/01/24 16:52

投稿

narururu
narururu

スコア172

title CHANGED
File without changes
body CHANGED
@@ -12,7 +12,7 @@
12
12
  decoration: BoxDecoration(
13
13
  shape: BoxShape.circle,
14
14
  image: DecorationImage(
15
- image: AssetImage("images/account.PNG")
15
+ image: AssetImage("images/test.PNG")
16
16
  ),
17
17
  ),
18
18
  ),

1

修正

2021/01/24 16:51

投稿

narururu
narururu

スコア172

title CHANGED
File without changes
body CHANGED
@@ -7,13 +7,8 @@
7
7
  if(imageFile == null) {
8
8
  return Center(
9
9
  child: Column(
10
- mainAxisAlignment: MainAxisAlignment.start,
11
- crossAxisAlignment: CrossAxisAlignment.center,
12
10
  children: [
13
11
  Container(
14
- width: 110.0,
15
- height: 110.0,
16
- margin: EdgeInsets.only(top: 30),
17
12
  decoration: BoxDecoration(
18
13
  shape: BoxShape.circle,
19
14
  image: DecorationImage(
@@ -26,9 +21,6 @@
26
21
  );
27
22
  } else {
28
23
  return Container(
29
- width: 110.0,
30
- height: 110.0,
31
- margin: EdgeInsets.only(top: 30),
32
24
  decoration: BoxDecoration(
33
25
  shape: BoxShape.circle,
34
26
  image: DecorationImage(