suit 1.0.0 copy "suit: ^1.0.0" to clipboard
suit: ^1.0.0 copied to clipboard

A library of platform adaptation scheme based on the ViewPort (vw and vh).

suit #

😭 😭

A library of platform adaptation scheme based on the ViewPort (vw and vh). #




1. Initialize the adapter #

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

class _AppState extends State<App> {
  @override
  Widget build(BuildContext context) {
    Adapter.initialize(context);

    return Scaffold();
  }
}
  • Cannot initialize under root widget
  • An application only needs to be initialized once
  • You can write it in any lifecycle hook, but for desktop application adaptation, it's better to write it in the build method

2. Import the package and write size by vh, vw anywhere #

  • Method 1: 36.vw, 52.0.vw, 100vh
  • Method 2: Adapter.setVW(25), Adapter.setVH(30)
  • Method 3: Adapter.vw * 32, Adapter.vh * 75


Complete example: #

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


void main() => runApp(MaterialApp(home: App()));

class App extends StatefulWidget {
  @override
  _AppState createState() => _AppState();
}

class _AppState extends State<App> {
  @override
  Widget build(BuildContext context) {
    // You can write it to initialize adapter here
    Adapter.initialize(context);
    return Scaffold(
        body: Container(
            width: 25.vw,
            height: 75.vh,
            color: Colors.red
        )
    );
  }
}

1
likes
120
pub points
1%
popularity

Publisher

unverified uploader

A library of platform adaptation scheme based on the ViewPort (vw and vh).

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on suit