main.dart 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Copyright 2019 The FlutterCandies author. All rights reserved.
  2. // Use of this source code is governed by an Apache license that can be found
  3. // in the LICENSE file.
  4. import 'package:flutter/material.dart';
  5. import 'package:flutter/services.dart';
  6. import 'extensions/color_extension.dart';
  7. import 'extensions/l10n_extensions.dart';
  8. import 'l10n/gen/app_localizations.dart';
  9. import 'pages/splash_page.dart';
  10. const Color themeColor = Color(0xff00bc56);
  11. /// The mock size is used for integration tests.
  12. /// Changing this requires at least a hot-restart.
  13. const Size? mockSize = null;
  14. String? packageVersion;
  15. void main() {
  16. runApp(const MyApp());
  17. SystemChrome.setSystemUIOverlayStyle(
  18. SystemUiOverlayStyle.dark.copyWith(statusBarColor: Colors.transparent),
  19. );
  20. }
  21. class MyApp extends StatelessWidget {
  22. const MyApp({super.key});
  23. @override
  24. Widget build(BuildContext context) {
  25. return MaterialApp(
  26. onGenerateTitle: (BuildContext context) => context.l10n.appTitle,
  27. theme: ThemeData(
  28. brightness: Brightness.light,
  29. primarySwatch: themeColor.swatch,
  30. textSelectionTheme: const TextSelectionThemeData(
  31. cursorColor: themeColor,
  32. ),
  33. ),
  34. darkTheme: ThemeData(
  35. brightness: Brightness.dark,
  36. primarySwatch: themeColor.swatch,
  37. textSelectionTheme: const TextSelectionThemeData(
  38. cursorColor: themeColor,
  39. ),
  40. ),
  41. home: const SplashPage(),
  42. localizationsDelegates: AppLocalizations.localizationsDelegates,
  43. supportedLocales: AppLocalizations.supportedLocales,
  44. builder: (context, child) {
  45. if (mockSize == null) {
  46. return child!;
  47. }
  48. final mq = MediaQuery.of(context).copyWith(size: mockSize);
  49. return MediaQuery(
  50. data: mq,
  51. child: Align(
  52. alignment: Alignment.topCenter,
  53. child: SizedBox.fromSize(size: mockSize, child: child),
  54. ),
  55. );
  56. },
  57. );
  58. }
  59. }