ids_material_sdk 3.7.0 copy "ids_material_sdk: ^3.7.0" to clipboard
ids_material_sdk: ^3.7.0 copied to clipboard

IDS Material SDK for Flutter offers fast networking, cache optimisation, custom widgets like Multi-Select DropDown, theming tools, and performance boosts to reduce server costs.

3.6.1 - 2025-02-15 #

  • IDSApiManager().postFormDataInBg in this function method type added as IDSMethodType.post use the below code snippet
IDSMethodType method;
void validateRequest() {
  var request4 = {"UserName": "ddd", "Password": "ddd"};
  final Future<Map<String, dynamic>> apiResponse5 = IDSApiManager()
          .postFormDataInBg("http://ids.com/api/v1/login", request4,
          {"Connection": "keep-alive"}, IDSMethodType.post);
  apiResponse5.then((response) => {IDSHelper.debugJSON(response)});
}
  • Here’s an example demonstrating how to use the sendFormRequest method for different HTTP methods:

 class ApiService {
  final IDSApiManager _apiManager = IDSApiManager(); // Replace with actual API manager instance

  /// Logs in the user with a username and password.
  Future<dynamic> loginUser() async {
    return await _apiManager.sendFormRequest(
      endPoint: "https://api.example.com/login",
      param: {
        "username": "test_user",
        "password": "secure_password"
      },
      headers: {
        "Content-Type": "application/x-www-form-urlencoded",
        "Authorization": "Bearer your_token"
      },
      method: IDSMethodType.post,
    );
  }

  /// Fetches a list of users with pagination.
  Future<dynamic> getUsers() async {
    return await _apiManager.sendFormRequest(
      endPoint: "https://api.example.com/users",
      param: {
        "page": "1",
        "limit": "10"
      },
      headers: {
        "Authorization": "Bearer your_token"
      },
      method: IDSMethodType.get,
    );
  }

  /// Updates a user's details.
  Future<dynamic> updateUser() async {
    return await _apiManager.sendFormRequest(
      endPoint: "https://api.example.com/user/123",
      param: {
        "name": "Updated Name",
        "email": "updated_email@example.com"
      },
      headers: {
        "Authorization": "Bearer your_token"
      },
      method: IDSMethodType.put,
    );
  }

  /// Deletes a user by ID.
  Future<dynamic> deleteUser() async {
    return await _apiManager.sendFormRequest(
      endPoint: "https://api.example.com/user/123",
      param: {}, // DELETE requests usually don't need a body
      headers: {
        "Authorization": "Bearer your_token"
      },
      method: IDSMethodType.delete,
    );
  }
}

void main() async {
  final apiService = ApiService();

  print("Logging in...");
  final loginResponse = await apiService.loginUser();
  print("Login Response: $loginResponse\n");

  print("Fetching Users...");
  final usersResponse = await apiService.getUsers();
  print("Users Response: $usersResponse\n");

  print("Updating User...");
  final updateResponse = await apiService.updateUser();
  print("Update Response: $updateResponse\n");

  print("Deleting User...");
  final deleteResponse = await apiService.deleteUser();
  print("Delete Response: $deleteResponse\n");
}
  • Example of IDSResponseHandler
 void exampleOfResponseHandler() async {
  dynamic response = await IDSApiManager().sendFormRequest(
    endPoint: "https://api.example.com/user",
    param: {},
    headers: {},
    method: IDSMethodType.get,
  );

  if (IDSResponseHandler.isJsonObject(response)) {
    Map<String, dynamic> userData = IDSResponseHandler.asJsonObject(response);
    print("User ID: ${userData['id']}");
  }

  if (IDSResponseHandler.isJsonArray(response)) {
    List<dynamic> products = IDSResponseHandler.asJsonArray(response);
    print("First product: ${products[0]}");
  }

  if (IDSResponseHandler.asString(response)) {
    String statusMessage = IDSResponseHandler.asString(response);
    print("First product: $statusMessage");
  }
}

  • sendRequest

Benchmark API for IDSApiManager().sendRequest Method #

This API is designed to test the sendRequest function, which supports GET, POST, PUT, PATCH, DELETE HTTP methods with JSON payloads.

🏠 Base URL #


πŸ“Œ 1. GET Request - Fetch Data #

Endpoint: #

Query Parameters: #

Parameter Type Required Description
page int ❌ Page number (default: 1)
limit int ❌ Number of records per page (default: 10)

Example Usage in IDSApiManager().sendRequest: #

 void getExample() async {
  final response = await IDSApiManager().sendRequest(
    endPoint: "https://benchmarkapi.example.com/users",
    param: { "page": 1, "limit": 10 },
    headers: { "Authorization": "Bearer your_token" },
    method: IDSMethodType.get,
  );

  print(response);
}
{
  "status": 200,
  "data": [
    { "id": 1, "name": "Alice Doe", "email": "alice@example.com" },
    { "id": 2, "name": "Bob Smith", "email": "bob@example.com" }
  ]
}
  • πŸ“Œ 2. POST Request - Create User
  • Endpoint: POST /users
  • Request Body:
{
  "name": "John Doe",
  "email": "john.doe@example.com"
}

Example Usage in IDSApiManager().sendRequest: #

void postExample() async {
  final response = await IDSApiManager().sendRequest(
    endPoint: "https://benchmarkapi.example.com/users",
    param: { "name": "John Doe", "email": "john.doe@example.com" },
    headers: {
      "Content-Type": "application/json",
      "Authorization": "Bearer your_token"
    },
    method: IDSMethodType.post,
  );

  print(response);
}
{
  "status": 201,
  "message": "User created successfully",
  "user": {
    "id": 123,
    "name": "John Doe",
    "email": "john.doe@example.com"
  }
}

  • πŸ“Œ 3. PUT Request - Update User
  • Endpoint: PUT /users/{id}

Example Usage in IDSApiManager().sendRequest #

void putExample()  async {
  final response = await IDSApiManager().sendRequest(
    endPoint: "https://benchmarkapi.example.com/users/123",
    param: { "name": "John Updated", "email": "john.updated@example.com" },
    headers: { "Authorization": "Bearer your_token" },
    method: IDSMethodType.put,
  );

  print(response);
}
{
  "status": 200,
  "message": "User updated successfully"
}

  • πŸ“Œ 4. PATCH Request - Partial Update
  • Endpoint: PATCH /users/{id}

Example Usage in IDSApiManager().sendRequest: #

void patchExample() async {
  final response = await IDSApiManager().sendRequest(
    endPoint: "https://benchmarkapi.example.com/users/123",
    param: { "email": "new.email@example.com" },
    headers: { "Authorization": "Bearer your_token" },
    method: IDSMethodType.patch,
  );

  print(response);
}
{
  "status": 200,
  "message": "User email updated successfully"
}

  • πŸ“Œ 5. DELETE Request - Remove User
  • Endpoint: DELETE /users/{id}

Example Usage in IDSApiManager().sendRequest: #

void deleteExample() async {
  final response = await IDSApiManager().sendRequest(
    endPoint: "https://benchmarkapi.example.com/users/123",
    param: {}, // DELETE usually doesn't require a body
    headers: { "Authorization": "Bearer your_token" },
    method: IDSMethodType.delete,
  );

  print(response);

}
{
  "status": 200,
  "message": "User deleted successfully"
}

πŸ“Œ 6. Benchmarking Performance #

Load Testing with _sendRequest #

  • Measure response time using DateTime.now().
  • Test with JMeter, k6, or Locust.
  • Use a loop to send multiple concurrent requests.

Example Dart Code for Benchmarking #

  void benchmarkAPI() async {
  final stopwatch = Stopwatch()..start();

  for (int i = 0; i < 10; i++) {
    await sendRequest(
      endPoint: "https://benchmarkapi.example.com/users",
      param: {},
      headers: { "Authorization": "Bearer your_token" },
      method: IDSMethodType.get,
    );
  }

  stopwatch.stop();
  print("Total execution time: ${stopwatch.elapsedMilliseconds} ms");
}

benchmarkAPI();

3.6.0 - 2025-02-12 #

  • Bug fixing and code optimisation
import 'package:ids_material_sdk/public/index.dart';

void loaderExample() async {
  IDSLoader(context).showLoader();
  try {
    await Future.delayed(Duration(seconds: 3)); // Simulate a network call
  } finally {
    IDSLoader(context).hideLoader();
  }
}

3.5.1 - 2025-02-11 #

  • Public access added

