Skip to content

Add Aggregate Query Support to Parse Flutter SDK #1041

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/dart/example/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,18 @@ Future<void> main() async {
..set('Name', 'Ketogenic')
..set('Fat', 65);



var response = await dietPlan.save();

if (response.success) {
dietPlan = response.results?.first;
print("Response received successfully");
}

final res = await ParseAggregate('DietPlan', pipeline: {
r'$match': {'Name': 'Ketogenic'}
}).execute();

print(res);
Comment on lines +26 to +30
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Enhance the ParseAggregate example with error handling and documentation

The example demonstrates the new aggregation query feature, but could be improved with error handling and better documentation.

Consider adding error handling and more descriptive output:

-  final res = await ParseAggregate('DietPlan', pipeline: {
-    r'$match': {'Name': 'Ketogenic'}
-  }).execute();
-
-  print(res);
+  // Execute an aggregate query to filter DietPlan objects
+  final aggregateResult = await ParseAggregate('DietPlan', pipeline: {
+    r'$match': {'Name': 'Ketogenic'}
+  }).execute();
+
+  if (aggregateResult.success) {
+    print("Aggregate query results:");
+    print(aggregateResult.results);
+  } else {
+    print("Aggregate query failed: ${aggregateResult.error?.message}");
+  }
🤖 Prompt for AI Agents (early access)
In packages/dart/example/main.dart around lines 26 to 30, the ParseAggregate example lacks error handling and sufficient documentation. Add try-catch blocks around the await call to handle potential exceptions gracefully. Include comments explaining the purpose of the aggregation query and the expected output. Also, enhance the print statement to provide more descriptive output for easier understanding of the results.

}
55 changes: 2 additions & 53 deletions packages/dart/lib/parse_server_sdk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:cross_file/cross_file.dart';
import 'package:dio/dio.dart';
import 'package:meta/meta.dart';
import 'package:mime/mime.dart';
import 'package:parse_server_sdk/src/utils/url_replace.dart';
import 'package:path/path.dart' as path;
import 'package:sembast/sembast.dart';
import 'package:sembast/sembast_io.dart';
Expand All @@ -29,111 +30,59 @@ export 'src/network/parse_dio_client.dart';
export 'src/network/parse_http_client.dart';

part 'src/base/parse_constants.dart';

part 'src/data/parse_core_data.dart';

part 'src/data/parse_subclass_handler.dart';

part 'src/enums/parse_enum_api_rq.dart';

part 'src/network/options.dart';

part 'src/network/parse_aggregate.dart';
part 'src/network/parse_client.dart';

part 'src/network/parse_connectivity.dart';

part 'src/network/parse_live_query.dart';

part 'src/network/parse_query.dart';

part 'src/objects/parse_acl.dart';

part 'src/objects/parse_array.dart';

part 'src/objects/parse_base.dart';

part 'src/objects/parse_cloneable.dart';

part 'src/objects/parse_config.dart';

part 'src/objects/parse_error.dart';

part 'src/objects/parse_exception.dart';

part 'src/objects/parse_file.dart';

part 'src/objects/parse_file_base.dart';

part 'src/objects/parse_file_web.dart';

part 'src/objects/parse_function.dart';

part 'src/objects/parse_geo_point.dart';

part 'src/objects/parse_installation.dart';

part 'src/objects/parse_number.dart';

part 'src/objects/parse_object.dart';

part 'src/objects/parse_operation/parse_add_operation.dart';

part 'src/objects/parse_operation/parse_add_relation_operation.dart';

part 'src/objects/parse_operation/parse_add_unique_operation.dart';

part 'src/objects/parse_operation/parse_increment_operation.dart';

part 'src/objects/parse_operation/parse_operation.dart';

part 'src/objects/parse_operation/parse_remove_operation.dart';

part 'src/objects/parse_operation/parse_remove_relation_operation.dart';

part 'src/objects/parse_relation.dart';

part 'src/objects/parse_response.dart';

part 'src/objects/parse_save_state_aware_child.dart';

part 'src/objects/parse_session.dart';

part 'src/objects/parse_user.dart';

part 'src/objects/parse_x_file.dart';

part 'src/objects/response/parse_error_response.dart';

part 'src/objects/response/parse_exception_response.dart';

part 'src/objects/response/parse_response_builder.dart';

