Skip to content

Commit

Permalink
feat: screen responsiveness
Browse files Browse the repository at this point in the history
  • Loading branch information
AhsanRns committed May 7, 2024
1 parent d860ddb commit 373d137
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
12 changes: 12 additions & 0 deletions evently/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import 'dart:ui';

import 'package:easy_localization/easy_localization.dart';
import 'package:evently/utils/constants.dart';
import 'package:evently/utils/evently_app_theme.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

bool isTablet = false;

void main() async {
WidgetsFlutterBinding.ensureInitialized();
await EasyLocalization.ensureInitialized();

isTablet = _getIsCurrentDeviceTablet();

runApp(
EasyLocalization(
supportedLocales: const [
Expand Down Expand Up @@ -55,3 +62,8 @@ class MyApp extends StatelessWidget {
);
}
}

bool _getIsCurrentDeviceTablet() {
final MediaQueryData mediaQuery = MediaQueryData.fromView(PlatformDispatcher.instance.implicitView!);
return mediaQuery.size.shortestSide >= tabletMinWidth;
}
1 change: 1 addition & 0 deletions evently/lib/utils/constants.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
const double tabletMinWidth = 600;
18 changes: 18 additions & 0 deletions evently/lib/utils/screen_responsive.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import 'package:evently/main.dart';
import 'package:flutter/material.dart';

class ScreenResponsive extends StatelessWidget {
final WidgetBuilder mobileScreen;
final WidgetBuilder tabletScreen;

const ScreenResponsive({super.key, required this.mobileScreen, required this.tabletScreen});

@override
Widget build(BuildContext context) {
if (isTablet) {
return tabletScreen(context);
}

return mobileScreen(context);
}
}

0 comments on commit 373d137

Please sign in to comment.