Flutter - Packages and Imports

Packages and Imports Files can reference each other with standard paths following the package name. Assuming the following structure flutter_my_demo - pubpsec.yaml (name: flutter_my_demo) - lib/ - main.dart - screens/ - homepage/ homepage.dart You can access the homepage dart file with: import 'package:flutter_my_demo/screens/homepage/homepage.dart'; or with relative paths (including ../.. syntax) import 'screens/homepage/homepage.dart'; [[../../../_notes/code/Flutter|Back to Flutter]]

Table Of Contents

Packages and Imports

Files can reference each other with standard paths following the package name.

Assuming the following structure

flutter_my_demo
- pubpsec.yaml (name: flutter_my_demo)
- lib/
    - main.dart
    - screens/
        - homepage/
            homepage.dart

You can access the homepage dart file with:

import 'package:flutter_my_demo/screens/homepage/homepage.dart'; or with relative paths (including ../.. syntax) import 'screens/homepage/homepage.dart';

[[../../../_notes/code/Flutter|Back to Flutter]]