This reverts commit 949023b27686fb80a0047157490d6c4c61995cef.
This commit is contained in:
parent
f34c2ef0a3
commit
499004779b
@ -72,7 +72,6 @@ class Form extends StatefulWidget {
|
||||
this.autovalidate = false,
|
||||
this.onWillPop,
|
||||
this.onChanged,
|
||||
this.onSaved,
|
||||
}) : assert(child != null),
|
||||
super(key: key);
|
||||
|
||||
@ -119,13 +118,6 @@ class Form extends StatefulWidget {
|
||||
/// will rebuild.
|
||||
final VoidCallback onChanged;
|
||||
|
||||
/// Called when the form is saved (after all the form fields have been saved).
|
||||
///
|
||||
/// See also:
|
||||
///
|
||||
/// * [FormState.save]
|
||||
final VoidCallback onSaved;
|
||||
|
||||
@override
|
||||
FormState createState() => FormState();
|
||||
}
|
||||
@ -180,8 +172,6 @@ class FormState extends State<Form> {
|
||||
void save() {
|
||||
for (FormFieldState<dynamic> field in _fields)
|
||||
field.save();
|
||||
if (widget.onSaved != null)
|
||||
widget.onSaved();
|
||||
}
|
||||
|
||||
/// Resets every [FormField] that is a descendant of this [Form] back to its
|
||||
|
@ -6,10 +6,9 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('onSaved callbacks are called', (WidgetTester tester) async {
|
||||
testWidgets('onSaved callback is called', (WidgetTester tester) async {
|
||||
final GlobalKey<FormState> formKey = GlobalKey<FormState>();
|
||||
String fieldValue;
|
||||
bool fieldModifiedSinceFormOnSaved;
|
||||
|
||||
Widget builder() {
|
||||
return MediaQuery(
|
||||
@ -20,12 +19,8 @@ void main() {
|
||||
child: Material(
|
||||
child: Form(
|
||||
key: formKey,
|
||||
onSaved: () { fieldModifiedSinceFormOnSaved = false; },
|
||||
child: TextFormField(
|
||||
onSaved: (String value) {
|
||||
fieldValue = value;
|
||||
fieldModifiedSinceFormOnSaved = true;
|
||||
},
|
||||
onSaved: (String value) { fieldValue = value; },
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -43,7 +38,6 @@ void main() {
|
||||
formKey.currentState.save();
|
||||
// pump'ing is unnecessary because callback happens regardless of frames
|
||||
expect(fieldValue, equals(testValue));
|
||||
expect(fieldModifiedSinceFormOnSaved, isFalse);
|
||||
}
|
||||
|
||||
await checkText('Test');
|
||||
|
Loading…
x
Reference in New Issue
Block a user