Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import multiple Dart files in the same folder

Tags:

flutter

dart

As the question is self-explaining, assume in the folder I have multiple Dart file. Instead of importing file by file (for example import 'screens/screen_1.dart'; import 'screens/screen_2.dart';...), I want to batch import (such as import 'screens/*.dart') but it doesn't work.

Do you know Dart allows us to do such batch import?

like image 472
anticafe Avatar asked Dec 05 '22 10:12

anticafe


1 Answers

Dart imports don't support importing multiple files at once.

What you can do is creating a library that exports other libraries

screens.dart

export 'screens/screen_1.dart';
export 'screens/screen_2.dart';
export 'screens/screen_3.dart';

foo.dart

import 'screens.dart';
like image 72
Günter Zöchbauer Avatar answered Jan 11 '23 03:01

Günter Zöchbauer