-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update dependencies, refactor error view and add new network plugin
This commit updates the project's dependencies, refactors how error views are managed and adds a new HTTP network plugin. It also adjusts some file and variable names for improved clarity. Coding conventions and organization have been improved for greater code readability and maintainability. Additionally, several functionalities have been enhanced, such as actions now being able to return Future or void.
- Loading branch information
1 parent
cd38563
commit 46961a6
Showing
30 changed files
with
540 additions
and
57 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
60 changes: 60 additions & 0 deletions
60
packages/system/vyuh_core/lib/plugin_types/network/http_network_plugin.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import 'dart:convert'; | ||
|
||
import 'package:http/http.dart'; | ||
import 'package:vyuh_core/vyuh_core.dart'; | ||
|
||
final class HttpNetworkPlugin extends NetworkPlugin { | ||
late Client _client; | ||
var _initialized = false; | ||
|
||
HttpNetworkPlugin() | ||
: super(name: 'vyuh.plugin.network.http', title: 'HTTP Network Plugin'); | ||
|
||
@override | ||
Future<void> init() async { | ||
if (_initialized) { | ||
return; | ||
} | ||
|
||
_client = Client(); | ||
_initialized = true; | ||
} | ||
|
||
@override | ||
Future<void> dispose() async { | ||
if (!_initialized) { | ||
return; | ||
} | ||
|
||
_client.close(); | ||
_initialized = false; | ||
} | ||
|
||
@override | ||
Future<Response> get(Uri url, {Map<String, String>? headers}) => | ||
_client.get(url, headers: headers); | ||
|
||
@override | ||
Future<Response> head(Uri url, {Map<String, String>? headers}) => | ||
_client.head(url, headers: headers); | ||
|
||
@override | ||
Future<Response> post(Uri url, | ||
{Map<String, String>? headers, Object? body, Encoding? encoding}) => | ||
_client.post(url, headers: headers, body: body, encoding: encoding); | ||
|
||
@override | ||
Future<Response> put(Uri url, | ||
{Map<String, String>? headers, Object? body, Encoding? encoding}) => | ||
_client.put(url, headers: headers, body: body, encoding: encoding); | ||
|
||
@override | ||
Future<Response> delete(Uri url, | ||
{Map<String, String>? headers, Object? body, Encoding? encoding}) => | ||
_client.delete(url, headers: headers, body: body, encoding: encoding); | ||
|
||
@override | ||
Future<Response> patch(Uri url, | ||
{Map<String, String>? headers, Object? body, Encoding? encoding}) => | ||
_client.patch(url, headers: headers, body: body, encoding: encoding); | ||
} |
25 changes: 25 additions & 0 deletions
25
packages/system/vyuh_core/lib/plugin_types/network/network_plugin.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import 'dart:convert'; | ||
|
||
import 'package:http/http.dart'; | ||
import 'package:vyuh_core/vyuh_core.dart'; | ||
|
||
abstract base class NetworkPlugin extends Plugin { | ||
NetworkPlugin({required super.name, required super.title}) | ||
: super(pluginType: PluginType.network); | ||
|
||
Future<Response> get(Uri url, {Map<String, String>? headers}); | ||
|
||
Future<Response> head(Uri url, {Map<String, String>? headers}); | ||
|
||
Future<Response> post(Uri url, | ||
{Map<String, String>? headers, Object? body, Encoding? encoding}); | ||
|
||
Future<Response> put(Uri url, | ||
{Map<String, String>? headers, Object? body, Encoding? encoding}); | ||
|
||
Future<Response> delete(Uri url, | ||
{Map<String, String>? headers, Object? body, Encoding? encoding}); | ||
|
||
Future<Response> patch(Uri url, | ||
{Map<String, String>? headers, Object? body, Encoding? encoding}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.