3.5.0 - 2025-02-11 #

Added #

  • uploadMultiPartFormData: This function allows uploading multiple files of any type (e.g., images, PDFs, videos, audio, documents) in a single request using multipart form data.
  • IDSDownloadManager: Introduced a new feature to efficiently manage file downloads, providing support for pause, resume, and retry capabilities with enhanced error handling.
  • IDSChipsRadioGroup: Introduced a new feature to efficiently manage option selections using chip-styled radio buttons. Provides support for dynamic option updates, state synchronization, and enhanced UI customization with properties like background color, text color, and border.
  • IDSInternetChecker – Reliable Internet Monitoring Utility
  • On-Demand Connectivity Check:
    • Use isConnected() to verify the current internet connection whenever required, such as before making API calls.
  • Real-Time Connectivity Notifications:
    • The onConnectionChange stream allows the app to react to connectivity changes immediately. For example:
      • Display a banner when the internet is lost.
      • Automatically retry failed requests when the connection is restored.
  • Cross-Platform Support: Works seamlessly across Android, iOS, Web, and Desktop platforms.

Improved #

  • Enhanced file handling capabilities to support a wider range of file formats.
  • Optimized network requests for better performance with large file uploads.

Fixed #

  • Resolved minor bugs related to file upload error handling and response parsing.

Example of uploadMultiPartFormData #

  void uploadFileWithData() async {

    final response = await uploadMultiPartFormData(
      endPoint: "https://example.com/upload",
      payloadParams: {
        'userId': '12345',
        'description': 'Uploading multiple files',
      },
      fileUploads: {
        'profileImage': ['path/to/profile_image.jpg'],
        'document': ['path/to/document.pdf'],
        'audioClip': ['path/to/audio.mp3'],
        'files':['path/to/audio.mp3', 'path/to/video.mpv4', 'path/to/images.jpg']
      },
      headers: {
        'Authorization': 'Bearer your_token_here',
        'Content-Type': 'multipart/form-data',
      },
      method: IDSMethodType.POST,
    );
  
    if (response['success']) {
      print('Files uploaded successfully!');
    } else {
      print('Upload failed: ${response['error']}');
    }
}

Example of IDSDownloadManager download files #

  /// Example usage demonstrating how to use the [IDSDownloadManager] to download files
  /// import this line  import 'package:ids_material_sdk/downloads/index.dart';
  void exampleUsage(String fileUrl) {
    IDSDownloadManager.instance.download(
      url: fileUrl,
      success: (fileBytes) async {
        // Handle successful download, e.g., display the file
        //print('Download successful. File size: ${fileBytes.lengthInBytes} bytes');
        /* /// path_provider add this in your pub file if not exist
        final fileName = fileUrl.split('/').last;
        final tempDir = await getTemporaryDirectory();
        final file = File('${tempDir.path}/$fileName');
        await file.writeAsBytes(fileBytes.lengthInBytes as List<int>);*/
      },
      failure: (error) {
        // Handle download error
        //print('Download failed with error: $error');
      },
    );
  }

Example of IDSChipsRadioGroup #

 
    String _selectedValue = "";
    /// Use this function to create the widget
    Widget buildRadioGroup() {
      return IDSChipsRadioGroup(
        options: ["Yes", "No"],
        selectedOption: _selectedValue,
        onChanged: (value) {
          setState(() {
            _selectedValue = value;
          });
        },
        chipsHeight: 40,
        chipsSelectedBgColor: Colors.indigoAccent,
      );
    }

How They Work Together #

Both IDSChipsRadioGroup and IDSInternetChecker enhance the overall user experience:

  • IDSChipsRadioGroup improves the visual interaction for option selection, offering a modern and responsive design.
  • IDSInternetChecker ensures the app can dynamically respond to internet connectivity, providing seamless offline and online transitions. These utilities help create robust, user-friendly apps that are both visually appealing and functionally reliable.
  /// Internet connection example
  Future<void> checkConnection() async {
    // 1. Check the current internet connection status
    bool isConnected = await IDSInternetChecker.isConnected();

    // 2. Listen for changes in internet connectivity status
    IDSInternetChecker.onConnectionChange.listen((isConnected) {
      if (isConnected) {
        // 3. Handle internet reconnection
        if (kDebugMode) {
          print("Internet reconnected");
        }
      } else {
        // 4. Handle internet disconnection
        if (kDebugMode) {
          print("Internet connection lost");
        }
      }
    });
  }

