sf 0.0.4 copy "sf: ^0.0.4" to clipboard
sf: ^0.0.4 copied to clipboard

A Flutter screen fit plugin. This tool will allow your app to perform the same on different resolutions of the screen!

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:sf/sf.dart';

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

  @override
  void initState() {
    super.initState();

    initPlatformState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;

    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      platformVersion = await Sf.platformVersion;
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  @override
  Widget build(BuildContext context) {
    sf.init(context).fit(375, 1440);
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Wrap(
          children: <Widget>[
            Container(
              color: Colors.pink,
              width: sf.dp(Dp.$200),
              height: sf.dp(Dp.$200),
            ),
            Container(
              color: Colors.green,
              width: sf.dp(Dp.$175),
              height: sf.dp(Dp.$200),
            ),
            Container(
              color: Colors.orange,
              width: sf.dp(Dp.$20),
              height: sf.dp(Dp.$60),
            ),
            Container(
              color: Colors.pink,
              width: 20.$dp,
              height: 60.$dp,
            ),
            Text("A 测", style: TextStyle(fontSize: sf.sp(Sp.$60))),
            Text("A 测",
                style: TextStyle(
                  fontSize: 60.$sp,
                ))
          ],
        ),
      ),
    );
  }
}
0
likes
35
pub points
0%
popularity

Publisher

unverified uploader

A Flutter screen fit plugin. This tool will allow your app to perform the same on different resolutions of the screen!

Repository (GitHub)
View/report issues

License

BSD-3-Clause (LICENSE)

Dependencies

flutter

More

Packages that depend on sf