Restrict builder to a specific platform with a responsive framework

644 Views Asked by At

My application is compatible with both desktop and mobile devices. In my application, I use the responsive framework package to ensure responsiveness.

 Widget build(BuildContext context) {
    return MaterialApp(
      builder: (context, child) =>
 // want to check the platform here
 ResponsiveWrapper.builder(
     child,
     maxWidth:MediaQuery.of(context).size.width,
     minWidth: MediaQuery.of(context).size.width,
     maxWidthLandscape: 2400,
     minWidthLandscape: 600,
     defaultScale: true,
     breakpointsLandscape: [
      const ResponsiveBreakpoint.resize(600, name: MOBILE, scaleFactor: 0.2,),
      const ResponsiveBreakpoint.autoScale(800, name: TABLET, scaleFactor: 0.7,),
      const ResponsiveBreakpoint.resize(1000, name: DESKTOP,scaleFactor: 1.2,),
      const ResponsiveBreakpoint.autoScale(1900, name: "Large Screen")
    ],
     breakpoints: [
       const ResponsiveBreakpoint.autoScale(600, name: MOBILE),
       const ResponsiveBreakpoint.autoScale(800, name: TABLET),
       const ResponsiveBreakpoint.autoScale(1000, name: DESKTOP),
       const ResponsiveBreakpoint.autoScale(1900, name: 'LARGE SCREEN')
   ],
   ),,
      home: HomeScreen(),
    );
  }
}

I'd like the builder to just work only on desktop platforms. How can I make a builder condition that only works on desktop?

1

There are 1 best solutions below

0
On

something like this init

import 'dart:io';


if(Platform.isWindows || Platform.isMacOS || Platform.isLinux){

//do some desktop stuff

}