@@ -160,4 +160,73 @@ void main() {
160
160
await tester.pumpWidget (new Container (), const Duration (seconds: 2 ));
161
161
});
162
162
163
+ testWidgets ('Read operations on ScrollControllers with no positions fail' , (WidgetTester tester) async {
164
+ ScrollController controller = new ScrollController ();
165
+ expect (() => controller.offset, throwsAssertionError);
166
+ expect (() => controller.position, throwsAssertionError);
167
+ });
168
+
169
+ testWidgets ('Read operations on ScrollControllers with more than one position fail' , (WidgetTester tester) async {
170
+ ScrollController controller = new ScrollController ();
171
+ await tester.pumpWidget (new ListView (
172
+ children: < Widget > [
173
+ new Container (
174
+ constraints: const BoxConstraints (maxHeight: 500.0 ),
175
+ child: new ListView (
176
+ controller: controller,
177
+ children: kStates.map <Widget >((String state) {
178
+ return new Container (height: 200.0 , child: new Text (state));
179
+ }).toList (),
180
+ ),
181
+ ),
182
+ new Container (
183
+ constraints: const BoxConstraints (maxHeight: 500.0 ),
184
+ child: new ListView (
185
+ controller: controller,
186
+ children: kStates.map <Widget >((String state) {
187
+ return new Container (height: 200.0 , child: new Text (state));
188
+ }).toList (),
189
+ ),
190
+ ),
191
+ ],
192
+ ));
193
+
194
+ expect (() => controller.offset, throwsAssertionError);
195
+ expect (() => controller.position, throwsAssertionError);
196
+ });
197
+
198
+ testWidgets ('Write operations on ScrollControllers with no positions fail' , (WidgetTester tester) async {
199
+ ScrollController controller = new ScrollController ();
200
+ expect (() => controller.animateTo (1.0 , duration: const Duration (seconds: 1 ), curve: Curves .linear), throwsAssertionError);
201
+ expect (() => controller.jumpTo (1.0 ), throwsAssertionError);
202
+ });
203
+
204
+ testWidgets ('Write operations on ScrollControllers with more than one position fail' , (WidgetTester tester) async {
205
+ ScrollController controller = new ScrollController ();
206
+ await tester.pumpWidget (new ListView (
207
+ children: < Widget > [
208
+ new Container (
209
+ constraints: const BoxConstraints (maxHeight: 500.0 ),
210
+ child: new ListView (
211
+ controller: controller,
212
+ children: kStates.map <Widget >((String state) {
213
+ return new Container (height: 200.0 , child: new Text (state));
214
+ }).toList (),
215
+ ),
216
+ ),
217
+ new Container (
218
+ constraints: const BoxConstraints (maxHeight: 500.0 ),
219
+ child: new ListView (
220
+ controller: controller,
221
+ children: kStates.map <Widget >((String state) {
222
+ return new Container (height: 200.0 , child: new Text (state));
223
+ }).toList (),
224
+ ),
225
+ ),
226
+ ],
227
+ ));
228
+
229
+ expect (() => controller.jumpTo (1.0 ), throwsAssertionError);
230
+ expect (() => controller.animateTo (1.0 , duration: const Duration (seconds: 1 ), curve: Curves .linear), throwsAssertionError);
231
+ });
163
232
}
0 commit comments