part 'src/objects/response/parse_response_utils.dart';

part 'src/objects/response/parse_success_no_results.dart';

part 'src/storage/core_store.dart';

part 'src/storage/core_store_memory.dart';

part 'src/storage/core_store_sem_impl.dart';

part 'src/storage/xxtea_codec.dart';

part 'src/utils/parse_date_format.dart';

part 'src/utils/parse_decoder.dart';

part 'src/utils/parse_encoder.dart';

part 'src/utils/parse_live_list.dart';

part 'src/utils/parse_logger.dart';

part 'src/utils/parse_login_helpers.dart';

part 'src/utils/parse_utils.dart';

part 'src/utils/valuable.dart';

class Parse {
Expand Down
34 changes: 34 additions & 0 deletions packages/dart/lib/src/network/parse_aggregate.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
part of '../../parse_server_sdk.dart';

class ParseAggregate {
final String className;
Map<String, dynamic> pipeline;
final bool? debug;
final ParseClient? client;
final bool? autoSendSessionId;
final String? parseClassName;

ParseAggregate(this.className,{required this.pipeline,this.debug, this.client, this.autoSendSessionId, this.parseClassName});
Comment on lines +1 to +11
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add comprehensive documentation and improve code formatting.

The class lacks proper documentation explaining its purpose, parameters, and usage. Additionally, there are formatting issues.

Add proper documentation and fix formatting:

part of '../../parse_server_sdk.dart';

+/// A class that provides support for Parse Server aggregate queries.
+/// 
+/// Aggregate queries allow complex data aggregation operations like grouping,
+/// filtering, projecting, etc. using MongoDB's aggregation pipeline syntax.
+/// 
+/// Example usage:
+/// ```dart
+/// final aggregate = ParseAggregate('YourClassName', 
+///   pipeline: {'\$match': {'field': 'value'}});
+/// final response = await aggregate.execute();
+/// ```
class ParseAggregate {
  /// The Parse class name to perform aggregation on
  final String className;
  
  /// The aggregation pipeline defining the operations to perform
  /// Must be a valid MongoDB aggregation pipeline
  Map<String, dynamic> pipeline;
  
  /// Whether to enable debug logging
  final bool? debug;
  
  /// Custom Parse client instance
  final ParseClient? client;
  
  /// Whether to automatically send the session ID
  final bool? autoSendSessionId;
  
