fixedlayout 0.0.1 copy "fixedlayout: ^0.0.1" to clipboard
fixedlayout: ^0.0.1 copied to clipboard

A Flutter package that provides a fixed layout by disabling system text scaling.

FixedLayout #

Flutter Dart

A Flutter package that provides a fixed layout by disabling system text scaling. Ensure consistent UI design across devices by preventing unwanted text scaling from system settings.


Features #

  • Disable System Text Scaling: Override system text scaling to maintain a consistent UI.
  • Screen Size Utilities: Easily retrieve screen size and calculate scaling factors for responsive designs.
  • Simple Integration: Just wrap your Scaffold with the FixedLayout widget.

Installation #

Add the following to your pubspec.yaml file:

dependencies:
  fixedlayout: ^0.0.1

Then, run flutter pub get to install the package.


Usage #

Disable System Text Scaling #

Wrap your Scaffold with the FixedLayout widget to disable system text scaling:

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: FixedLayout(
        child: Scaffold(
          appBar: AppBar(
            title: Text('Fixed Layout Example'),
          ),
          body: Center(
            child: Text('This text will not scale with system settings.'),
          ),
        ),
      ),
    );
  }
}

Screen Size and Scaling Factor #

Use the FindMediaQuery class to get the screen size and calculate a scaling factor for responsive designs:

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

class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    Size screenSize = FindMediaQuery.screenSize(context);
    double scaleFactor = FindMediaQuery.scaleFactor(375.0, context); // 375.0 is the base width

    return Container(
      width: screenSize.width,
      height: screenSize.height,
      child: Text('Scale Factor: $scaleFactor'),
    );
  }
}

Example #

Here’s a complete example demonstrating how to use the FixedLayout widget and FindMediaQuery utilities:

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

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: FixedLayout(
        child: Scaffold(
          appBar: AppBar(
            title: Text('Fixed Layout Example'),
          ),
          body: Center(
            child: MyWidget(),
          ),
        ),
      ),
    );
  }
}

class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    Size screenSize = FindMediaQuery.screenSize(context);
    double scaleFactor = FindMediaQuery.scaleFactor(375.0, context);

    return Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Text('Screen Width: ${screenSize.width}'),
        Text('Screen Height: ${screenSize.height}'),
        Text('Scale Factor: $scaleFactor'),
      ],
    );
  }
}

Contributing #

Contributions are welcome! If you find a bug or have a feature request, please open an issue on the GitHub repository. If you'd like to contribute code, feel free to submit a pull request.


License #

This project is licensed under the MIT License. See the LICENSE file for details.


Support #

If you find this package useful, consider giving it a ⭐️ on GitHub. Your support is greatly appreciated!


This README.md provides a comprehensive overview of your package, including installation instructions, usage examples, and contribution guidelines. You can customize the GitHub links and other details as needed.

2
likes
130
points
25
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter package that provides a fixed layout by disabling system text scaling.

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on fixedlayout