mirror of
https://github.com/flutter/samples.git
synced 2026-03-24 05:12:06 +00:00
19 lines
517 B
Dart
19 lines
517 B
Dart
import 'dart:convert';
|
|
|
|
import 'package:http/http.dart' as http;
|
|
import 'package:http/testing.dart';
|
|
|
|
// Set up a mock HTTP client.
|
|
final http.Client mockClient = MockClient(_mockHandler);
|
|
|
|
Future<http.Response> _mockHandler(http.Request request) async {
|
|
var decodedJson = Map<String, dynamic>.from(
|
|
json.decode(request.body) as Map<String, dynamic>);
|
|
|
|
if (decodedJson['email'] == 'root' && decodedJson['password'] == 'password') {
|
|
return http.Response('', 200);
|
|
}
|
|
|
|
return http.Response('', 401);
|
|
}
|