How to import all Dart files from a Directory?

You can create a file in the screens directory and call it all.dart or whatever you like. In this file, you will simply export all of the Dart files in that folder:

export 'homepage.dart';
export 'aboutTheApp.dart';
export 'upcomingEvents.dart';

Now, whenever you want to use any file from that folder, you can just import all.dart or what you called it:

import 'screens/all.dart`;

...

Other than that, there is no possibility to import a directory.


Create directory alert_view and add your all file as shown in the image below

Create directory

And create a all_alert.dart file in the alert_view directory, after export all of the your Dart files in the all_alert.dart files like this:

export 'alert.dart';
export 'alert_style.dart';
export 'animation_transition.dart';
export 'constants.dart';
export 'dialog_button.dart';

Now, where you have to use alert_view's files, there only import this one file.

import 'package:gateinn/library/alert_view/all_alert.dart';

No, there is no simpler way.

Dart do not offer a directory import.