request.dart 695 B

123456789101112131415161718192021
  1. import 'dart:async';
  2. import 'package:flutter/services.dart' show rootBundle;
  3. import 'dart:convert';
  4. class Request {
  5. static const String baseUrl = 'http://www.shuqi.com/';
  6. static Future<dynamic> get({required String action, Map? params}) async {
  7. return Request.mock(action: action, params: params);
  8. }
  9. static Future<dynamic> post({required String action, Map? params}) async {
  10. return Request.mock(action: action, params: params);
  11. }
  12. static Future<dynamic> mock({required String action, Map? params}) async {
  13. var responseStr = await rootBundle.loadString('assets/mock/$action.json');
  14. var responseJson = json.decode(responseStr);
  15. return responseJson['data'];
  16. }
  17. }