Closed Turbozanik closed 11 months ago
Hi. i faced the same problem, but it is covered by ScreenUtil.init function see example: @override Widget build(BuildContext context) { if (Get.currentRoute.contains(Strings.numberScreen) && !kIsWeb) { ScreenUtil.init(context, designSize: const Size(1080, 1920)); }
you can easely add any condition and modify designSize
Hi. i faced the same problem, but it is covered by ScreenUtil.init function see example: @OverRide Widget build(BuildContext context) { if (Get.currentRoute.contains(Strings.numberScreen) && !kIsWeb) { ScreenUtil.init(context, designSize: const Size(1080, 1920)); }
you can easely add any condition and modify designSize
@Bravo2x And it works with window resize for web?
This issue is stale because it has been open for 30 days with no activity.
@Turbozanik you can use this lib (https://pub.dev/packages/flutter_flavorizr) to define screen sizes
Hi. i faced the same problem, but it is covered by ScreenUtil.init function see example: @OverRide Widget build(BuildContext context) { if (Get.currentRoute.contains(Strings.numberScreen) && !kIsWeb) { ScreenUtil.init(context, designSize: const Size(1080, 1920)); }
you can easely add any condition and modify designSize
@Bravo2x And it works with window resize for web?
Can be used on web and windows, but the effect depends on whether it meets your expectations
@Turbozanik how u solve that problem ?
This issue is stale because it has been open for 30 days with no activity.
Did you solve the problem?
Hi. i faced the same problem, but it is covered by ScreenUtil.init function see example: @OverRide Widget build(BuildContext context) { if (Get.currentRoute.contains(Strings.numberScreen) && !kIsWeb) { ScreenUtil.init(context, designSize: const Size(1080, 1920)); }
you can easely add any condition and modify designSize
@Bravo2x And it works with window resize for web?
Can be used on web and windows, but the effect depends on whether it meets your expectations
@RomanSoviak This approach actually works. I have not yet changed my existing project. But I will use this in the next one.
class MyApp extends StatelessWidget with WidgetsBindingObserver
+
@override
didChangeMetrics() {
//this is what my lib does
// Fimber.e(MediaQueryData.fromView(WidgetsBinding.instance.platformDispatcher.views.first).size.width.toString());
// AppDimensions.instance
// .updateDeviceMediaQueryData(MediaQueryData.fromView(WidgetsBinding.instance.platformDispatcher.views.first));
// you can replace it with this:
if(kWeb && isDesktopSize()) {
ScreenUtil.init(context, designSize: const Size(1080, 1920));// and it should trigger ScreenUtil internal sizeFacor update.
} else if(kWeb && isTabletSize()){
ScreenUtil.init(context, designSize: const Size(720, 1280));// and it should trigger ScreenUtil internal sizeFacor update.
} else ....
}
@Turbozanik thanks a lot for the reply :))
This issue is stale because it has been open for 30 days with no activity.
need once refresh can show right my code:
Widget build(BuildContext context) {
Size designSize;
if (Platform.isIOS) {
// Apple IOS 14 Size
designSize = Size(390, 844);
} else if (Platform.isAndroid) {
// Desktop 设计尺寸
designSize = Size(360, 690);
} else if (Platform.isWindows) {
// Desktop 设计尺寸
designSize = Size(1440, 1024);
} else if (Platform.isMacOS) {
// MacBook Air Size
designSize = Size(1280, 832);
} else {
designSize = Size(360, 690);
}
return ScreenUtilInit(
designSize: designSize,
// minTextAdapt: true,
splitScreenMode: true,
// useInheritedMediaQuery: true,
builder: (context, child) {
return RefreshConfiguration(
footerTriggerDistance: 15,
dragSpeedRatio: 0.91,
headerBuilder: () => MaterialClassicHeader(),
footerBuilder: () => ClassicFooter(),
enableLoadingWhenNoData: false,
enableRefreshVibrate: false,
enableLoadMoreVibrate: false,
shouldFooterFollowWhenNotFull: (state) {
// If you want load more with noMoreData state ,may be you should return false
return false;
},
child: GetMaterialApp(
title: "Arce",
// home: WelcomePage(),
// routes: staticRoutes,
getPages: AppPages.routes,
initialRoute: AppPages.INITIAL,
debugShowCheckedModeBanner: false,
locale: TranslationService.to.locale,
fallbackLocale: TranslationService.fallbackLocale,
translations: TranslationService.to.translations,
theme: ThemeService.to.lightTheme,
darkTheme: ThemeService.to.darkTheme,
themeMode: ThemeService.to.themeMode,
// theme: ThemeService,
builder: (context, widget) {
return MediaQuery(
// 设置全局文字缩放因子为默认1.0,文字大小不随系统变化而改变
data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
child: ResponsiveBreakpoints.builder(
child: widget!,
breakpoints: [
const Breakpoint(start: 0, end: 450, name: MOBILE),
const Breakpoint(start: 641, end: 1007, name: TABLET),
const Breakpoint(start: 1008, end: 1920, name: DESKTOP),
const Breakpoint(
start: 1921, end: double.infinity, name: '4K'),
],
));
},
),
);
});
}
before refresh
after:
sorry, might my code error,i will check it
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.
I needed to support mobile/tablet/desktop web screen sizes with different designs in my app. And I can't do this using this library, as I can set only one design size rigt now.
So I have created my own simplified lib for this case folowing the example of yor library.
I guess it would be really nice to have this functionality in this library. It will shurely help me =).
I would appreciate any feedback on this.
Sharing my code: Lib:
Usage: