adaptive_screen_utils

pub package Score License Platform GitHub stars GitHub forks GitHub issues GitHub pull requests

A Flutter package to provide Adaptive Screen Utils for creating responsive UI for different screen sizes. Make your UI look great on any device.

Youtube Video

This package is created for educational purposes in Flutter Jaipur Meetup: Make your own package publish on pub.dev.

You can use it in production as well. It is a simple package that provides a few methods to check the screen size and create a responsive UI.

Flutter Jaipur Social Handles

LinkedIn Twitter Meetup YouTube

Usage

To use this package, add adaptive_screen_utils as a dependency in your pubspec.yaml file.

dependencies:
  adaptive_screen_utils: ^1.3.0

Example

Import the file to your project

import 'package:adaptive_screen_utils/adaptive_screen_utils.dart';
class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final desktop = expanded(context);
    final tablet = medium(context);
    return Scaffold(
      appBar: AppBar(
        title: Text('Adaptive Screen Utils'),
      ),
      body: Builder(
        builder: (context) {
         if (desktop) {
            return Center(
              child: Text(
                'Desktop',
                style: Theme.of(context).textTheme.headline4,
              ),
            );
          } else if (tablet) {
            return Center(
              child: Text(
                'Tablet',
                style: Theme.of(context).textTheme.headline4,
              ),
            );
          }
          return Center(
              child: Text(
                'Mobile',
                style: Theme.of(context).textTheme.headline4,
              ),
          );
        },
      ),
    );
  }
}

Methods

Method Description
compact Returns true if the screen width is less than 600.0
medium Returns true if the screen width is less than 840.0
expanded Returns true if the screen width is greater than 840.0

Issues & Feedback

If you wish to contribute to this repo, welcome to Pull Requests. Star ⭐ the repo if you find it useful 🤩🤩. we are open to enhancements, bug-fixes & suggestions. feel free to open an issue.

License

MIT License

Maintainers & Collaborators

Ravi Kovind

Flutter Jaipur