mirror of
https://github.com/flutter/samples.git
synced 2025-11-10 14:58:34 +00:00
Update mockito in form_app (#904)
This commit is contained in:
@@ -9,12 +9,14 @@ import 'package:mockito/mockito.dart';
|
||||
|
||||
class MockClient extends Mock implements http.Client {
|
||||
MockClient() {
|
||||
when(post('https://example.com/signin', body: anyNamed('body')))
|
||||
when(post('https://example.com/signin',
|
||||
body: anyNamed('body'), headers: anyNamed('headers')))
|
||||
.thenAnswer((answering) {
|
||||
dynamic body = answering.namedArguments[const Symbol('body')];
|
||||
|
||||
if (body != null && body is String) {
|
||||
var decodedJson = json.decode(body) as Map<String, String>;
|
||||
var decodedJson = Map<String, dynamic>.from(
|
||||
json.decode(body) as Map<String, dynamic>);
|
||||
|
||||
if (decodedJson['email'] == 'root' &&
|
||||
decodedJson['password'] == 'password') {
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'sign_in_http.g.dart';
|
||||
@@ -86,7 +86,7 @@ class _SignInHttpDemoState extends State<SignInHttpDemo> {
|
||||
headers: {'content-type': 'application/json'});
|
||||
|
||||
if (result.statusCode == 200) {
|
||||
_showDialog('Succesfully signed in.');
|
||||
_showDialog('Successfully signed in.');
|
||||
} else if (result.statusCode == 401) {
|
||||
_showDialog('Unable to sign in.');
|
||||
} else {
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
// 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 'package:flutter/material.dart';
|
||||
import 'package:english_words/english_words.dart' as english_words;
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class FormValidationDemo extends StatefulWidget {
|
||||
const FormValidationDemo({Key key}) : super(key: key);
|
||||
|
||||
Reference in New Issue
Block a user