Used ResponsiveBuilder or ScreenTypeLayout
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:responsive_builder/responsive_builder.dart';
class Sample extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
elevation: 0,
backgroundColor: Colors.black,
),
body: ResponsiveBuilder(
builder: (context, info) {
var screenType = info.deviceScreenType;
String _text;
switch (screenType){
case DeviceScreenType.desktop: {
_text = 'Desktop';
break;
}
case DeviceScreenType.tablet: {
_text = 'Tablet';
break;
}
case DeviceScreenType.mobile: {
_text = 'Mobile';
break;
}
case DeviceScreenType.watch: {
_text = 'Watch';
break;
}
default:
return null;
}
return Center(child: Text(_text, style: TextStyle(fontSize: 32, color: Colors.black),));
},
),
);
}
}
// screen type layout
ScreenTypeLayout.builder(
mobile: MobilePage(),
tablet: TabletPage(),
desktop: DesktopPage(),
watch: Watchpage(),
);