How To Run A Flutter App on Raspberry Pi 4 - Three of Three

preview_player
Показать описание
All videos are in 4K so you may need to change your YouTube Quality settings to 1080p HD if the screen details are blurry.

This is part three of the series about how to install and run flutter apps on a Raspberry Pi 4 with 2G of Ram. This video shows you how to build and run your test project in the terminal using command line instructions.
Timeline:
0:00 to 0:23 Introduction.
0:24 to 0:31 Flutter clean.
0:32 to 0:51 Flutter pub get - this refreshes the dependencies needed for the project.
0:57 to 8:13 flutter build linux --target-platform linux-arm64 - v. This command will build the project on the Raspberry Pi Arm controller (must have 64 bit Debian Linux). It will take about 8 minutes to build the test project on a Raspberry Pi 4 with 2G of ram.
8:14 to 8:30 go back to your root directory of your Flutter project.
8:31 to 9:35 flutter run --release - v. This will run the Flutter test project on the Raspberry pi 4.
9:36 to 9:53 wrap up and end.

How to setup Flutter, VS Code and run the Flutter default test application on a Raspberry Pi 4 with 2G of ram.

Step 1. Using the Raspberry Pi imager, select the Debian 11 Bullseye 64 bit and install on the Raspberry Pi with at least 2G of ram. Does not work on the default Linux 32 bit distribution.

Step 7. After this project is setup DO NOT try to build, run it or debug it in the VS Code IDE. Not sure why but it hangs up - may be due to lack of memory.

Step 8. Close VS Code, find your developer directory for the test project, open it up in terminal. At the command line: run flutter clean and then flutter pub get and in that order. Not necessary but does some house cleaning avoid issues . . .

Step 9. In the terminal window, assuming you are in the Flutter example starter project root directory, type in this command:

flutter build linux --target-platform linux-arm64 -v

Step 10. the -v allows verbose logging so you can see if it hangs up. I get a random hang at when it runs the ninja build. If it hangs up there then try updating ninja.

Step 11. You will need to use one of the various Linux keystrokes (ALT with Print Screen key and then O) to get out of a crash if it hangs up at the ninja step. After a reboot and do step 12.

Step 12. Update ninja: sudo apt-get update and then sudo apt-get install ninja-build. You may need to uninstall and reinstall.

Step 13. Again DO NOT build in VS Code terminal - for some reason, probably lack of memory, the system will hang at the ninja build step.

Step 14. After you have a successful build (at the command line and not in VS Cod): navigate over from your project directory to build/linux/arm64/release/bundle and you will find the flutter application build (the default name is flutter_application_1 or whatever name you gave the project).

Step 15. You can use ./ and the file name to run the app from the command line or you can use the desktop and double click and run that way.

Step 16. I have run the app successfully - next steps - install the GPIO packages and write an app to flash and LED!

Note that if I use terminal to build and run it seems fairly stable.
Рекомендации по теме
Комментарии
Автор

This was an impressive series of videos 👍😁 thank you for that. Is it also possible to use camera control commands from the libcamera app in Flutter?

marco_di
Автор

Hello thank you for tutorial. Is it possible to run just bundles without rest of the project? For that what would we need to install on fresh pi os?

Sravdar
Автор

not working

dk_window_get_state: assertion 'GDK_IS_WINDOW (window)' failed
[ +43 ms] ** (flutterpi:8716): WARNING **: Failed to start
Flutter renderer: No available configurations for the given pixel format

mauricioposadas
welcome to shbcf.ru