flutter_screen_adapt_kit 1.0.2 copy "flutter_screen_adapt_kit: ^1.0.2" to clipboard
flutter_screen_adapt_kit: ^1.0.2 copied to clipboard

Flutter 零侵入式屏幕适配,支持缩放、安全区域和文本适配

flutter_screen_adapt_kit #

A zero-code-invasion Flutter screen adaptation plugin for iOS, Android, and HarmonyOS.

Features #

  • Size Scaling: Automatically scales your UI to fit any screen size
  • Safe Area: Platform-aware notch/cutout handling (wide notch, dynamic island, hole punch, waterdrop)
  • Text Scaling: Configurable text scale behavior (scale with UI, system only, or fixed)
  • Foldable Support: Detect fold state (flat/half-opened), hinge position, and display cutouts
  • Zero Code Invasion: Write raw design values, no .w/.h suffixes needed
  • Graceful Degradation: All adapt APIs return 1.0 outside AdaptKit scope

Usage #

1. Initialize #

No special binding required. Just use WidgetsFlutterBinding.ensureInitialized().

2. Wrap your app #

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(
    AdaptKit(
      designSize: Size(375, 812), // Your design spec
      child: MaterialApp(
        home: MyHomePage(),
      ),
    ),
  );
}

3. Use adapt APIs anywhere in your widget tree #

// Get current scale ratio
final scale = context.adaptScale;

// Get adapted DPR
final dpr = context.adaptDpr;

// Get safe area insets
final safeTop = context.adaptSafeTop;
final safeBottom = context.adaptSafeBottom;

// Get notch info
final notchInfo = context.adaptNotchInfo;

// Get status bar and notch heights
final statusBar = context.statusBarHeight;  // Pure status bar (iOS: 24px, Android/HarmonyOS: 25px)
final notch = context.notchHeight;          // Notch area (total topInset - statusBar)

// Detect foldable state
final isFolded = context.isFolded;
final isFlat = context.isFlat;
final hingeBounds = context.adaptHingeBounds;

Configuration #

AdaptKit Parameters #

Parameter Default Description
designSize Size(375, 812) Your design specification
strategy AdaptStrategy.width Scaling strategy (width/height/min)
textBehavior TextBehavior.scale Text scale behavior
supportSystemTextScale true Whether to multiply by system font scale
safeMode SafeMode.auto Safe area handling mode
classifier null Platform-specific notch classifier

Dynamic Updates #

// At runtime
AdaptKit.of(context)?.setDesignSize(Size(430, 932));
AdaptKit.of(context)?.overrideNotch(NotchOverride(type: NotchType.wideNotch, topInset: 44));
AdaptKit.of(context)?.resetNotch();

License #

MIT

0
likes
140
points
126
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Flutter 零侵入式屏幕适配,支持缩放、安全区域和文本适配

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_screen_adapt_kit