pop_network 0.0.16 copy "pop_network: ^0.0.16" to clipboard
pop_network: ^0.0.16 copied to clipboard

The plug-in built to simplify internet requests, validate the internet and help the developer to make good use of the API's.

adaptable

Languages lastcommit Issues

The plug-in built to simplify internet requests.

Getting started #

Depend on it

Add this to your package's pubspec.yaml file:

  dependencies:
       pop_network: <latest-version>

Install it You can install packages from the command line:

with Flutter:

  $ flutter pub get

Usage #

It is possible to perform an initial configuration using the pop_network.config function. This function should be used when starting to build your application with some custom settings.

void main() {
  await pop_network.config(baseUrl: "https:www.example.com");
  runApp(const MyApp());
}

Where you can add a base url or just not configure and pass the url in Enpoint. For more information visit the Contribution Guide

final endpoint = Endpoint(
  suffixPath: 'https:www.example.com'
);

The suffixPath can be used this way or being concatenated with a base url that is configured in the execution of the application, it doesn't have to be at the beginning but it is good to avoid errors.

void main() {
  await PopNetwork.config(baseUrl: "https:www.example.com");
  runApp(const MyApp());
}

final endpoint = Endpoint(
  suffixPath: 'suffix/path'
);

result path: https:www.example.com/suffix/path

Some other base settings can be done like setting intectors, setting default header, etc. More details in pop_network config Guide


When the split settings are completed, just call the api:

final result = await ApiManager.request();

or


final endpoint = Endpoint(
  suffixPath: 'suffix/path'
);

final result = await ApiManager.requestApi(
  endpoint: endpoint,
);

It is possible to check if your device is connected to the internet using ConnectionChecker;

final conection = await ConnectionChecker.isConnectedToInternet();

I see the gif of the operation below:

ConnectionChecker

If you want to see a usage in a simple way, go to /example folder.

It is also possible to make the request directly to the mock file that is being mapped to the functionality with ApiManager.requestMock. For more information, go to the documentation of the Mock.

Documentation #

Additional information #

For contributes:

  • Fork this repository;
  • Create a new branch to develop your feature: git checkout -b my-feature;
  • Commit your changes: git commit -m 'feat: my new feature';
  • Push to your branch: git push origin my-feature.
  • Open a pull request for your code to be evaluated.
  • For more information visit the Contribution Guide

To help maintain the chosen pattern we also create a file which is called before every commit. This file will format and pinpoint (if present) errors in the codestyle of your code. To enable this you must first copy it to git's hooks folder. If you are developing on macOS, go to the root of the project and run the command below:

cp pre-commit .git/hooks/pre-commit

After this step, it is necessary to give permission for the file to be executed. Just follow the following command:

chmod +x .git/hooks/pre-commit
4
likes
0
pub points
50%
popularity

Publisher

verified publisherpopcode.com.br

The plug-in built to simplify internet requests, validate the internet and help the developer to make good use of the API's.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

dio, flutter

More

Packages that depend on pop_network