Coder Social home page Coder Social logo

snapp-x / snapp_cli Goto Github PK

View Code? Open in Web Editor NEW
20.0 4.0 3.0 1.75 MB

Dart CLI for Remote Flutter Development. Easily set up and remotely debug Flutter apps on Raspberry Pi and other devices. Snapp CLI automates configuration, supporting custom embedders like Flutter-pi.

Home Page: https://pub.dev/packages/snapp_cli

License: BSD 3-Clause "New" or "Revised" License

Dart 100.00%
flutter raspberry-pi embedded-systems snapp-embedded dart-cli flutter-pi remote-debugging

snapp_cli's Introduction

snapp_cli Pub Version

Power Up Your Raspberry Pi for Flutter

Styles

What is snapp_cli?

Imagine You have a Raspberry Pi sitting on your desk or tucked away in a drawer, collecting dust. You bought it with grand ideas of developing Flutter apps on it, but the thought of setting it up for development has always seemed too complicated. Now, picture a tool that makes this process simple and effortless – that’s snapp_cli. πŸš€

snapp_cli allows you to control everything from your laptop πŸ’». Here’s how it simplifies your development process:

  1. πŸ”— Effortless Connection: snapp_cli sets up a secure, passwordless SSH link from your laptop to your Raspberry Pi, so you can manage it without direct interaction.

  2. πŸ”§ Automated Installation: snapp_cli automates the installation of Flutter and all necessary dependencies on your Raspberry Pi. You run snapp_cli from your laptop, and it handles everything remotely. But that's not all – snapp_cli also supports custom embedders like Flutter-pi.

  3. βš™οΈ Custom Device Configuration: snapp_cli configures your Raspberry Pi to appear as a custom device in your IDE. You can easily select it and run your Flutter apps, just like you would on a phone or emulator.

  4. πŸ› οΈ Seamless Remote Development: Develop and debug your Flutter apps directly from your laptop. snapp_cli enables hot reload, restart, and access to DevTools, so you can run and test apps on your Raspberry Pi with all the tools you need for smooth and efficient remote development.

In essence, snapp_cli transforms your idle Raspberry Pi into a powerful Flutter development platform, all managed from your laptop. Whether you're new to Flutter or an experienced developer, snapp_cli makes remote development simple and effective.

Installation

snapp_cli is a Dart-based command-line tool. If you already have Flutter installed on your laptop, getting snapp_cli up and running is quick and easy. Just run the following command in your terminal:

dart pub global activate snapp_cli

Make sure that system cache bin directory is added to your system's PATH to use snapp_cli globally. follow this link for more information: Running a script from your PATH

Usage

Using snapp_cli is straightforward. Once installed, you can use it to set up and manage your Raspberry Pi for Flutter development. Let's start with bootstrap command.

Bootstrap Command

The most important command in snapp_cli is the bootstrap command. This command is interactive and guides you through the entire setup process, making your remote device(Raspberry Pi) ready for Flutter development with minimal effort.

To use the bootstrap command, simply run:

$ snapp_cli bootstrap

Styles

The bootstrap command simplifies the entire setup process for your Raspberry Pi. It prompts for your Raspberry Pi's IP address and username to establish a passwordless SSH connection. You'll then choose a Flutter Embedder (Flutter Desktop, Flutter Pi or ...), and the command checks and installs it along with any necessary dependencies. Finally, it configures your Raspberry Pi as a custom device in the Flutter SDK, allowing you to select and run your Flutter apps on the Raspberry Pi directly from your laptop, enabling seamless remote debugging and development.

Other Commands

snapp_cli includes additional commands to help you manage your devices and SSH connections efficiently:

Styles

The devices command helps you manage your custom devices in the Flutter SDK. With subcommands to add, delete, list, and update the IP addresses of your devices, you have full control over your development environment.

The ssh command assists in establishing and managing secure, passwordless SSH connections to your remote devices. Subcommands are available to create and test SSH connections, making remote access and management straightforward.


Each command has specific options and usage, which you can explore further by running snapp_cli --help or snapp_cli <command> --help.

Troubleshooting

Running Commands in Verbose Mode

If you encounter any issues while using the snapp_cli tool, you can run the commands in verbose mode to obtain more detailed information about the error. To do this, simply add the -v flag to your command. For example:

$ snapp_cli bootstrap -v

SSH Connection Issues

Sometimes, you may face difficulties establishing an SSH connection to a device due to various reasons, such as an incorrect IP address, username, password, or SSH key. To verify whether the SSH connection is functioning correctly, you can execute the snapp_cli ssh test-connection command. If the connection fails, attempt to establish a new connection using the snapp_cli ssh create-connection command.

If you still cannot establish an SSH connection, it may be necessary to review the SSH configurations on both your host (e.g., your PC) and the remote device (e.g., Raspberry Pi).

However, be cautious: if you have any other SSH connections to your remote device or to other devices, using the following commands will remove them.

Host Device - Your PC
  • Clear the .snapp_cli directory:
    rm -r ~/.snapp_cli
  • Clear the known hosts file:
    ssh-keygen -R yourIpAddress
  • Clear the ssh-agent saved keys:
    ssh-add -D
Remote Device - Raspberry Pi

Connect to your remote device via a simple SSH connection:

ssh [username]@[ipAddress]

After successfully connecting to your remote device, remove the .ssh folder that contains the SSH keys:

rm -r ~/.ssh

Notes:

  • Ensure you replace yourIpAddress with the actual IP address of your device.
  • Be explicit about replacing placeholders like username@ipAddress with the appropriate user and IP address for the Raspberry Pi.

Manually Editing flutter_custom_devices.json

