Skip to content

Instantly share code, notes, and snippets.

@dolpheen
Created July 27, 2020 20:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dolpheen/7e096b6bc8f535660d641554a444263e to your computer and use it in GitHub Desktop.
Save dolpheen/7e096b6bc8f535660d641554a444263e to your computer and use it in GitHub Desktop.
Replaces system viewconfiguration
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
class CustomWidgetsFlutterBinding extends WidgetsFlutterBinding {
@override
ViewConfiguration createViewConfiguration() {
final ratio = 4.0;
return ViewConfiguration(
size: window.physicalSize / ratio,
devicePixelRatio: ratio,
);
}
static WidgetsBinding ensureInitialized() {
if (WidgetsBinding.instance == null) {
CustomWidgetsFlutterBinding();
}
return WidgetsBinding.instance;
}
}
void main() {
CustomWidgetsFlutterBinding.ensureInitialized()
..attachRootWidget(
Center(
child: Container(width: 50, height: 50, color: Colors.red),
),
)
..scheduleWarmUpFrame();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment