@override Widget build(BuildContext context) { final Size _size = MediaQuery.of(context).size; // If our width is more than 1100 then we consider it a desktop if (_size.width >= 1100) { return desktop; } // If width it less then 1100 and more then 850 we consider it as tablet elseif (_size.width >= 850 && tablet != null) { return tablet; } // Or less then that we called it mobile else { return mobile; } } }
classMainScreenextendsStatelessWidget{ @override Widget build(BuildContext context) { return Scaffold( key: context.read<MenuController>().scaffoldKey, drawer: SideMenu(), body: SafeArea( child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ // We want this side menu only for large screen if (Responsive.isDesktop(context)) Expanded( // default flex = 1 // and it takes 1/6 part of the screen child: SideMenu(), ), Expanded( // It takes 5/6 part of the screen flex: 5, child: DashboardScreen(), ), ], ), ), ); } }
classDashboardScreenextendsStatelessWidget{ @override Widget build(BuildContext context) { return SafeArea( child: SingleChildScrollView( padding: EdgeInsets.all(defaultPadding), child: Column( children: [ Header(), SizedBox(height: defaultPadding), Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded( flex: 5, child: Column( children: [ MyFiels(), SizedBox(height: defaultPadding), RecentFiles(), if (Responsive.isMobile(context)) SizedBox(height: defaultPadding), if (Responsive.isMobile(context)) StarageDetails(), ], ), ), if (!Responsive.isMobile(context)) SizedBox(width: defaultPadding), // On Mobile means if the screen is less than 850 we dont want to show it if (!Responsive.isMobile(context)) Expanded( flex: 2, child: StarageDetails(), ), ], ) ], ), ), ); } }