I have two designs, the first for mobile devices and the second for iPad. I built a class to do that.
My question is: does this class serve the purpose or need to be modified? Does the iPad size start from 768?
Note: I do not want to use external packages
import 'package:flutter/material.dart';
class ResponsiveBuilder extends StatelessWidget {
final Widget mobileWidget;
final Widget? iPadWidget;
const ResponsiveBuilder({super.key, required this.mobileWidget, this.iPadWidget});
@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
if (constraints.maxWidth >= 768) {
return iPadWidget ?? mobileWidget;
} else {
return mobileWidget;
}
},
);
}
}
2
Answers
It’s a general question that does not have the right answer – it depends on your business needs and use cases. By doing minimal research, I noticed some different values:
Source 1:
Source 2:
Source 3:
Based on the sources, the provided value of
768px
seems okay-ish but I would recommend playing around with different values and your UI to see what specific value makes more sense for your layout to be updated (to "break").I prefer you to use this class to Make your App Responsive both for Mobile,Ipad
And This is the Method how to Call This class On Another class: