패키지, 저장소 및 앱 카테고리 검색

requests_inspector 표지
패키지 상세v5.5.1

requests_inspector

REST-API 및 GraphQL 요청을 로깅하기 위한 Flutter 패키지로, 전화기를 흔들어 화면에 RequestsInspector 위젯을 표시할 수 있습니다.

AndroidiOS
30일 다운로드
8.3천
좋아요
167
Pub 점수
130

패키지 설치

flutter pub add requests_inspector

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

RequestsInspector는 개발 중 HTTP 및 GraphQL 요청을 디버깅하기 위해 설계된 Flutter 패키지입니다. 모든 외부 API 호출을 로그로 기록하고, 장치를 흔들어 실시간으로 요청/응답 데이터에 접근할 수 있도록 전용 인스펙터 위젯을 표시합니다. 코드 수정 없이 네트워크 활동을 빠르게 확인해야 하는 개발자에게 이상적입니다. 이 패키지는 Android와 iOS 플랫폼을 모두 지원하며, dio 또는 http와 같은 기존 HTTP 클라이언트와 원활하게 통합됩니다. 가벼운 설계로 성능에 미치는 영향을 최소화합니다.

사용 사례

  • API 엔드포인트 디버깅
  • GraphQL 쿼리 모니터링
  • 요청 헤더 및 본문 검사
  • 개발 중 실시간 네트워크 로깅
  • 실패한 요청 문제 해결

주요 기능

  • 흔들어서 검사기 열기
  • HTTP 및 GraphQL 지원
  • 크로스 플랫폼(안드로이드 및 iOS)
  • 최소한의 설정 필요
  • 실시간 요청/응답 보기

적합한 대상

  • 디버그 모드에서의 Flutter 개발자
  • 팀이 API 통합 테스트 중
  • 프론트엔드 엔지니어가 네트워크 문제를 진단하고 있습니다
  • REST/GraphQL를 사용하는 모바일 앱 개발자
  • 빠른 네트워크 검사를 필요로 하는 누구나

고려 사항

  • 생산 환경 사용을 위한 것이 아님
  • 흔들기 제스처를 사용하려면 물리적 장치가 필요합니다
  • 디버그 빌드에 한정
  • 로그의 지속적 저장 없음
  • 일부 기기에서는 권한이 필요할 수 있습니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Stand With Palestine

requests_inspector 🕵

pub package

A Flutter package for logging API requests (Http Requests & GraphQL) requests.

Main Features:
  1. Log your Http request, GraphQL and WebSockets.
  2. Intercept your requests and responses for testing.
  3. Share request details as json, cURL, or HAR file to re-run it again (ex. Postman).

And more and more

To get the RequestsInspector widget on your screen:
  1. 📱💃 : Shake your phone.

  2. 📱👈 : Long-Press on any free space on the screen.

Also you can share the request details as (Log, cURL command, or HAR file) with your team to help them debug the API requests.

From Inspector to Postman 🧡 🎉️ Now you can extract cURL command from the inspector to send the request again from your terminal or Postman 💪💪

HAR File Support 📦 🎉️ You can now share requests as HAR (HTTP Archive) files! HAR files are a standard format that can be imported into various tools like Postman, Proxyman, or any HAR-compatible tool for debugging and analysis. You can share HAR files in two formats:

  • HAR text: Copy the HAR content as text
  • HAR file (.har): Share as a downloadable .har file

The HAR format includes complete request/response details, headers, timing information, and more, making it perfect for comprehensive API debugging and sharing with your team.


Setup

First, add it at the top of your MaterialApp with enabled: true.

void main() {
  runApp(const RequestsInspector(
    child: MyApp(),
  ));
}
1. RESTful API:
Using Dio, pass by RequestsInspectorInterceptor() to Dio.interceptors and we are good to go 🎉️🎉️.
final dio = Dio()..interceptors.add(RequestsInspectorInterceptor());
If you don't use Dio then don't worry

In your API request just add a new RequestDetails using RequestInspectorController filled with the API data.

InspectorController().addNewRequest(
    RequestDetails(
        requestName: requestName,
        requestMethod: RequestMethod.GET,
        url: apiUrl,
        queryParameters: params,
        statusCode: responseStatusCode,
        responseBody: responseData,
        ),
    );
Real Restful example

a. Normal InspectorController().addNewRequest.

Future<List<Post>> fetchPosts() async {
  final dio = Dio();
  final params = {'userId': 1};

  final response = await dio.get(
    '[https://jsonplaceholder.typicode.com/posts](https://jsonplaceholder.typicode.com/posts)',
    queryParameters: params,
  );

  final postsMap = response.data as List;
  final posts = postsMap.map((postMap) => Post.fromMap(postMap)).toList();

  InspectorController().addNewRequest(
    RequestDetails(
      requestName: 'Posts',
      requestMethod: RequestMethod.GET,
      url: '[https://jsonplaceholder.typicode.com/posts](https://jsonplaceholder.typicode.com/posts)',
      queryParameters: params,
      statusCode: response.statusCode ?? 0,
      responseBody: response.data,
    ),
  );

  return posts;
}

b. Using RequestsInspectorInterceptor.

Future<List<Post>> fetchPosts() async {
  final dio = Dio()..interceptors.add(RequestsInspectorInterceptor());
  final response = await dio.get('[https://jsonplaceholder.typicode.com/posts](https://jsonplaceholder.typicode.com/posts)');

  final postsMap = response.data as List;
  final posts = postsMap.map((postMap) => Post.fromMap(postMap)).toList();

  return posts;
}
Finaly, Shake your phone to get the Inspector

<img src = "https://raw.githubusercontent.com/Abdelazeem777/requests_inspector/main/images/mobile_list.jpg" width ="280" /> <img src = "https://raw.githubusercontent.com/Abdelazeem777/requests_inspector/main/images/mobile_request.jpg" width ="280" />


2. GraphQl:

To use requests_inspector with graphql_flutter library. you jus need to wrap your normal HttpLink with our GraphQLInspectorLink and we are done.

Example:

 Future<List<Post>> fetchPostsGraphQlUsingGraphQLFlutterInterceptor() async {
 Future<List<Post>> fetchPostsGraphQlUsingGraphQLFlutterInterceptor() async {
  final client = GraphQLClient(
    cache: GraphQLCache(),
    link: Link.split(
      (request) => request.isSubscription,
      GraphQLInspectorLink(WebSocketLink('ws://graphqlzero.almansi.me/api')),
      GraphQLInspectorLink(HttpLink('[https://graphqlzero.almansi.me/api](https://graphqlzero.almansi.me/api)')),
    ),
  );
  const query = r'''query {
    post(id: 1) {
      id
      title
      body
    }
    }''';

  final options = QueryOptions(document: gql(query));
  final result = await client.query(options);
  if (result.hasException) {
    log(result.exception.toString());
  } else {
    log(result.data.toString());
  }
  var post = Post.fromMap(result.data?['post']);
  return [post];
}

Stopper (Requests & Responses)

requests_inspector (Stopper) enables your to stop and edit requests (before sending it to server) and responses (before receiving it inside the app).

  • First, you need to add navigatorKey to your MaterialApp then pass it to RequestsInspector to show Stopper dialogs.
final navigatorKey = GlobalKey<NavigatorState>();

void main() => runApp(
  RequestsInspector(
    // Add your `navigatorKey` to enable `Stopper` feature
    navigatorKey: navigatorKey,
    child: const MyApp(),
  ),
);

// ...

@override
Widget build(BuildContext context) {
  return MaterialApp(
    navigatorKey: navigatorKey, // <== Here!
    // ...
  • Second, just enable it from Inspector and it will stop all your requests and responses.

<img src="https://raw.githubusercontent.com/Abdelazeem777/requests_inspector/main/images/stopper_feature.gif" width="280"/>


For Web, Windows, MacOS and Linux

Obviously, The shaking won't be good enough for those platforms 😅

So you can specify showInspectorOn with ShowInspectorOn.LongPress.

void main() {
  runApp(const RequestsInspector(
    enabled: true,
    showInspectorOn: ShowInspectorOn.LongPress
    child: MyApp(),
  ));
}

OR, you can just pass ShowInspectorOn.Both to open the Inspector with Shaking or with LongPress.

void main() {
  runApp(const RequestsInspector(
    enabled: true,
    showInspectorOn: ShowInspectorOn.Both,
    child: MyApp(),
  ));
}

Some images

🤝 Contributors

Contributors helping improve requests_inspector: 💻🎨📖🚧


Abdelazeem

Belal

Mostafa

Abdelrahman

Anthony

M Hussein

Vadym

M Gawdat

Anas

Moaz

Michelle

Abdullah

Ahmed

Nourhan

Anthony
How to Contribute

We welcome contributions from everyone! Here's how you can help:

  1. Report Issues: Found a bug or have a feature request? Open an issue
  2. Submit Pull Requests: Have a fix or improvement? We'd love to review your PR!
  3. Improve Documentation: Help us make the docs clearer and more comprehensive
  4. Share Feedback: Let us know how you're using the package and what could be better

To add yourself as a contributor, simply follow the contribution guidelines and your efforts will be recognized here!


Future plans:

  • [x] Add support for GraphQL.
  • [x] Enhance the GraphQL request and response displaying structure.
  • [x] Improve the request tab UI and add expand/collapse for each data block.
  • [x] Better UI.
  • [x] Support Dark/Light Modes.
  • [x] Powerful JSON Tree View.
  • [x] Collapsable separated sections.
  • [x] Click to Copy Content of each section.
  • [ ] Add search inside the request details page.
  • [ ] Add Http Interceptor.
  • [ ] 'WillPopScope' is deprecated and shouldn't be used. Use PopScope instead. The Android predictive back feature will not work with WillPopScope.

📃 License

This project is licensed under the MIT License - see the LICENSE file for details.

🎉 Thank you for using Requests Inspector!

카테고리

의존성

의존성 목록 9 개

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.