mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
* Driver commands for controlling the Input widget This commit introduces two new driver commands for controlling the material Input widget. * setInputText(SerializableFinder finder, String text) * submitInputText(SerializableFinder finder) Since it is not possible to directly modify the Input widget text, these driver commands invokes the handler functions of the Input widget: onChanged and onSubmitted, respectively. The `submitInputText` command returns the submitted String as a result. * Make input command handler methods private Addressing comments from @yjbanov.
63 lines
1.5 KiB
Dart
63 lines
1.5 KiB
Dart
// Copyright 2016 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import 'message.dart';
|
|
import 'find.dart';
|
|
|
|
class SetInputText extends CommandWithTarget {
|
|
@override
|
|
final String kind = 'setInputText';
|
|
|
|
SetInputText(SerializableFinder finder, this.text) : super(finder);
|
|
|
|
final String text;
|
|
|
|
static SetInputText deserialize(Map<String, dynamic> json) {
|
|
String text = json['text'];
|
|
return new SetInputText(SerializableFinder.deserialize(json), text);
|
|
}
|
|
|
|
@override
|
|
Map<String, String> serialize() {
|
|
Map<String, String> json = super.serialize();
|
|
json['text'] = text;
|
|
return json;
|
|
}
|
|
}
|
|
|
|
class SetInputTextResult extends Result {
|
|
static SetInputTextResult fromJson(Map<String, dynamic> json) {
|
|
return new SetInputTextResult();
|
|
}
|
|
|
|
@override
|
|
Map<String, dynamic> toJson() => <String, dynamic>{};
|
|
}
|
|
|
|
class SubmitInputText extends CommandWithTarget {
|
|
@override
|
|
final String kind = 'submitInputText';
|
|
|
|
SubmitInputText(SerializableFinder finder) : super(finder);
|
|
|
|
static SubmitInputText deserialize(Map<String, dynamic> json) {
|
|
return new SubmitInputText(SerializableFinder.deserialize(json));
|
|
}
|
|
}
|
|
|
|
class SubmitInputTextResult extends Result {
|
|
SubmitInputTextResult(this.text);
|
|
|
|
final String text;
|
|
|
|
static SubmitInputTextResult fromJson(Map<String, dynamic> json) {
|
|
return new SubmitInputTextResult(json['text']);
|
|
}
|
|
|
|
@override
|
|
Map<String, dynamic> toJson() => <String, dynamic>{
|
|
'text': text
|
|
};
|
|
}
|