I am new to Flutter and have created a bunch of UI elements as custom widgets so that I can use them throughout my app. It's tiresome to have to remember to include each and every widget import
in a Dart file.
I recently learned that you can export a widget from within another widget, and anything that imports the parent widget has access to everything:
//===================
//=== global.dart ===
//===================
import 'package:flutter/material.dart';
import 'package:myapp/storage.dart';
//Widget exports for convenience
export 'package:myapp/_global/widgets/widget1.dart';
export 'package:myapp/_global/widgets/widget2.dart';
export 'package:myapp/_global/widgets/widget3.dart';
So now in each of my files throughout my project, I just need to do:
import 'package:myapp/global.dart';
...and I have access to widget1
, widget2
, widget3
.
Is there a risk to doing this, such as a performance decrease or something else I can't foresee? It's awfully convenient for development. I'm just trying to make sure I'm not shooting myself in the foot.