1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-11 15:28:44 +00:00

add form_app (#463)

* add form_app

* revert unrelated changes

* use links in README

* remove unnecessary type annotation

* Remove GlobalKey for sign_in_http sample

* reword comment

* run package:copywriter

* use relative import

* fix quotes

* Add punctuation

* make sure setState() is used in form_widgets sample

* avoid first person pronoun

* store date state in parent widget in form_widgets.dart
This commit is contained in:
John Ryan
2020-06-12 12:38:46 -07:00
committed by GitHub
parent a94342d199
commit af5be70f34
72 changed files with 2598 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
// Copyright 2020, the Flutter project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:mockito/mockito.dart';
class MockClient extends Mock implements http.Client {
MockClient() {
when(post('https://example.com/signin', body: anyNamed('body')))
.thenAnswer((answering) {
var body = answering.namedArguments[Symbol('body')];
if (body != null && body is String) {
var decodedJson = json.decode(body);
if (decodedJson['email'] == 'root' &&
decodedJson['password'] == 'password') {
return Future.value(http.Response('', 200));
}
}
return Future.value(http.Response('', 401));
});
when(post('https://example.com/signout'))
.thenAnswer((_) => Future.value(http.Response('', 401)));
}
}