1// Copyright 2014 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5import 'message.dart';
6
7/// A Flutter Driver command that sends a string to the application and expects a
8/// string response.
9class RequestData extends Command {
10 /// Create a command that sends a message.
11 const RequestData(this.message, {super.timeout});
12
13 /// Deserializes this command from the value generated by [serialize].
14 RequestData.deserialize(super.json) : message = json['message'], super.deserialize();
15
16 /// The message being sent from the test to the application.
17 final String? message;
18
19 @override
20 String get kind => 'request_data';
21
22 @override
23 bool get requiresRootWidgetAttached => false;
24
25 @override
26 Map<String, String> serialize() =>
27 super.serialize()..addAll(<String, String>{if (message != null) 'message': message!});
28}
29
30/// The result of the [RequestData] command.
31class RequestDataResult extends Result {
32 /// Creates a result with the given [message].
33 const RequestDataResult(this.message);
34
35 /// The text extracted by the [RequestData] command.
36 final String message;
37
38 /// Deserializes the result from JSON.
39 static RequestDataResult fromJson(Map<String, dynamic> json) {
40 return RequestDataResult(json['message'] as String);
41 }
42
43 @override
44 Map<String, dynamic> toJson() => <String, String>{'message': message};
45}
46