Skip to content

Instantly share code, notes, and snippets.

@blaugold
Created September 15, 2021 14:38
Show Gist options
  • Save blaugold/b2893a13aa648cc47250d6081bb11cda to your computer and use it in GitHub Desktop.
Save blaugold/b2893a13aa648cc47250d6081bb11cda to your computer and use it in GitHub Desktop.
Flutter-Display-DevicePixelRatio
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.dark().copyWith(
scaffoldBackgroundColor: darkBlue,
),
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: MyWidget(),
),
),
);
}
}
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Text(
'${MediaQuery.of(context).devicePixelRatio} dpr',
style: Theme.of(context).textTheme.headline4,
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment