πŸ“¦ adaptive_ui_intent

Intent-based adaptive UI for Flutter Design layouts based on what the user is doing, not what device they are on.


✨ Why adaptive_ui_intent?

Most Flutter apps adapt UI like this:

if (width > 600) ...
if (Platform.isIOS) ...
if (isTablet) ...

This package introduces a new way of thinking:

πŸ‘‰ Adapt UI based on intent (reading, input, monitoring, media, navigation)


🧠 Core Concept: UI Intent

Instead of device checks, you declare intent:

AdaptiveIntent(
  intent: UIIntent.monitoring,
  builder: (context, config) {
    return GridView(
      crossAxisCount: config.columns,
    );
  },
);

The package automatically decides:

  • Columns
  • Spacing
  • Max width
  • Aspect ratio based on screen size + platform + intent

🎯 Supported UI Intents

enum UIIntent {
  reading,
  navigation,
  input,
  monitoring,
  media,
}
Intent Best for
reading Articles, blogs, text-heavy screens
navigation Menus, dashboards, app navigation
input Forms, login, data entry
monitoring Charts, analytics, stats
media Video, images, galleries

πŸš€ Installation

Add to your pubspec.yaml:

dependencies:
  adaptive_ui_intent: ^0.1.0

Then run:

flutter pub get

🧩 Basic Usage

AdaptiveIntent(
  intent: UIIntent.reading,
  builder: (context, config) {
    return Padding(
      padding: EdgeInsets.all(config.spacing),
      child: ConstrainedBox(
        constraints: BoxConstraints(maxWidth: config.maxWidth),
        child: Text(
          longArticleText,
          style: Theme.of(context).textTheme.bodyLarge,
        ),
      ),
    );
  },
);

βš™οΈ IntentConfig Explained

The builder provides an IntentConfig:

class IntentConfig {
  final int columns;
  final double maxWidth;
  final double spacing;
  final double aspectRatio;
}

Use it to drive layout decisions, not widget logic.


πŸ“Š Example: Monitoring Dashboard

AdaptiveIntent(
  intent: UIIntent.monitoring,
  builder: (context, config) {
    return GridView.count(
      crossAxisCount: config.columns,
      childAspectRatio: config.aspectRatio,
      children: List.generate(
        6,
        (i) => Card(child: Center(child: Text('Chart $i'))),
      ),
    );
  },
);

βœ” Phone β†’ single column βœ” Tablet β†’ grid layout βœ” Web β†’ wide dashboard


🎨 Platform Awareness (Built-in)

The package automatically adapts for:

  • πŸ“± Phone vs Tablet
  • πŸ–₯️ Web
  • 🍎 iOS spacing
  • πŸ€– Android spacing

No platform checks needed.


πŸ§ͺ Example App

cd example
flutter run

Resize the window or switch devices to see intent-based adaptation.


πŸ›£οΈ Roadmap

Planned features:

  • πŸ”„ Custom intent overrides
  • β™Ώ Accessibility-aware intents
  • ⌚ WearOS / small-screen presets
  • πŸ“ Foldable device support

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Add tests if possible
  4. Submit a pull request

Small improvements are welcome πŸ™Œ


πŸ“„ License

MIT License Free for personal and commercial use.


Libraries

adaptive_ui_intent