Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 23, 2025

Flutter web compilation failed because int64MaxValue (2^63-1) from dart_numerics exceeds JavaScript's MAX_SAFE_INTEGER (2^53-1). JavaScript uses double-precision floats for all numbers, causing compilation errors when integer literals exceed the safe range.

Changes

  • read_operations.dart: Replace int64MaxValue with _maxSafeInteger = 9007199254740991 constant in stream limiting logic
  • nitrite_id_test.dart: Replace int64MaxValue/int64MinValue with web-safe literal strings in boundary test
  • Remove unused dart_numerics imports from both files
// Before
rawStream = rawStream.take(findPlan.limit ?? int64MaxValue);

// After  
const int _maxSafeInteger = 9007199254740991; // JavaScript MAX_SAFE_INTEGER
rawStream = rawStream.take(findPlan.limit ?? _maxSafeInteger);

The constant serves as a "take all" sentinel value when no explicit limit is set, so the reduced range (2^53-1 vs 2^63-1) has no practical impact on functionality.

Original prompt

This section details on the original issue you should resolve

<issue_title>Failed to compile for flutter web. int64MaxValue</issue_title>
<issue_description>Failed to compile for flutter web.

Error: The integer literal ... can't be represented exactly in JavaScript.
Try changing the literal to something that can be represented in JavaScript. In JavaScript .... is the closest value that can be represented exactly.
const int int64MaxValue = ...;</issue_description>

Comments on the Issue (you are @copilot in this section)

@anidotnet Could you please provide more context? A reproducible code may be? @anidotnet I have never tested it on web, I'll take a look and let you know.

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@coderabbitai
Copy link

coderabbitai bot commented Nov 23, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


Comment @coderabbitai help to get the list of available commands and usage tips.

Co-authored-by: anidotnet <696662+anidotnet@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix compilation error for int64MaxValue in Flutter web Fix Flutter web compilation: replace int64MaxValue with JavaScript-safe integer constant Nov 23, 2025
Copilot AI requested a review from anidotnet November 23, 2025 18:16
Copilot finished work on behalf of anidotnet November 23, 2025 18:16
@anidotnet anidotnet marked this pull request as ready for review November 23, 2025 20:05
Copilot AI review requested due to automatic review settings November 23, 2025 20:05
Copilot finished reviewing on behalf of anidotnet November 23, 2025 20:06
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes Flutter web compilation issues caused by integer literals exceeding JavaScript's MAX_SAFE_INTEGER. The changes replace usage of int64MaxValue (2^63-1) from the dart_numerics package with JavaScript-safe integer values (2^53-1), enabling the package to compile successfully for Flutter web targets.

Key changes:

  • Introduced a _maxSafeInteger constant for stream limiting operations
  • Updated boundary tests to use web-safe literal strings instead of dart_numerics constants
  • Removed unused dart_numerics imports from affected files

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/nitrite/lib/src/collection/operations/read_operations.dart Added _maxSafeInteger constant (2^53-1) to replace int64MaxValue in stream take operation
packages/nitrite/test/collection/nitrite_id_test.dart Updated boundary test to use JavaScript-safe integer literals as strings
Comments suppressed due to low confidence (1)

packages/nitrite/lib/src/collection/operations/read_operations.dart:1

  • The compareTo method in NitriteId (line 64 of nitrite_id.dart) uses int.parse() which may cause issues on Flutter web when comparing IDs with values exceeding JavaScript's MAX_SAFE_INTEGER (2^53-1). While the test now uses web-safe values, any production IDs created from int64 values could still fail comparison operations on web. Consider using BigInt for parsing and comparison, or explicitly document that IDs must not exceed MAX_SAFE_INTEGER on web platforms.
import 'package:nitrite/nitrite.dart';

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failed to compile for flutter web. int64MaxValue

2 participants