- In older versions, you may have imported a single file containing
Paginator
orAsyncPaginator
. Now, these classes might be organized differently, possibly split across multiple files or using new package imports. - If you see errors referencing
IPaginator
orBasePaginator
, ensure you’ve updated import paths to point to the new, refactored code.
- Version 4 introduces a
BasePaginator<T>
class that centralizes shared logic. If you subclassed an oldPaginator
directly, you’ll now likely extendBasePaginator<T>
orPaginator<T>
instead. - If you relied on custom page-change logic, override
onPageChanged
in your subclass. This replaces older patterns where you might have had your own “goToPage” hooking mechanism.
- In prior versions, transformations like
filter()
orsorted()
might have returned raw lists or used a different caching approach. Now, we store and retrieve fully instantiatedPaginator<T>
objects in an internal_transformCache
with time-based expiration. - If your code was accessing transform results directly, you’ll need to rely on the newly returned
Paginator<T>
from methods likewhere(...)
orsort(...)
.
- If you want to avoid overlapping fetch requests, ensure
autoCancelFetches
is set totrue
in yourPaginationConfig
. If you’re upgrading and want to preserve old behavior (which might allow multiple fetches at once), you can set it tofalse
.
- The
InfinitePaginator
now supports both page-based and cursor-based patterns through factory constructors. If you previously used separate classes for these patterns, you might need to switch toInfinitePaginator.pageBased()
orInfinitePaginator.cursorBased()
. - Check your existing code for any references to legacy infinite scroll classes or direct calls that now require passing
a
paginationKey
. Adapt them to match the new factory constructor signature.
- If you want to track usage metrics, add the
PaginationAnalytics
mixin to your custom paginator class. This is optional but can be handy if you want to log the number of page loads, errors, etc.
- Lastly, confirm your existing tests still pass or update them to reflect any structural changes in version 4 (like new method names, new overrides, or changed class hierarchies).
-
String Extensions:
- Removed deprecated
toDateTime
method - Use
toDateFormatted
ortoDate
instead
- Removed deprecated
-
DateTime Extensions:
- Removed deprecated
format
method - Use
formatted
instead - Added stricter type checking for date operations
- Removed deprecated
-
try/toDateWithFormat
renamed totry/toDateFormatted
:- Action: Update all instances of
try/toDateWithFormat
in your code totry/toDateFormatted
.
- Action: Update all instances of
-
dateFormat
on String is now a method with an optionallocale
parameter: This change gives you more control over the formatting process, allowing you to specify the locale explicitly for accurate results.- Old Usage:
String formattedDate = '2024-06-10'.dateFormat; // Used default or current locale
- New Usage:
String formattedDate = '2024-06-10'.dateFormat(); // Uses default locale String formattedDateUS = '2024-06-10'.dateFormat('en_US'); // Explicitly uses US locale
- Old Usage:
These methods now have an optional startOfWeek
parameter to customize the first day of the week. The default value is
DateTime.monday
.
Old Usage:
DateTime now = DateTime.now();
DateTime firstDayOfWeek = now.firstDayOfWeek;
DateTime lastDayOfWeek = now.lastDayOfWeek;
New Usage:
DateTime now = DateTime.now();
DateTime firstDayOfWeek = now.firstDayOfWeek(); // Defaults to Monday
DateTime lastDayOfWeek = now.lastDayOfWeek(); // Defaults to Monday
// Customize start of week (e.g., Sunday)
DateTime firstDayOfWeekSunday = now.firstDayOfWeek(startOfWeek: DateTime.sunday);
flatJson
renamed toflatMap
: If you were using theflatJson
method onMap<String, dynamic>
, update your code to useflatMap
instead. The functionality has been enhanced to handle arrays, circular references, and provide an option to exclude arrays.makeEncodable
andsafelyEncodedJson
renamed: ThemakeEncodable
andsafelyEncodedJson
methods onMap<K, V>
have been renamed toencodableCopy
andencodedJsonString
, respectively. Additionally, an issue where sets were not correctly converted to JSON-encodable lists has been fixed.
Review the changelog for any other minor breaking changes and update your code accordingly.
If you encounter any issues during the migration process please fill an issue here.