scaled_window 1.0.4 copy "scaled_window: ^1.0.4" to clipboard
scaled_window: ^1.0.4 copied to clipboard

Render a widget/app at a custom resolution. Useful when developing for multiple environments.

example/lib/main.dart

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

void main() {
  runApp(
    ScaledWindow(
      resolution: Size(1366, 768),
      builder: (_, scale) => MyApp(scale: scale),
    ),
  );
}

class MyApp extends StatelessWidget {
  double scale;
  MyApp({Key? key, required this.scale}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final width = MediaQuery.of(context).size.width - 50;
    final textStyle = TextStyle(fontSize: 40, );
    return MaterialApp(
      home: Scaffold(
        backgroundColor: Colors.grey.shade200,
        appBar: AppBar(title: const Text('A Desktop App')),
        body: Padding(
          padding: const EdgeInsets.all(10),
          child: Row(
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: [
              Material(
                elevation: 10,
                child: SizedBox(
                  width: width / 4,
                  child: const RotatedBox(
                    quarterTurns: 1,
                    child: FittedBox(
                      child: Text('Left Sidebar'),
                    ),
                  ),
                ),
              ),
              const SizedBox(width: 15),
              Material(
                elevation: 10,
                child: SizedBox(
                  width: width / 2,
                  child: Column(
                    children: [
                      Text("Main View", style: textStyle),
                      SizedBox(height: 40),
                      Text("This app thinks it's running in a 1366x768 window", style: textStyle, textAlign: TextAlign.center,),
                      SizedBox(height: 40),
                      Text("Window scale: ${scale.toStringAsFixed(2)}", style: textStyle, textAlign: TextAlign.center,),
                    ],
                    mainAxisAlignment: MainAxisAlignment.center,
                    crossAxisAlignment: CrossAxisAlignment.center,
                  ),
                ),
              ),
              const SizedBox(width: 15),
              Material(
                elevation: 10,
                child: SizedBox(
                  width: width / 4,
                  child: const RotatedBox(
                    quarterTurns: 1,
                    child: FittedBox(
                      child: Text('Right Sidebar'),
                    ),
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
3
likes
130
pub points
49%
popularity

Publisher

unverified uploader

Render a widget/app at a custom resolution. Useful when developing for multiple environments.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

cupertino_icons, flutter

More

Packages that depend on scaled_window