one_request 1.0.1 copy "one_request: ^1.0.1" to clipboard
one_request: ^1.0.1 copied to clipboard

Handle http request, error and loading at a time. Very simple to use and easy to understand.

one_request #

A simple all in one web request package. #

Features #

Package used dio ,flutter_easyloading, either_dart. Thanks All of them.

Usage #

Include short and useful examples for package users. Navigate to /test folder for example.

Add oneRequest.loadingconfig under main() and async it.

void main() async {
  // Add Here
  oneRequest.loadingconfig();
  runApp(const MyApp());
}

Add oneRequest.initLoading under runapp() inside Materialapp

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      // Add as Builder
      builder: oneRequest.initLoading,
      title: 'Flutter Demo one_request',
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }

Call api example:

// Create an instance
  final request = oneRequest();
  // store the respone 
  var value = await request.send(
      // Url requared
      url: 'https://google.com',
      // Method ('GET','POST','PUT','DELETE',)           
      method: RequestType.GET, 
      // Header data Map<String,dynamic> (Optional)                      
      header: {'test': 'test'},   
      // Body data Map<String,dynamic> (Optional)          
      body: {'test': 'test'},    
      // Boolean value , true is FormData, Default is false (Optional)           
      formData: false, 
      //MaxRedirect count, Default is 1 (Optional)
      maxRedirects: 1, 
      // Request Timeout, Default is 60 Second (Optional)                     
      timeout: 60,  
      //  ContentType, Default is 'application/json' (Optional)                       
      contentType:  ContentType.json,
      // ['stream','json','plain','bytes'], Default is 'json' (Optional)    
      responsetype: ResponseType.json, 
      // If responce type is {'status':success,'message': 'text','data':[]} or indner  content containing all response in 'data' key the make it true,initialy false
      innderData : false,

    );

Additional information #

loading Config can be modified #

  // Custom loading Configuration
  oneRequest.loadingconfig(
    // BackgroundColor of loading
    backgroundColor: Colors.amber,   
    // Loading indicator Widget                   
    indicator: const CircularProgressIndicator(), 
    //  Loading Indicator Colour      
    indicatorColor: Colors.red,  
    // Progress Indicator Colour                       
    progressColor: Colors.red,  
    // Text Color                        
    textColor: Colors.red,  
    // Success Widget                            
    success : const Icon(                              
        Icons.check,
        color: Colors.green,
      ),
      // Error Widget
      error : const Icon(                              
        Icons.error,
        color: Colors.red,
      ),
      // Info Widget
      info : const Icon(                               
        Icons.info,
        color: Colors.blue,
      ),
  );

loading Widget Only can be modified to use on multi purpose outside one_request #

// only loading indictor Customize
  oneRequest.loadingconfig(
    // Widget
    indicator: const CircularProgressIndicator(),    
    // Text   
    status: 'loading',                                  
  );

dismiss loading #

// dissmiss loading
oneRequest.dismissLoading;
6
likes
130
pub points
0%
popularity

Publisher

unverified uploader

Handle http request, error and loading at a time. Very simple to use and easy to understand.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

GPL-3.0 (LICENSE)

Dependencies

dio, either_dart, flutter, flutter_easyloading

More

Packages that depend on one_request