Canteen Management Frontend
Frontend for our canteen management system.
Built with flutter web.
The QR scanner feature requires https to be enabled (see getUserMedia() and Secure context restrictions).
Structure
See also dart/flutter package layout conventions.
lib/
main application sourcesbuild/
(generated) build artifactsweb/
,android/
,ios/
base files for respective device buildstest/
,integration_test/
test code for widget and integration tests, resp.test_driver/
setup forflutter drive
(integration) tests.idea/
,.circleci/
configuration files for IntelliJ and CircleCI resp.
Building from Source
- Set up flutter (includes the dart SDK)
- clone the repository
- run
flutter build web --web-renderer html
in the project root
The artifact is found in <project root>/build/web/
.
Running and Debugging
IntelliJ/Android Studio
In the flutter toolbar (top right by default), select a device and the main.dart
configuration and press either the Run or Debug button.
To run on other browsers and devices, select the server
configuration and manually connect to <host address>:5000
.
Note: in most modern browsers, camera usage is only allowed in secure contexts (https://...
or localhost
). For debugging purposes, Chrome allows specifying exceptions using chrome://flags/#unsafely-treat-insecure-origin-as-secure
.
Terminal
In the following, replace ...
with --web-renderer html
(the qr_code_scanner package requires the HTML renderer to work in web).
Run flutter run ...
to open a debug view on a supported browser.
Run flutter run -d web-server --web-hostname 0.0.0.0 --web-port 5000 ...
and manually connect to <host address>:5000
.
Running Tests
Widget Tests
Widget tests launch widgets in an optimized test environment.
Run flutter test
(runs all files in test/
)
Integration Tests
Integration tests launch the entire app on a real or emulated device/browser. This is closer to real use than widget tests, but requires more effort to set up and runs slower.
- Download chromedriver
- Run
chromedriver --port=4444
(this is the default port forflutter drive
) - Run
flutter drive --driver=test_driver/integration_test.dart --target=integration_test/demo_test.dart -d web-server
See also Running Flutter Driver tests with Web and the integration_test
example app.