3.4.0 #

  • IDSExpandableCard components created

  • uploadMultiPartFormData api error handling did that

  • Code snippet added in the example file function name = uploadFormData

3.3.0 #

  • uploadMultiPartFormData api create to upload the multiple or single file in the form
  • Code clean up and formation
  • SDK API name uploadMultiPartFormData

3.2.0 #

  • index.dart file added to avoid multiple file import
  • IDSTextArea UI issues fixes
  • Multidrop down code format issue fixed

3.1.0 #

  • ids_multiselect_drop_down.dart code formatting issue fixed
  • SearchArrayDialog created code snippet available in example code.

3.0.1 #

  • Bug fixes of the bottom nav bar. below configuration property added in the bottom nav bar
  • this.enableTopShadow = true,
    
  • this.blurRadius = 2.0,
    
  • this.spreadRadius = 0.2,
    
  • this.offset = -2,
    
  • this.shadowColor = Colors.black12,
    

3.0.0 #

  • IDSBottomNavigationAppBar widget created
  • IDSBottomNavigationAppBar this widget is fully customizable as per the user case of the app
  • Code snippet https://github.com/vinod1988/ids_bottom_nav_bar_example
  • IDSTextAreaTitle formatting issue fixed
  • IDSTextArea formatting issue fixed

2.8.8 #

  • IDSTextAreaTitle widget added in the material sdk
  • IDSTextArea widget added in the material sdk

2.8.7 #

  • IDSDropdownTitle widget added in the material sdk

2.8.6 #

  • IDSFieldTitle widget added in the material sdk
  • code formatted as per dart formatter
  • code clean up and widget optimization

2.8.5 #

  • postFormDataInBg 500 error handle and send back in response
  • IDSNumberTextField created to user only number fields in the form
  • IDSUITextField keyboard type parameter added in the constructor

2.8.4 #

  • postFormDataInBg return type changed to Map<String, dynamic>

2.8.3 #

  • UIPasswordField parameter issue fixed. below lib version upgraded
  • xml: ^6.5.0
  • logger: ^2.5.0
  • states_rebuilder: ^6.4.0 _

2.8.2 #

  • Example code added
  • 500 server error print in the log, for debugging purpose only
  • Readme file updated
  • UIPasswordField suffix icon added for password show and hide functionality

2.8.1 #

  • Error Handling: Implement robust error handling mechanisms for all Payment Authorization Interface (PAI) processes to gracefully handle 500 errors.
  • Documentation Update: Update the existing documentation to reflect the latest implementation changes and best practices.
  • Code Optimization: Review and optimize the codebase for performance and efficiency.
  • Security Enhancement: Conduct a thorough security audit and implement necessary measures to strengthen the system's security posture.

2.8.0 #

  • postFormDataInBgArray [when api return the array response]

2.7.0 #

  • Document updated

2.6.0 #

  • PasswordField
  • Documentations

2.5.0 #

  • UITextField
  • Networking services enhancements

2.4.0 #

  • APi logic separated

2.3.0 #

  • Form data request api implemented

2.2.1 #

  • API bug fixing

2.2.0 #

  • Networking api added
  • Custom Button Style
  • Constants
  • Networking logger

2.1.0 #

  • Optimization

2.0.1 #

  • SKD upgraded to support 3.3

2.0.0 #

  • New html widget added

1.0.2 #

  • drop down key name changed

1.0.1 #

  • Drop down html content issue fixed

1.0.0 #

  • Version 1.0 released

0.0.3 #

  • TODO: Describe initial release.

0.0.2 #

  • TODO: Describe initial release.

0.0.1 #

  • TODO: Describe initial release.
26
likes
0
points
240
downloads

Publisher

verified publisherivandigitalsolutions.com

Weekly Downloads

IDS Material SDK for Flutter offers fast networking, cache optimisation, custom widgets like Multi-Select DropDown, theming tools, and performance boosts to reduce server costs.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

connectivity_plus, flutter, flutter_html, html_unescape, http, internet_connection_checker, logger, states_rebuilder, xml

More

Packages that depend on ids_material_sdk