main.dart 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import 'package:flutter/foundation.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_localizations/flutter_localizations.dart';
  4. import 'package:tetris/gamer/gamer.dart';
  5. import 'package:tetris/generated/l10n.dart';
  6. import 'package:tetris/material/audios.dart';
  7. import 'package:tetris/panel/page_portrait.dart';
  8. import 'gamer/keyboard.dart';
  9. void main() {
  10. debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;
  11. _disableDebugPrint();
  12. runApp(const MainApp());
  13. }
  14. void _disableDebugPrint() {
  15. bool debug = false;
  16. assert(() {
  17. debug = true;
  18. return true;
  19. }());
  20. if (!debug) {
  21. debugPrint = (message, {wrapWidth}) {
  22. //disable log print when not in debug mode
  23. };
  24. }
  25. }
  26. final RouteObserver<ModalRoute> routeObserver = RouteObserver<ModalRoute>();
  27. class MainApp extends StatelessWidget {
  28. const MainApp({super.key});
  29. // This widget is the root of your application.
  30. @override
  31. Widget build(BuildContext context) {
  32. return MaterialApp(
  33. title: '俄罗斯方块',
  34. localizationsDelegates: const [
  35. S.delegate,
  36. GlobalMaterialLocalizations.delegate,
  37. GlobalWidgetsLocalizations.delegate
  38. ],
  39. navigatorObservers: [routeObserver],
  40. supportedLocales: S.delegate.supportedLocales,
  41. theme: ThemeData(
  42. primarySwatch: Colors.blue,
  43. ),
  44. home: Scaffold(
  45. body: Sound(child: Game(child: KeyboardController(child: _HomePage()))),
  46. ),
  47. );
  48. }
  49. }
  50. const screenBorderWidth = 3.0;
  51. const backgroundColor = Color(0xffefcc19);
  52. class _HomePage extends StatelessWidget {
  53. @override
  54. Widget build(BuildContext context) {
  55. //only Android/iOS support land mode
  56. bool land = MediaQuery.of(context).orientation == Orientation.landscape;
  57. return land ? const PageLand() : const PagePortrait();
  58. }
  59. }