Skip to content

better_networking Package Creation #857

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 37 commits into from
Jun 29, 2025

Conversation

synapsecode
Copy link
Contributor

PR Description

This PR aims to separate all the networking related contents from apidash_core and instead re-package them into another public flutter package named better_networking.

This package contains all of the networking parts that apidash relies on. Including httpRequest creation, cancellation, HttpRequest & HttpResponse Models and so on

Moreover as a new feature, HTTP Streaming has been implemented with cancellation ability. This allows future expansion of apidash into Server Side Events (SSE), WebSockets and Streaming GenAI Responses

Streaming Request Example

final stream = await streamHttpRequest(
  'S1',
  APIType.rest,
  HttpRequestModel(
    method: HTTPVerb.post,
    url: 'http://localhost:11434/v1/chat/completions',
    body: jsonEncode({
      'model': 'gemma3:latest',
      'stream': true,
      "messages": [
        {
          "role": "system",
          "content":
              'Give me a 200 word essay about the given topic',
        },
        {"role": "user", "content": 'Flutter'},
      ],
    }),
  ),
);
stream.listen(
  (data) {
    print('Recieved Data: $data');
  },
  onDone: () {
    print('Streaming Complete');
  },
  onError: (e) {
    print(e);
  },
);

Cancelling Stream Request

cancelHttpRequest('S1');

Checklist

  • I have gone through the contributing guide
  • I have updated my branch and synced it with project main branch before making this PR
  • I am using the latest Flutter stable branch (run flutter upgrade and verify)
  • I have run the tests (flutter test) and all tests are passing

Added/updated tests?

We encourage you to add relevant test cases.

  • Yes
  • No, and this is why: It is just a repackaging, no new functionality added except streamingRequests

OS on which you have developed and tested the feature?

  • Windows
  • macOS
  • Linux

@synapsecode synapsecode changed the title Feat/better networking better_networking Package Creation Jun 17, 2025
@animator
Copy link
Member

import 'package:apidash_core/apidash_core.dart';

should not be replaced by

import 'package:better_networking/better_networking.dart';

apidash_core/apidash_core.dart should export 'package:better_networking/better_networking.dart'; which will make it available wherever apidash_core is imported inside apidash.

pubspec.yaml Outdated
@@ -14,6 +14,8 @@ dependencies:
path: packages/apidash_core
apidash_design_system:
path: packages/apidash_design_system
better_networking:
path: packages/better_networking
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not be directly added here.
better_networking will flow into apidash via apidash_core.

@synapsecode
Copy link
Contributor Author

Hi @animator, better_networking has been exported from apidash_code and all imports have been fixed.

@animator
Copy link
Member

Kindly make only necessary changes in the PR.
A lot of import formatting and other formatting changes have been made which is not required.

@animator
Copy link
Member

Use GitHub Desktop https://desktop.github.com/download/
to review file changes visually and discard changes before making a commit.

@synapsecode synapsecode force-pushed the feat/better_networking branch from 7830a14 to 1b64d05 Compare June 22, 2025 15:58
@synapsecode
Copy link
Contributor Author

have reverted them. changed file count is down. vscode had the format on save enabled so many of the modified files got auto-formatted and didnt catch it when seeing the changes.

@synapsecode synapsecode marked this pull request as ready for review June 22, 2025 17:05
animator added 17 commits June 29, 2025 06:00
Replaces the import of better_networking with apidash_core in the test file to reflect the correct package dependency.
Renamed the internal _cleanup and _handleError functions to cleanup and handleError, respectively, and updated all references.
Included HTTPVerb.options in the kMethodsWithBody constant to ensure OPTIONS requests are recognized as supporting a body.
@animator animator merged commit e5b22a2 into foss42:main Jun 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants