Home > Software engineering >  How to create apps in different platforms, each of different functionalities with Flutter?
How to create apps in different platforms, each of different functionalities with Flutter?

Time:07-23

I was thinking about creating a small project using Flutter to create a mobile application along with website accessibility. I am quite new to Flutter and wanted to learn more about it. So basically, my application consists of two user targets; teachers and students. I want to allow teachers to be able to create courses ONLY on the website, but students and teachers are allowed to access the mobile application. Teachers can view courses and students can join classes through the app. The reason for only allowing students in the mobile app is that I want to make use of the gyroscope of mobile phones.

Hence, there are some questions that I need help with:

  1. Should I create 2 apps; an independent Flutter Web and an independent mobile app, or pack them together in one app?
  2. If I pack them together, how do I make the above conditions possible? I was thinking about checking the device used and displaying different interfaces on different devices. Is this possible?

Also, I am willing to receive any advice on what is better to implement, or what I could change. Thank you for your time!

CodePudding user response:

  1. You can handle this scenario with a single codebase
  2. To check if user is using web you can use below condition. You can also use a combination of LayoutBuilder and MediaQuery to show responsive UI based on device dimensions.

There are different scenarios which u need to consider while deciding if you should have separate projects.For e.g. If the functionality on the web is completely different, then you can think about 2 app approach.

import 'package:flutter/foundation.dart' show kIsWeb;

if (kIsWeb) {
  // running on the web!
} else {
  // NOT running on the web! You can check for additional platforms here.
}
  • Related