12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- import 'package:flutter/foundation.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter/services.dart';
- import 'package:flutter_localizations/flutter_localizations.dart';
- import 'package:tetris/gamer/gamer.dart';
- import 'package:tetris/generated/l10n.dart';
- import 'package:tetris/material/audios.dart';
- import 'package:tetris/panel/page_portrait.dart';
- import 'gamer/keyboard.dart';
- void main() {
- WidgetsFlutterBinding.ensureInitialized();
- debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;
- _disableDebugPrint();
- runApp(const MainApp());
- SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
- statusBarColor: Colors.transparent,
- statusBarIconBrightness: Brightness.dark,
- systemNavigationBarColor: Colors.transparent,
- systemNavigationBarIconBrightness: Brightness.dark,
- ));
- }
- void _disableDebugPrint() {
- bool debug = false;
- assert(() {
- debug = true;
- return true;
- }());
- if (!debug) {
- debugPrint = (message, {wrapWidth}) {
- //disable log print when not in debug mode
- };
- }
- }
- final RouteObserver<ModalRoute> routeObserver = RouteObserver<ModalRoute>();
- class MainApp extends StatelessWidget {
- const MainApp({super.key});
- // This widget is the root of your application.
- @override
- Widget build(BuildContext context) {
- return MaterialApp(
- title: '俄罗斯方块',
- localizationsDelegates: const [
- S.delegate,
- GlobalMaterialLocalizations.delegate,
- GlobalWidgetsLocalizations.delegate
- ],
- navigatorObservers: [routeObserver],
- supportedLocales: S.delegate.supportedLocales,
- theme: ThemeData(
- primarySwatch: Colors.blue,
- ),
- home: Scaffold(
- body: Sound(child: Game(child: KeyboardController(child: _HomePage()))),
- ),
- );
- }
- }
- const screenBorderWidth = 3.0;
- const backgroundColor = Color(0xffefcc19);
- class _HomePage extends StatelessWidget {
- @override
- Widget build(BuildContext context) {
- //only Android/iOS support land mode
- bool land = MediaQuery.of(context).orientation == Orientation.landscape;
- return land ? const PageLand() : const PagePortrait();
- }
- }
|