adaptive_screen_utils 2.3.0 copy "adaptive_screen_utils: ^2.3.0" to clipboard
adaptive_screen_utils: ^2.3.0 copied to clipboard

Flutter Package for creating adaptive UIs for different screen sizes.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:adaptive_screen_utils/adaptive_screen_utils.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({super.key});
  @override
  Widget build(BuildContext context) => MaterialApp(
        title: 'Adaptive Screen Utils',
        theme: ThemeData(
          colorScheme: ColorScheme.fromSeed(seedColor: Colors.red),
        ),
        darkTheme: ThemeData(
          colorScheme: ColorScheme.fromSeed(seedColor: Colors.redAccent),
        ),
        home: const MyHomePage(title: 'Adaptive Screen Utils'),
      );
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    final mobile = compact(context);
    final tablet = medium(context);
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: GridView(
        gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
          crossAxisCount: mobile
              ? 2
              : tablet
                  ? 4
                  : 6,
        ),
        children: [
          ...List.generate(
            2 * 4 * 6,
            (index) => Container(
              color: index.isEven
                  ? Theme.of(context).colorScheme.onPrimaryContainer
                  : Theme.of(context).colorScheme.onSecondaryContainer,
              child: Center(
                child: Text(
                  'Item ${index + 1}',
                  style: Theme.of(context).textTheme.titleLarge?.copyWith(
                        color: index.isEven
                            ? Theme.of(context).colorScheme.onPrimary
                            : Theme.of(context).colorScheme.onSecondary,
                      ),
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}
14
likes
160
points
209
downloads

Publisher

verified publisherbetterx.io

Weekly Downloads

Flutter Package for creating adaptive UIs for different screen sizes.

Homepage
Repository (GitHub)
View/report issues

Topics

#sizer #adaptive #responsive #adaptive-screen-utils #flutter

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on adaptive_screen_utils