In some cases, you may need to manually edit the flutter_custom_devices.json file, which stores the configurations for custom devices. Here are the steps to follow if you encounter this situation:

  1. Locate the flutter_custom_devices.json File:

    • The location of the flutter_custom_devices.json file can vary depending on the operating system you are using. You can find it with the snapp_cli list command.
  2. Backup the File:

    • Before making any manual changes, it's a good practice to create a backup of the flutter_custom_devices.json file in case something goes wrong.
  3. Edit the JSON File:

    • Use a text editor to open the flutter_custom_devices.json file. You can make changes to the device configurations as needed. Ensure that the JSON structure is valid; any syntax errors can cause issues.
  4. Test the Configuration:

    • To test the changed configuration you need to run your app again.

Keep in mind that manually editing the flutter_custom_devices.json file should be done with caution, as incorrect changes can lead to configuration issues. It's recommended to use the CLI tool to add, update, or delete custom devices whenever possible.

Contributing

If you encounter any issues with this package or have suggestions for improvements, please open an issue. You are welcome to contribute to the development of this project by forking the repository and submitting pull requests.

License

This project is licensed under the MIT License

snapp_cli's People

Contributors

m-theis avatar payam-zahedi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

snapp_cli's Issues

Problem with elements

Hello, good job, I have one problem, when I run the application on Raspberry I get the following message, the application starts but I can see the appbar and the button, but in the console I have the following information:
Building Linux application...
cp: -r not specified; omitting directory '/tmp/testrpi/snapp_embedded/flutter_assets/fonts'
cp: -r not specified; omitting directory '/tmp/testrpi/snapp_embedded/flutter_assets/packages'
cp: -r not specified; omitting directory '/tmp/testrpi/snapp_embedded/flutter_assets/shaders'
cp: -r not specified; omitting directory '/tmp/testrpi/snapp_embedded/flutter_assets/fonts'
cp: -r not specified; omitting directory '/tmp/testrpi/snapp_embedded/flutter_assets/packages'
cp: -r not specified; omitting directory '/tmp/testrpi/snapp_embedded/flutter_assets/shaders'

I run flutter run -d pi-4b directly from my windows device in the powershell terminal in the vs code app

Cannot run the app to Pi 4B

I can list devices

snapp_cli devices list

βœ“  Searching for custom devices completed!

List of custom devices in "C:\Users\enzii\AppData\Roaming\.flutter_custom_devices.json":
  id: pi-5, label: Raspberry Pi 5, enabled: true
  id: pi-4b, label: Raspberry Pi 4 Model B, enabled: true

However, it cannot run an application to Pi 4 on debug mode

 flutter run -d pi-4b
Launching lib\main.dart on Raspberry Pi 4 Model B in debug mode...
Error: No pubspec.yaml file found.
This command should be run from the root of your Flutter project.
cp: target '/tmp/flutter_application_1/build/flutter_assets' is not a directory
cp: target '/tmp/flutter_application_1/build/linux/arm64/debug/bundle/data/flutter_assets' is not a directory
cp: cannot create regular file '/tmp/flutter_application_1/build/linux/arm64/debug/bundle/data': No such file or directory
bash: line 1: /tmp/flutter_application_1/build/linux/arm64/debug/bundle/flutter_application_1: No such file or directory

Version solving failed when trying to activate (Flutter 3.22.2)

Hi,

I'm on:

Flutter 3.22.2
Dart SDK version: 3.4.3

and when trying dart pub global activate snapp_cli, I see:

Note: intl is pinned to version 0.19.0 by flutter_tools from the flutter SDK.
See https://dart.dev/go/sdk-version-pinning for details.

Note: process is pinned to version 5.0.2 by flutter_tools from the flutter SDK.
See https://dart.dev/go/sdk-version-pinning for details.


    Because snapp_cli <0.4.5 depends on process ^4.2.4 and every version of
      flutter_tools from sdk depends on process 5.0.2, snapp_cli <0.4.5 is incompatible
      with flutter_tools from sdk.
(1) So, because every version of snapp_cli depends on flutter_tools from sdk and
      snapp_cli >=0.4.0 depends on interact_cli ^2.3.0, every version of snapp_cli
      requires interact_cli ^2.3.0.

    Because dart_console >=1.2.0 <4.0.0 depends on intl ^0.18.0 and dart_console
      >=1.1.0-pre.0 <1.2.0 depends on intl ^0.17.0, dart_console >=1.1.0-pre.0 <4.0.0
      requires intl ^0.17.0 or ^0.18.0.
    And because every version of interact_cli depends on dart_console ^1.1.2, every
      version of interact_cli requires intl ^0.17.0 or ^0.18.0.
    And because every version of snapp_cli depends on flutter_tools from sdk which
      depends on intl 0.19.0, interact_cli is incompatible with snapp_cli.
    And because every version of snapp_cli requires interact_cli ^2.3.0 (1),
      snapp_cli is forbidden.
    So, because pub global activate depends on snapp_cli any, version solving
      failed.

Create video for flutter-pi user – short version

We want to explain flutter-pi user how easy it is to use it on Raspberry Pi

Structure:

  1. Intro: Short summary what we are going to show in the video
  2. Problem: Why makes it so difficult to use flutter-pi on Raspberry Pi
  3. Solution/Problem solving: How does snapp_cli resolves all the problems and it is to be used
  4. Result: – Created custom device – screen recording from Raspberry Pi running

Improvement: Speed up the sending files to the Remote Device

Presently, we rely on scp, a component of SSH, to transfer application files to remote devices. However, a notable limitation of scp is its inability to selectively filter files for transmission. Rather, it only facilitates the transfer of entire folders.

As a result, we inevitably transmit numerous unnecessary files that exceed our requirements.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.