tang_network 0.0.4
tang_network: ^0.0.4 copied to clipboard
The util of HTTP Network implements on the Flutter platform.
tang_network #
The util of HTTP Networking with the capabilities:
- Get
- Post
- Upload
- Download
abstract configurationsupported
Installation #
dependencies:
tang_network: ^0.0.1
Usage #
Setup
- Implements the configurations for your project,
/// Configuration.
class MainConfigNetworkHttp implements NetworkHttpConfig { ... }
/// Base.
class MainConfigNetworkHttpBase implements NetworkHttpBase { ... }
/// Keys.
class MainConfigNetworkHttpKeys implements NetworkHttpKeys { ... }
/// Codes.
class MainConfigNetworkHttpCodes implements NetworkHttpCodes { ... }
/// Getters.
class MainConfigNetworkHttpGetters implements NetworkHttpGetters { ... }
/// Callbacks.
class MainConfigNetworkHttpCallbacks implements NetworkHttpCallbacks { ... }
- Invoke the
setup()method before the root page displaying,
await NetworkHttp.shared.setup(config: MainConfigNetworkHttp());
- Invoke the
setupDeviceInfo()method after user has granted the permission ofDevice Info, if you do not invoke this method, theDevice Infowill be passively initialized when theNetworkHttp.shared.request()method is called for the first time.
onPrivacyPolicyConfirmed: () async {
await NetworkHttp.shared.setupDeviceInfo();
}
Request
- Create your own API class and call the
NetworkHttpAPIs to send the requests,
final response = await NetworkHttp.shared.request('/api-service/module/method',
{
'param1': 1,
'param2': '2',
},
method: NetworkMethodType.post,
).then((resp) => NetworkRespModel.fromJson(resp));
return response;