You should be able to reshare the majority of your code without different projects.
This is the beauty of widgets and of MediaQuery.
Create all your main components in widgets, your list of items can be ItemList();, the main menu can be MainDrawer();, etc.
For widgets that are meant for differing screen sizes, in your layout builder you can either return LargeScreenWidget() or SmallScreenWidget().
Use either a LayoutBuilder or OrientationBuilder, and write the code to respond to changes in screen size, width and orientation. This way it can share most of the same code.
When you return your layout builder, follow the general pseudo code:
isLargeScreen
? return Row(children[LeftWidget(), RightWidget()])
: return SingleChildScrollView(child: MobileWidget());
If somebody has a very small Chrome window on Desktop, it can switch to the mobile layout this way.
Just as a tidbit, I almost always start my code with the following so I can adapt the layout.
var size = MediaQuery.of(context).size;
var isLargeScreen = false;
if (MediaQuery.of(context).size.width > 900) {
isLargeScreen = true;
} else {
isLargeScreen = false;
}
This way when I am building a widget I can do like the following:
Container(
constraints: BoxConstraints(maxWidth: (isLargeScreen ? 700 : size.width * 0.9)),
),
You can also ask the user which operating system they are using with Platform.isIOS/isWindows/isAndroid.
EX:
onTap: () {
Navigator.push(context, MaterialPageRoute(
builder: (context) {
return Platform.isIOS ? AndroidPage() : iOSPage();
},
)); // MaterialPageRoute
},
Or when using a FutureBuilder
return Platform.isIOS ? CupertinoLoading() : CircularProgressIndicator();
On top of this, you can use VoidCallbackMethod with the OrientationBuilder to change the way the app functions.
In the articles I share, if the screen is small, it opens a Navigation route, otherwise it passes the data to a widget on the right side. This is good for a messaging app for example.
Here are some articles to help you out.
Develop A Responsive Layout Of Mobile App With Flutter
Developing for Multiple Screen Sizes and Orientations in Flutter
Of course, ultimately it is up to your project, what you and/or your team desires, and how comfortable you are with file-size/extra if statements running all the time.
However I will add, that at least for the mobile apps, I usually only use one project. Web/desktop may be a different project.
Happy fluttering!