esizer 1.0.1 copy "esizer: ^1.0.1" to clipboard
esizer: ^1.0.1 copied to clipboard

A Flutter package provide responsive, dynamic, configurable size for each device screen size.

example/lib/main.dart

import 'dart:io';

import 'package:esizer/esizer.dart';
import 'package:example/responsive_home_page.dart';
import 'package:flutter/material.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'ESizer Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: ESizer(
        builder: (BuildContext context) {
          return const ResponsiveHomePage();
        },
        sizeFileResolver: _resolveSizeDataFile,
      ),
    );
  }

  String _resolveSizeDataFile(
      {BoxConstraints? boxConstraints, Orientation? orientation}) {
    if (boxConstraints != null) {
      if (Platform.isAndroid || Platform.isIOS) {
        if (orientation == Orientation.portrait) {
          if (boxConstraints.maxWidth < 600) {
            return "phone.yaml";
          } else {
            return "tablet.yaml";
          }
        } else if (orientation == Orientation.landscape) {
          if (boxConstraints.maxHeight < 600) {
            return "phone.yaml";
          } else {
            return "tablet.yaml";
          }
        } else {
          return "phone.yaml";
        }
      } else {
        return "phone.yaml";
      }
    }
    return "phone.yaml";
  }
}
3
likes
120
pub points
23%
popularity

Publisher

unverified uploader

A Flutter package provide responsive, dynamic, configurable size for each device screen size.

Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

License

MIT (LICENSE)

Dependencies

args, flutter, path, yaml

More

Packages that depend on esizer