  /// Custom Parse class name for response handling
  final String? parseClassName;

-  ParseAggregate(this.className,{required this.pipeline,this.debug, this.client, this.autoSendSessionId, this.parseClassName});
+  /// Creates a new ParseAggregate instance.
+  /// 
+  /// [className] is the Parse class to query.
+  /// [pipeline] defines the aggregation operations to perform.
+  ParseAggregate(
+    this.className, {
+    required this.pipeline,
+    this.debug,
+    this.client,
+    this.autoSendSessionId,
+    this.parseClassName,
+  });
🤖 Prompt for AI Agents (early access)
In packages/dart/lib/src/network/parse_aggregate.dart lines 1 to 11, the ParseAggregate class lacks proper documentation and has formatting issues. Add DartDoc comments above the class and its fields explaining their purpose and usage, including an example of how to instantiate and use the class. Also, reformat the constructor parameters to be each on their own line with trailing commas for better readability.


Future<ParseResponse> execute() async {
Map<String,String> _pipeline={};
if(pipeline.isEmpty){
throw ArgumentError('pipeline must not be empty. Please add pipeline operations to aggregate data. Example: {"\$group": {"_id": "\$userId", "totalScore": {"\$sum": "\$score"}}} ');
}
else{
_pipeline.addAll({'pipeline':jsonEncode([pipeline])});
}
final debugBool = isDebugEnabled(objectLevelDebug: debug);
final result = await ParseObject(className)._client.get(
Uri.parse('${ParseCoreData().serverUrl}$keyEndPointAggregate$className').replace(queryParameters: _pipeline).toString(),
);
print('result >>> ${result.data}');
return handleResponse<ParseObject>(
ParseObject(className),
result,
ParseApiRQ.get,
debugBool,
parseClassName ?? 'ParseBase',
);
}
Comment on lines +13 to +33
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Remove debug print statement and improve pipeline parameter handling.

The execute() method contains a debug print statement and has some issues with variable naming and error handling.

Make the following improvements:

+  /// Executes the aggregate query and returns the response.
+  /// 
+  /// Throws an [ArgumentError] if the pipeline is empty.
+  /// Returns a [ParseResponse] containing the query results.
  Future<ParseResponse> execute() async {
-    Map<String,String> _pipeline={};
+    Map<String, String> queryParams = {};
    if(pipeline.isEmpty){
      throw ArgumentError('pipeline must not be empty. Please add pipeline operations to aggregate data.  Example: {"\$group": {"_id": "\$userId", "totalScore": {"\$sum": "\$score"}}}  ');
    }
    else{
-      _pipeline.addAll({'pipeline':jsonEncode([pipeline])});
+      queryParams.addAll({'pipeline': jsonEncode([pipeline])});
    }
    final debugBool = isDebugEnabled(objectLevelDebug: debug);
    final result = await ParseObject(className)._client.get(
-      Uri.parse('${ParseCoreData().serverUrl}$keyEndPointAggregate$className').replace(queryParameters: _pipeline).toString(),
+      Uri.parse('${ParseCoreData().serverUrl}$keyEndPointAggregate$className')
+          .replace(queryParameters: queryParams)
+          .toString(),
    );
-    print('result >>> ${result.data}');
+    // Use ParseCoreData().logger instead of print for debugging
+    if (debugBool) {
+      ParseCoreData().logger.info('Aggregate query result: ${result.data}');
+    }
    return handleResponse<ParseObject>(
      ParseObject(className),
      result,
      ParseApiRQ.get,
      debugBool,
      parseClassName ?? 'ParseBase',
    );
  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Future<ParseResponse> execute() async {
Map<String,String> _pipeline={};
if(pipeline.isEmpty){
throw ArgumentError('pipeline must not be empty. Please add pipeline operations to aggregate data. Example: {"\$group": {"_id": "\$userId", "totalScore": {"\$sum": "\$score"}}} ');
}
else{
_pipeline.addAll({'pipeline':jsonEncode([pipeline])});
}
final debugBool = isDebugEnabled(objectLevelDebug: debug);
final result = await ParseObject(className)._client.get(
Uri.parse('${ParseCoreData().serverUrl}$keyEndPointAggregate$className').replace(queryParameters: _pipeline).toString(),
);
print('result >>> ${result.data}');
return handleResponse<ParseObject>(
ParseObject(className),
result,
ParseApiRQ.get,
debugBool,
parseClassName ?? 'ParseBase',
);
}
/// Executes the aggregate query and returns the response.
///
/// Throws an [ArgumentError] if the pipeline is empty.
/// Returns a [ParseResponse] containing the query results.
Future<ParseResponse> execute() async {
Map<String, String> queryParams = {};
if (pipeline.isEmpty) {
throw ArgumentError(
'pipeline must not be empty. Please add pipeline operations to '
'aggregate data. Example: {"\$group": {"_id": "\$userId", '
'"totalScore": {"\$sum": "\$score"}}}',
);
} else {
queryParams.addAll({'pipeline': jsonEncode([pipeline])});
}
final debugBool = isDebugEnabled(objectLevelDebug: debug);
final result = await ParseObject(className)._client.get(
Uri.parse('${ParseCoreData().serverUrl}$keyEndPointAggregate$className')
.replace(queryParameters: queryParams)
.toString(),
);
// Use ParseCoreData().logger instead of print for debugging
if (debugBool) {
ParseCoreData().logger.info('Aggregate query result: ${result.data}');
}
return handleResponse<ParseObject>(
ParseObject(className),
result,
ParseApiRQ.get,
debugBool,
parseClassName ?? 'ParseBase',
);
}
🤖 Prompt for AI Agents (early access)
In packages/dart/lib/src/network/parse_aggregate.dart around lines 13 to 33, remove the debug print statement that outputs the result data. Rename the local variable _pipeline to a more descriptive name like queryParameters. Improve error handling by ensuring the pipeline parameter is properly validated and encoded before adding it to the query parameters. Make sure the pipeline is encoded as a JSON array and passed correctly in the request URI.

}
Comment on lines +1 to +34
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

❓ Verification inconclusive

Add test coverage for the new aggregate functionality.

The PR objectives mention that tests are planned but not yet implemented. Tests are essential for ensuring this new functionality works correctly.

Please ensure comprehensive test coverage is added for the ParseAggregate class, including tests for:

