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

質問編集履歴

4

追記

2021/01/30 14:41

投稿

narururu
narururu

スコア172

title CHANGED
File without changes
body CHANGED
@@ -127,7 +127,7 @@
127
127
  ),),
128
128
  onTap: () => _onButtonPressed(),
129
129
  ),
130
- Fruits.replaceAll(_selectedItem);
130
+        Fruits.replaceAll('くだもの', _selectedItem);
131
131
  ]
132
132
  ),
133
133
  );
@@ -135,9 +135,8 @@
135
135
  ```
136
136
  エラー
137
137
  ```ここに言語を入力
138
- lib/main.dart:40:45: Error: Expected ']' before this.
138
+ lib/main.dart:40:53: Error: Expected ']' before this.
139
- Fruits.replaceAll(_selectedItem);
139
+ Fruits.replaceAll('くだも�?�', _selectedItem);
140
- ^
140
+ ^
141
- lib/main.dart:40:30: Error: Too few positional arguments: 2 required, 1 given.
141
+ lib/main.dart:40:20: Error: A value of type 'String' can't be assigned to a variable of type 'Widget'.
142
- Fruits.replaceAll(_selectedItem);
143
142
  ```

3

追記

2021/01/30 14:41

投稿

narururu
narururu

スコア172

title CHANGED
File without changes
body CHANGED
@@ -132,4 +132,12 @@
132
132
  ),
133
133
  );
134
134
  }
135
+ ```
136
+ エラー
137
+ ```ここに言語を入力
138
+ lib/main.dart:40:45: Error: Expected ']' before this.
139
+ Fruits.replaceAll(_selectedItem);
140
+ ^
141
+ lib/main.dart:40:30: Error: Too few positional arguments: 2 required, 1 given.
142
+ Fruits.replaceAll(_selectedItem);
135
143
  ```

2

追記

2021/01/30 14:38

投稿

narururu
narururu

スコア172

title CHANGED
File without changes
body CHANGED
@@ -104,4 +104,32 @@
104
104
  ## 試したこと
105
105
  _selectedItem をTextやListTileの階層に入れてみたりしましたがエラーとなってしまいます。
106
106
  条件分岐式で解決できないか試したりしているのですが、解決できません。
107
+
108
+ ##
107
- どなたか、アドバイスをよろしくお願いいたします。
109
+ どなたか、アドバイスをよろしくお願いいたします。
110
+
111
+ ## 追記
112
+ replaceAllという方法を知り、試してみましたがエラーとなってしまいました。
113
+ ```ここに言語を入力
114
+ // ignore: non_constant_identifier_names
115
+ String Fruits = 'くだもの';
116
+
117
+ @override
118
+ Widget build(BuildContext context) {
119
+ return Scaffold(
120
+ body: ListView(
121
+ children: <Widget>[
122
+ ListTile(
123
+ title: Text(
124
+ 'くだもの',
125
+ style: TextStyle(
126
+ color: Colors.grey,
127
+ ),),
128
+ onTap: () => _onButtonPressed(),
129
+ ),
130
+ Fruits.replaceAll(_selectedItem);
131
+ ]
132
+ ),
133
+ );
134
+ }
135
+ ```

1

修正

2021/01/30 14:36

投稿

narururu
narururu

スコア172

title CHANGED
File without changes
body CHANGED
@@ -1,5 +1,5 @@
1
1
  ## 解決したい課題
2
- 「くだもの」と表示されている項目をタップし、BottomSheetから選択したフルーツが「くだもの」置き換わるようにしたい。
2
+ 「くだもの」と表示されている項目をタップし、BottomSheetから選択したフルーツが「くだもの」から選択したフルーツに置き換わるようにしたい。
3
3
 
4
4
  ## 現状
5
5
  選択したフルーツが「くだもの」の下に表示されてしまう。