ax_responsive 0.0.6 copy "ax_responsive: ^0.0.6" to clipboard
ax_responsive: ^0.0.6 copied to clipboard

A Flutter package for creating adaptive and responsive layouts across devices easily.

πŸ“± ax_responsive #

A powerful and minimal Flutter package for building responsive UIs easily.
It provides helpers like AxConsumer, AxResponsive, and context extensions to make adaptive layouts effortless.


πŸš€ Installation #

Add to your pubspec.yaml:

dependencies:
  ax_responsive: ^latest_version

Then run:

flutter pub get

βš™οΈ Setup #

Wrap your app with AxResponsive and ProviderScope (for Riverpod):

import 'package:ax_responsive/ax_responsive.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

void main() {
  runApp(
    ProviderScope(
      child: AxResponsive(const MyApp()),
    ),
  );
}

🧩 Components Overview #

πŸ”Ή AxResponsive #

This widget initializes the responsive engine and listens for size/orientation changes.
Wrap it around your root widget (usually your MaterialApp).

AxResponsive(const MyApp())

πŸ”Ή AxConsumer #

A widget that rebuilds in real time whenever the screen size, orientation, or platform changes.
Perfect for live responsive updates without manual setState calls.

AxConsumer(
  builder: (context) {
    final width = 0.5.sw;
    final height = 0.3.sh;
    return Container(width: width, height: height);
  },
)

πŸ”Ή Screen Size Extensions #

Easily get responsive dimensions using .sw and .sh (screen width/height):

Expression Description Example
0.5.sw 50% of screen width Container(width: 0.5.sw)
0.3.sh 30% of screen height Container(height: 0.3.sh)

πŸ”Ή Responsive Builders #

Use context.res() to define different widgets for each device type:

context.res(
  orElse: () => Text("Default View"),
  mobile: (v) => Text("πŸ“± Mobile"),
  tabletLow: (v) => Text("πŸ’» Tablet Low"),
  tabletPortrait: (v) => Text("πŸ“— Tablet Portrait"),
  large: (v) => Text("πŸ–₯️ Large Screen"),
  desktop: (v) => Text("πŸ–₯️ Desktop"),
);

πŸ”Ή context.resMaybe() #

Same as res, but returns a widget directly instead of a function.
Simplifies usage when you don’t need the parameter.

context.resMaybe(
  orElse: Text("Default View"),
  mobile: Text("πŸ“± Mobile View"),
  desktop: Text("πŸ–₯️ Desktop View"),
);

πŸ”Ή Orientation Builder #

Detect orientation changes easily:

context.orien(
  portrait: "πŸ“² Portrait Mode",
  landscape: "πŸŒ„ Landscape Mode",
);

πŸ”Ή Platform Checks #

Quick checks for platform type:

context.isMobile     // true if mobile
context.isTablet     // true if tablet
context.isDesktop    // true if desktop
context.isPortrait   // true if portrait
...

πŸ’‘ Key Features #

βœ… Real-time responsive rebuilds
βœ… Simple .sw and .sh extensions for sizing
βœ… Orientation and platform detection
βœ… Works perfectly with Riverpod
βœ… Lightweight and production-ready


🧰 Example Folder #

For a full working demo, check out the example/ folder in the repository.


❀️ Made with Flutter #

If you find this package helpful, don’t forget to ⭐ the repo!

1
likes
145
points
18
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter package for creating adaptive and responsive layouts across devices easily.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_riverpod, freezed_annotation

More

Packages that depend on ax_responsive