  1. Successful aggregation queries with various pipeline operations
  2. Error handling for empty pipelines
  3. Error handling for server-side errors
  4. Custom client and debug flag handling

🏁 Script executed:

#!/bin/bash
# Look for test files related to the aggregate functionality
fd -e dart "aggregate.*test" 

# Check coverage in existing test files for references to ParseAggregate
rg -l "ParseAggregate" --type dart packages/dart/test/

Length of output: 85


Add comprehensive test coverage for ParseAggregate

No existing tests for the new aggregate functionality were found. Please add tests in packages/dart/test/ covering:

  • Successful aggregation with various pipeline operations (e.g. $group, $match, $sort, etc.)
  • Error thrown when pipeline is empty
  • Handling of server-side errors (simulate non-200 responses)
  • Custom client injection and debug flag behavior

Ensure these tests exercise both positive and negative scenarios and validate that execute() builds the correct request URI, encodes the pipeline properly, and invokes handleResponse as expected.

🤖 Prompt for AI Agents (early access)
In packages/dart/lib/src/network/parse_aggregate.dart lines 1 to 34, there is no test coverage for the ParseAggregate class. Add comprehensive tests in packages/dart/test/ that cover successful aggregation queries with different pipeline operations like $group, $match, and $sort; verify that an ArgumentError is thrown when the pipeline is empty; simulate server-side errors to test error handling; and test the behavior when a custom client and debug flag are provided. Ensure tests validate the correct request URI construction, proper JSON encoding of the pipeline, and that handleResponse is called correctly.

4 changes: 2 additions & 2 deletions packages/dart/lib/src/network/parse_http_client.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import 'dart:convert';
import 'package:universal_io/io.dart';

import 'package:http/http.dart' as http;

import 'package:parse_server_sdk/parse_server_sdk.dart';
import 'package:universal_io/io.dart';

import 'http_client_io.dart' if (dart.library.js) 'http_client_js.dart';

Expand Down Expand Up @@ -31,6 +30,7 @@ class ParseHTTPClient extends ParseClient {
ParseNetworkOptions? options,
ProgressCallback? onReceiveProgress,
}) async {

final http.Response response = await _client.get(
Uri.parse(path),
headers: options?.headers,
Expand Down
24 changes: 24 additions & 0 deletions packages/dart/lib/src/utils/url_replace.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
class UrlReplace{
String? scheme;
String? userInfo;
String? host;
int? port;
String? path;
Iterable<String>? pathSegments;
String? query;
Map<String, dynamic>? queryParameters;
String? fragment;

UrlReplace({
this.scheme,
this.userInfo,
this.host,
this.port,
this.path,
this.pathSegments,
this.query,
this.queryParameters,
this.fragment,
});

}
Comment on lines +1 to +24
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add documentation and consider using Dart's Uri class instead.

This class lacks documentation explaining its purpose and usage. Additionally, it appears to duplicate functionality that's already available in Dart's Uri class.

  1. Add class-level and field-level documentation
  2. Add a space after the class name declaration: class UrlReplace {
  3. Consider whether this utility class is necessary or if Dart's Uri class could be used directly
-class UrlReplace{
+/// A container for URL components used for URL manipulation operations.
+/// This class provides a convenient way to store and pass URL components.
+class UrlReplace {
  /// The URL scheme (e.g., 'http', 'https')
  String? scheme;
  /// The user info portion of the URL
  String? userInfo;
  /// The host name
  String? host;
  /// The port number
  int? port;
  /// The path component of the URL
  String? path;
  /// The path segments as an iterable collection
  Iterable<String>? pathSegments;
  /// The query string
  String? query;
  /// The query parameters as a map
  Map<String, dynamic>? queryParameters;
  /// The fragment identifier
  String? fragment;

+  /// Creates a new UrlReplace instance with the specified URL components.
  UrlReplace({
    this.scheme,
    this.userInfo,
    this.host,
    this.port,
    this.path,
    this.pathSegments,
    this.query,
    this.queryParameters,
    this.fragment,
  });

}
🤖 Prompt for AI Agents (early access)
In packages/dart/lib/src/utils/url_replace.dart lines 1 to 24, add clear class-level documentation explaining the purpose of UrlReplace and field-level comments describing each property. Insert a space after the class name declaration to follow Dart style conventions (change `class UrlReplace{` to `class UrlReplace {`). Finally, review the code to determine if this class is redundant given Dart's built-in Uri class and consider refactoring to use Uri directly if possible.

8 changes: 4 additions & 4 deletions packages/dart/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies:
# Networking
dio: ^5.7.0
http: ^1.2.0
web_socket_channel: ^2.4.3
web_socket_channel: ^3.0.3
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Verify compatibility with web_socket_channel major version upgrade

The web_socket_channel dependency has been upgraded from ^2.4.3 to ^3.0.3, which is a major version bump that may include breaking changes.


🌐 Web query:

What are the breaking changes in web_socket_channel v3.0.0?

💡 Result:

Breaking Changes in web_socket_channel v3.0.0

The 3.0.0 release of the Dart web_socket_channel package introduced several breaking changes that impact how developers interact with the API. The main breaking changes are as follows:

  • Removal of WebSocketChannel Constructor
    The direct constructor for WebSocketChannel has been removed. Developers can no longer instantiate the channel using WebSocketChannel() and must now use provided factory methods, such as WebSocketChannel.connect, to create channel instances[1][6].

  • WebSocketChannel Is Now an Abstract Interface
    The WebSocketChannel class has been converted into an abstract interface. This means you cannot instantiate it directly and must instead work with implementations provided by the package, such as via WebSocketChannel.connect[1][6].

  • Change in Exception Thrown by IOWebSocketChannel.ready
    The ready property on IOWebSocketChannel previously threw a WebSocketException on error. In v3.0.0, this now throws a WebSocketChannelException, requiring consumers to update their exception handling logic when awaiting the connection's readiness[1][6].

  • Adapter Around package:web_socket for Web Implementation
    An adapter for the package:web_socket package is now the default implementation for web platform connections made via WebSocketChannel.connect. This may affect the underlying behavior or compatibility for web-based applications[1][6].

Summary Table

Breaking Change Details
Constructor removal No direct WebSocketChannel() instantiation; use factory constructors instead
Abstract interface WebSocketChannel is now abstract; use specific implementations
Exception change in ready Throws WebSocketChannelException (previously WebSocketException)
Default web adapter Uses package:web_socket adapter for web via WebSocketChannel.connect

Developers upgrading to v3.0.0 should adjust their code to accommodate these changes[1][6].

Citations:


Validate Breaking Changes for web_socket_channel v3.0.0

We’ve bumped web_socket_channel from ^2.4.3 to ^3.0.3, which includes these breaking changes:

  • Removal of the direct WebSocketChannel() constructor – you must now use WebSocketChannel.connect(...).
  • WebSocketChannel is now an abstract interface.
  • IOWebSocketChannel.ready throws WebSocketChannelException (instead of WebSocketException).
  • Default web implementation now uses the package:web_socket adapter.

Please audit the Dart code for:

  • Any instantiation of WebSocketChannel() (replace with connect).
  • Direct uses of IOWebSocketChannel and calls to its ready property (update exception handling).
  • Web‐platform socket code relying on the old adapter.

Make the necessary updates or confirm that your code paths already comply with the new API.

🤖 Prompt for AI Agents (early access)
In packages/dart/pubspec.yaml at line 27, the web_socket_channel dependency has been upgraded from ^2.4.3 to ^3.0.3, which introduces breaking changes. Audit all Dart code that uses web_socket_channel for direct instantiation of WebSocketChannel() and replace these with WebSocketChannel.connect(...) factory methods. Also, update any exception handling around IOWebSocketChannel.ready to catch WebSocketChannelException instead of WebSocketException. Verify web platform socket code to ensure compatibility with the new package:web_socket adapter. Make these code adjustments to align with the new major version API.


#Database
sembast: ^3.6.0
Expand All @@ -34,15 +34,15 @@ dependencies:
uuid: ^4.5.1
meta: ^1.16.0
path: ^1.9.0
mime: ^1.0.0
timezone: ^0.9.4
mime: ^2.0.0
timezone: ^0.10.1
universal_io: ^2.2.2
xxtea: ^2.1.0
collection: ^1.18.0
cross_file: ^0.3.3+8

dev_dependencies:
lints: ^4.0.0
lints: ^5.1.1

# Testing
build_runner: ^2.4.9
Expand Down
2 changes: 2 additions & 0 deletions packages/flutter/example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
*.swp
.DS_Store
.atom/
.build/
.buildlog/
.history
.svn/
.swiftpm/
migrate_working_dir/

# IntelliJ related
Expand Down
6 changes: 3 additions & 3 deletions packages/flutter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dependencies:
flutter:
sdk: flutter

parse_server_sdk: ^6.4.0
parse_server_sdk: ^8.0.0
# Uncomment for local testing
#parse_server_sdk:
# path: ../dart
Expand All @@ -40,14 +40,14 @@ dependencies:

# Utils
path_provider: ^2.1.4
package_info_plus: ^5.0.1
package_info_plus: ^8.3.0
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Check for potential issues with package_info_plus upgrade

The package_info_plus dependency has been upgraded from ^5.0.1 to ^8.3.0, which is a significant version jump. Verify that this update is compatible with your app's requirements.


🌐 Web query:

Are there any breaking changes between package_info_plus v5.0.1 and v8.3.0?

💡 Result:

Breaking Changes Between package_info_plus v5.0.1 and v8.3.0

Overview:
Yes, there are breaking changes between package_info_plus v5.0.1 and v8.3.0. The most notable comes in the major release jump to v7.0.0 and subsequent versions.


Major Breaking Change in v7.0.0:

  • The Android implementation for the buildSignature value switched from using its previous hashing method to SHA-256 for improved security.

    "BREAKING FEAT(package_info_plus): Switch to SHA-256 for buildSignature on Android (#2835)"[1].

v5.0.1 Breaking Changes:

  • v5.0.1 itself introduced breaking changes related to handling the versionJsonUrl on web, now allowing for no page extension:

    "BREAKING FIX(package_info_plus): Allow no page extension in versionJsonUrl on web (#2381)"[3].

  • This requires you to adjust your web setup if you had previously relied on an explicit .json extension in URLs.

Other Notable Upgrades Between v5.0.1 → v8.3.0:

  • There are other minor and patch releases with additional fixes, features, and internal improvements, but the main breaking change of note is the SHA-256 switch for Android.
  • There is no mention in the changelogs of breaking API changes to the core PackageInfo API (such as constructor signatures, returned fields, or general usage) for end-users between these versions[1][3][8]. Most common usage patterns (fetching version, build number, etc.) remain stable.

Upgrade Considerations:

  • Android: If your logic depends on the buildSignature value, expect it to be different due to SHA-256.
  • Web: Ensure your Flutter web deployment does not rely on the .json extension for versionJsonUrl; update your deployment/server settings if needed.
  • General: Always clean and rebuild Xcode projects when upgrading, particularly for iOS apps, as incorrect version info may be cached in the build folder[8].

Summary Table of Key Breaking Changes

Version Breaking Change Description
5.0.1 versionJsonUrl can omit .json extension on web[3]
7.0.0 buildSignature uses SHA-256 on Android[1]

If you rely on either buildSignature for Android or serve web builds with a specific versionJsonUrl file extension, carefully review your implementation when upgrading between these versions.


Further Recommendations:

  • Review the full changelog for package_info_plus for all detailed updates between your installed version and the latest[1].
  • Test each platform you support (Android, iOS, Web) after upgrading to catch any behavioral nuances, especially around version/build info retrieval and signature computation.

Citations:


Review Breaking Changes in package_info_plus Upgrade

The jump from ^5.0.1 to ^8.3.0 introduces a couple of breaking changes you should verify:

  • Android (v7.0.0): buildSignature now uses SHA-256 instead of the previous hashing method. If your app logic depends on this value, update or re-test accordingly.
  • Web (v5.0.1): versionJsonUrl no longer requires a .json extension. Ensure your server or deployment doesn’t rely on a fixed .json suffix.

All other core PackageInfo APIs (version, build number, etc.) remain unchanged. Please review your implementation, adjust any dependent logic, and test each platform (Android, iOS, Web) after upgrading.

🤖 Prompt for AI Agents (early access)
In packages/flutter/pubspec.yaml at line 43, the package_info_plus dependency was upgraded from ^5.0.1 to ^8.3.0, which includes breaking changes. Review your app code for any usage of buildSignature on Android and update or retest it due to the switch to SHA-256 hashing in v7.0.0. Also, verify your web deployment does not rely on a .json extension in versionJsonUrl, adjusting server or deployment settings if necessary. Finally, test all platforms thoroughly to ensure compatibility with the new package version.

path: ^1.8.3

dev_dependencies:
flutter_test:
sdk: flutter

flutter_lints: ^4.0.0
flutter_lints: ^5.0.0
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Updated linting rules

The flutter_lints dev dependency has been updated from ^4.0.0 to ^5.0.0. This may introduce new linting rules or deprecate existing ones.


🌐 Web query:

What are the changes in flutter_lints between version 4.0.0 and 5.0.0?

💡 Result:

Changes in flutter_lints Between Versions 4.0.0 and 5.0.0

Summary Table

Category 4.0.0 5.0.0
package:lints dependency 4.0.0 5.0.0
Minimum SDK Flutter 3.13 / Dart 3.1 Flutter 3.24 / Dart 3.5
Lints Added library_annotations
no_wildcard_variable_uses
invalid_runtime_check_with_js_interop_types
unnecessary_library_name
Lints Removed package_prefixed_library_names
library_names
avoid_null_checks_in_equality_operators
prefer_const_constructors
prefer_const_declarations
prefer_const_literals_to_create_immutables

Detailed Changes

Dependency and SDK Updates

  • The internal dependency was updated: package:lints upgraded from version 4.0.0 to 5.0.0.
  • Minimum required Flutter and Dart SDK versions increased to Flutter 3.24 and Dart 3.5[1][2][4].

New Lints Added

  • invalid_runtime_check_with_js_interop_types: Prevents incorrect runtime checks with interop types, improving JavaScript interoperability safety.
  • unnecessary_library_name: Discourages unnecessary library name declarations for cleaner code[1][4].

Lints Removed

  • avoid_null_checks_in_equality_operators: This removal gives developers more control over how null is handled in equality checks[1][4].
  • prefer_const_constructors
  • prefer_const_declarations
  • prefer_const_literals_to_create_immutables

These three "prefer_const_" lints were removed to simplify constant usage recommendations in Flutter projects, as they were sometimes seen as overly restrictive[1][4].

Removed in 4.0.0 (Still Absent in 5.0.0)

  • package_prefixed_library_names
  • library_names

These were already removed in the shift from 3.0.2 to 4.0.0[1].

Added in 4.0.0 (Still Present Unless Otherwise Stated)

  • library_annotations
  • no_wildcard_variable_uses

What This Means for Your Project

  • Upgrading to 5.0.0 may introduce new lint warnings related to JavaScript interop and unnecessary library name usage.
  • Code that previously failed the removed lints (prefer_const_* and avoid_null_checks_in_equality_operators) will no longer be flagged.
  • Projects must now use newer Flutter and Dart SDKs (at least Flutter 3.24 / Dart 3.5)[1][2][4].

Upgrading will keep your project aligned with the latest best practices and Dart ecosystem trends, and may lead to cleaner, more maintainable codebases[4].

Citations:


Update Dart/Flutter SDK Constraints & Address New Lint Rules

Please ensure the upgrade to flutter_lints: ^5.0.0 is fully supported:

• In packages/flutter/pubspec.yaml, bump your environment SDKs to meet the new minimums:

environment:
  sdk: ">=3.5.0 <4.0.0"
  flutter: ">=3.24.0"

• Run

flutter pub upgrade
flutter analyze

to surface the two new lints:

  • invalid_runtime_check_with_js_interop_types
  • unnecessary_library_name

• Review and adjust any code patterns that relied on lints now removed:

  • avoid_null_checks_in_equality_operators
  • prefer_const_constructors
  • prefer_const_declarations
  • prefer_const_literals_to_create_immutables
🤖 Prompt for AI Agents (early access)
In packages/flutter/pubspec.yaml at line 50, after updating flutter_lints to ^5.0.0, update the environment SDK constraints to sdk: ">=3.5.0 <4.0.0" and flutter: ">=3.24.0" to meet new minimum requirements. Then run flutter pub upgrade and flutter analyze to detect new lint warnings for invalid_runtime_check_with_js_interop_types and unnecessary_library_name. Finally, review and modify code to comply with these new lints and adjust any code relying on removed lints like avoid_null_checks_in_equality_operators and the prefer_const_* rules.

path_provider_platform_interface: ^2.1.2
plugin_platform_interface: ^2.1.8

Expand Down
Loading