Migration Guide: v1 to v2 🚀
Overview
Normie v2.0.0 represents a major architectural overhaul from v1.0.0. This guide will help you migrate your existing code to the new version with minimal friction.
Core Changes
1. Method Organization
// v1.0.0 ⬇️
Normie.hexToColor('#FF5733');
Normie.formatDate(date: '2024-03-15');
Normie.isValidEmail('test@example.com');
// v2.0.0 ⬇️
Normie.palette.hexToColor('#FF5733');
Normie.chrono.format(date: '2024-03-15');
Normie.check.isEmail('test@example.com');
2. Method Names
Some methods have been renamed for clarity and consistency:
// v1.0.0 ⬇️
Normie.isValidEmail()
Normie.getFileExtension()
Normie.getWeekDayDate()
// v2.0.0 ⬇️
Normie.check.isEmail()
Normie.files.getExtension()
Normie.chrono.getWeekDay()
Migration Table
Here's a complete mapping of old methods to their new locations:
Normie.reverse()
Normie.words.reverse()
Moved to Words category
Normie.formatDate()
Normie.chrono.format()
Moved to Chrono category
Normie.getWeekDayDate()
Normie.chrono.getWeekDay()
Renamed and moved
Normie.truncate()
Normie.words.truncate()
Moved to Words category
Normie.getStringInitial()
Normie.words.getStringInitial()
Moved to Words category
Normie.titleCase()
Normie.words.titleCase()
Moved to Words category
Normie.hexToColor()
Normie.palette.hexToColor()
Moved to Palette category
Normie.colorToHex()
Normie.palette.colorToHex()
Moved to Palette category
Normie.isValidEmail()
Normie.check.isEmail()
Renamed and moved
Normie.getFileExtension()
Normie.files.getExtension()
Renamed and moved
Normie.randomColor()
Normie.palette.randomColor()
Moved to Palette category
Normie.rotate()
Normie.maths.rotate()
Moved to Maths category
Step-by-Step Migration
1. Update Package Version
dependencies:
normie: ^2.0.0
2. Run Package Update
flutter pub get
3. Update Imports
No changes needed! Keep using:
import 'package:normie/normie.dart';
4. Find and Replace
Use your IDE's search feature to find old method calls. Here's a regex pattern to help:
Normie\.(reverse|formatDate|getWeekDayDate|truncate|getStringInitial|titleCase|hexToColor|colorToHex|isValidEmail|getFileExtension|randomColor|rotate)
5. Verify New Features
After migrating, consider implementing new features:
// New caching capabilities
Normie.cache.set('user', data, expiry: Duration(hours: 1));
// Enhanced validation
Normie.check.isStrongPassword(password);
Normie.check.isCreditCard(cardNumber);
// Better number formatting
Normie.numeric.formatCurrency(amount);
Normie.numeric.formatFileSize(bytes);
Common Migration Issues
1. Method Not Found Errors
// ❌ Error:
Normie.isValidEmail('test@example.com');
// ✅ Fix:
Normie.check.isEmail('test@example.com');
2. Parameter Changes
// ❌ Old way:
Normie.getWeekDayDate(date: '2024-03-15');
// ✅ New way:
Normie.chrono.getWeekDay(
date: '2024-03-15',
format: 'yyyy-MM-dd'
);
3. Return Type Changes
Some methods now return more specific types or include additional information. Always check the method signature in your IDE.
Migration Checklist
Need Help?
If you're stuck with migration:
Check the documentation for detailed method information
Open an issue on GitHub
Contact us at chat@codesadhu.com
Remember: This is a breaking change, but the new structure makes Normie more maintainable and feature-rich!
After Migration
Once you've completed the migration, consider:
Reviewing new utilities for potential optimizations
Adding error handling with the new Guard utility
Implementing caching where appropriate
Using the new validation methods for better security
Exploring new formatting options for better UX
The effort to migrate will be rewarded with cleaner, more maintainable code and access to powerful new features! 🎉
Last updated