|
|
||
|
|
||
|
|
||
|
|
||
Put, LazyPut |
عالی
SmartLazyPut, Enhanced DI |
35% بهبود |
یک کتابخانه قدرتمند و آسان برای ساخت انیمیشنهای زیبا و روان در Flutter با یک API ساده و بصری.
هسته سیستم انیمیشن که چرخه حیات انیمیشن را به طور کامل مدیریت میکند.
GetAnimatedBuilder<double>(
duration: Duration(milliseconds: 500),
delay: Duration(milliseconds: 200),
tween: Tween<double>(begin: 0.0, end: 1.0),
idleValue: 0.0,
curve: Curves.easeInOut,
onStart: (controller) => print('Animation started!'),
onComplete: (controller) => print('Animation completed!'),
builder: (context, value, child) {
return Opacity(
opacity: value,
child: child,
);
},
child: Text('Hello World!'),
)
یک ویجت چندمنظوره برای اعمال انیمیشنهای از پیش تعریف شده.
class AnimatedCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Animate(
duration: Duration(milliseconds: 800),
type: AnimationType.slideInLeft,
customOffset: 100,
curve: Curves.easeOutBack,
onStart: (controller) {
print('Card animation started');
},
onComplete: (controller) {
print('Card animation completed');
},
child: Card(
child: Container(
padding: EdgeInsets.all(16),
child: Text('Animated Card'),
),
),
);
}
}
Extension methods for easily applying animations with a smooth and chainable API.
Duration duration = Duration(seconds: 2) // Animation duration
Duration delay = Duration.zero // Delay
ValueSetter<AnimationController>? onComplete // End callback
bool isSequential = false // Sequential execution
// Fade
myWidget.fadeIn(duration: Duration(seconds: 1))
myWidget.fadeOut(duration: Duration(seconds: 1))
// Scale
myWidget.scale(
begin: 0.8,
end: 1.2,
duration: Duration(milliseconds: 600),
)
// Rotate (turns)
myWidget.rotate(
begin: 0.0, // Start
end: 1.0, // One full turn
duration: Duration(seconds: 2),
)
// Spin (full rotation)
myWidget.spin(duration: Duration(seconds: 1))
enum SlideType {
left, // From left
right, // From right
top, // From top
bottom, // From bottom
}
// Usage
myWidget.slideIn(
type: SlideType.left,
distance: 100.0,
duration: Duration(milliseconds: 500),
)
myWidget.slideOut(
type: SlideType.right,
distance: 200.0,
duration: Duration(milliseconds: 400),
)
// Bounce
myWidget.bounce(
begin: 1.0,
end: 1.3,
duration: Duration(milliseconds: 800),
)
// Blur
myWidget.blur(
begin: 0.0,
end: 10.0,
duration: Duration(milliseconds: 1000),
)
// Flip
myWidget.flip(duration: Duration(milliseconds: 600))
// Wave
myWidget.wave(duration: Duration(seconds: 2))
myWidget
.fadeIn(
duration: Duration(milliseconds: 500),
)
.slideIn(
type: SlideType.left,
duration: Duration(milliseconds: 600),
isSequential: true, // Execute after fadeIn
)
.bounce(
begin: 1.0,
end: 1.1,
duration: Duration(milliseconds: 300),
isSequential: true, // Execute after slideIn
);
ویجت هوشمند که بهطور خودکار UI را هنگام تغییر متغیرهای مشاهدهشده بهروزرسانی میکند.
class CounterView extends ReactiveGetView<CounterController> {
@override
Widget build(BuildContext context) {
return Text('Count: ${controller.count.value}');
// No Obx needed!
}
}
تبدیل خودکار پیکسل به مقادیر پاسخگو با پایگاه ابعاد دینامیک.
Container(
width: 134.w, // 134px responsive width
height: 30.h, // 30px responsive height
child: Text(
'Hello',
style: TextStyle(fontSize: 16.sp),
),
)
اشکال Squircle اصیل اپل و بهبودهای Cupertino برای تجربه iOS بهتر.
GetCupertinoApp(
theme: CupertinoThemeData(
primaryColor: CupertinoColors.systemBlue,
),
home: HomePage(),
)
HTTP کش، منطق تلاش مجدد هوشمند، ثبت درخواست و مدیریت اتصال.
class ApiService extends GetConnect {
@override
void onInit() {
enableCaching = true;
enableRetry = true;
maxRetries = 3;
}
}
SmartLazyPut برای مدیریت چرخه حیات هوشمند و بازآفرینی خودکار.
Get.smartLazyPut(() => MyController());
// Enhanced injection with validation
Get.smartPut<DatabaseService>(
builder: () => DatabaseService(),
condition: () => NetworkManager.isConnected,
);
بهینهسازی برای آخرین نسخههای Flutter با عملکرد 60% بهتر.
حالت سنتی GetX که فقط هنگام راهاندازی مجدد یا Hot Reload بهروزرسانی میشود.
Container(
width: 300.w,
height: 100.h,
child: Text('Hello', style: TextStyle(fontSize: 16.sp)),
)
بهروزرسانی بلادرنگ با استفاده از LayoutBuilder.
ResponsiveBuilder(
mode: ResponsiveMode.layoutBuilder,
builder: (context, data) {
return Container(
width: data.w(300), // Updates instantly!
height: data.h(100),
);
},
)
بهروزرسانی بلادرنگ با MediaQuery برای صفحات تکی.
SinglePageResponsive(
builder: (data) {
return Container(
width: data.w(300),
child: Text('Device: ${data.deviceType}'),
);
},
)
ResponsiveHelper.responsiveValue(
phone: 14.0,
tablet: 16.0,
laptop: 18.0,
desktop: 20.0,
)
مقادیر مختلف برای انواع مختلف دستگاهها برمیگرداند.
ویژگی | GetMaterialApp | GetCupertinoApp |
---|---|---|
سیستم طراحی | Material Design | iOS/Cupertino |
ویجتها | Material widgets | Cupertino widgets |
پشتیبانی Squircle | ||
اصالت iOS | خوب | عالی |
چندپلتفرمه |
کش خودکار پاسخ با TTL (Time To Live) برای بهبود عملکرد.
class ApiService extends GetConnect {
@override
void onInit() {
enableCaching = true;
cacheMaxAge = Duration(minutes: 5);
}
}
منطق تلاش مجدد قابل تنظیم برای مقاومت بیشتر در برابر خطا.
enableRetry = true;
maxRetries = 3;
retryDelay = Duration(seconds: 2);
ثبت جزئیات درخواست/پاسخ برای دیباگ بهتر.
enableLogging = true;
// Detailed request/response logging
class ChatService extends GetConnect {
late GetSocket _socket;
void connectToChat() {
_socket = socket('wss://chat.example.com/ws');
_socket.onOpen(() {
print('Connected to chat');
});
_socket.on('chat_message', (data) {
final message = ChatMessage.fromJson(data);
_handleNewMessage(message);
});
// Enhanced: Auto-reconnection
_socket.enableAutoReconnect = true;
_socket.maxReconnectAttempts = 5;
}
void sendMessage(String message) {
if (_socket.isConnected) {
_socket.emit('chat_message', {
'text': message,
'timestamp': DateTime.now().toIso8601String(),
});
}
}
}
برای ویجتهایی که نیاز به بهروزرسانی خودکار دارند.
// ✅ Good
class HomeView extends ReactiveGetView<HomeController> {
@override
Widget build(BuildContext context) {
return Text(controller.title.value); // No Obx!
}
}
استفاده از SmartLazyPut برای مدیریت بهتر کنترلرها.
// ✅ Good
Get.smartLazyPut(() => HomeController());
// Enhanced binding
binding: BindingsBuilder.smartLazyPut(() => MyController())
انتخاب حالت مناسب برای نیازهای مختلف.
// ✅ Good: For real-time updates
ResponsiveBuilder(
mode: ResponsiveMode.layoutBuilder,
builder: (context, data) => MyWidget(),
)
با ReactiveGetView نیازی به Obx نیست.
// ❌ Avoid
class HomeView extends ReactiveGetView<HomeController> {
Widget build(BuildContext context) {
return Obx(() => Text(controller.title.value)); // Unnecessary!
}
}
از put برای کنترلرهایی که ممکن است استفاده نشوند خودداری کنید.
// ❌ Avoid
Get.put(MaybeUnusedController()); // Immediate injection
// ✅ Better
Get.smartLazyPut(() => MaybeUnusedController());
همیشه منابع را در onClose پاکسازی کنید.
// ❌ Avoid: No cleanup
@override
void onClose() {
super.onClose(); // Missing resource cleanup!
}
// ✅ Good: Proper cleanup
@override
void onClose() {
_subscription.cancel();
_animationController.dispose();
super.onClose();
}
// Old GetX
class HomeView extends GetView<HomeController> {
Widget build(BuildContext context) {
return Obx(() => Text(controller.title.value));
}
}
// Binding
class HomeBinding extends Bindings {
void dependencies() {
Get.lazyPut(() => HomeController());
}
}
// New GetX Master
class HomeView extends ReactiveGetView<HomeController> {
Widget build(BuildContext context) {
return Text(controller.title.value); // No Obx!
}
}
// Enhanced Binding
class HomeBinding extends Bindings {
void dependencies() {
Get.smartLazyPut(() => HomeController());
}
}
کنترلرها و سرویسها فقط هنگام نیاز ایجاد میشوند.
مدیریت حافظه بهطور خودکار انجام میشود.
فقط ویجتهای متأثر هنگام تغییر state بازسازی میشوند.
GetX Master نسل جدید مدیریت State در Flutter است که با الهام از اصول طراحی GetX، امکانات پیشرفتهای مثل سیستم Responsive بلادرنگ، پشتیبانی کامل Cupertino، تزریق وابستگی هوشمند و بهبودهای عملکرد قابل توجه را ارائه میدهد.
60% سریعتر و 30% کمتر استفاده از حافظه
ReactiveGetView، سیستم Responsive و Cupertino کامل
مهاجرت آسان از GetX و سازگاری با کدهای موجود