Flutter: Difference between revisions

imported>Jmarmstrong1207
Add emulator section
imported from old wiki (The second flake example doesn't work because it uses a variable androidSdk which is defined in the flake before it, but not the second one)
 
(4 intermediate revisions by 4 users not shown)
Line 5: Line 5:
== Development ==
== Development ==


The easiest way is to install Android Studio by adding <code>pkgs.androidstudio</code> to your list of packages in configuration.nix.
=== Linux desktop/Web ===
 
To build Flutter apps to Linux desktop or Web you only need the <code>flutter</code> package from Nixpkgs.
Then run <code>flutter build linux</code> or <code>flutter build web</code>.
 
=== Android ===
 
The easiest way is to install Android Studio by adding <code>pkgs.android-studio</code> to your list of packages in configuration.nix.


If you prefer [[Vscode|VSCode]], you can create a [[Development environment with nix-shell|dev-shell]] with the packages "jdk", "flutter", and a preferred android sdk such as the preconfigured one "androidenv.androidPkgs_9_0.androidsdk" (mentioned in the Android wiki page). Add other packages if missing any. Or you can install Android Studio to get all the Android packages, and install Flutter.
If you prefer [[Vscode|VSCode]], you can create a [[Development environment with nix-shell|dev-shell]] with the packages "jdk", "flutter", and a preferred android sdk such as the preconfigured one "androidenv.androidPkgs_9_0.androidsdk" (mentioned in the Android wiki page). Add other packages if missing any. Or you can install Android Studio to get all the Android packages, and install Flutter.
Line 69: Line 76:
         };
         };
       };
       };
      androidSdk = pkgs.androidenv.androidPkgs_9_0.androidsdk;
     in
     in
     {
     {
Line 76: Line 84:
           buildInputs = [
           buildInputs = [
             flutter
             flutter
             androidenv.androidPkgs_9_0.androidsdk
             androidsdk
             jdk17
             jdk17
           ];
           ];
Line 95: Line 103:


== Emulators ==
== Emulators ==
[[Android|View the Android wiki page for more info]], but you can set up emulators in Android Studio, run them from there, then target the emulator in VSCode when running your flutter code. Otherwise, you can Nixify your emulators as stated in the Android wiki page
[[Android|View the Android wiki page for more info]], but you can set up emulators in Android Studio, run them from there, then target the emulator in VSCode when running your flutter code. Otherwise, you can Nixify or even manually add your emulators as stated in the Android wiki page


== Packaging ==
== Packaging ==
Line 104: Line 112:


* The [https://github.com/orgs/NixOS/teams/flutter team working on flutter in nixpkgs] maintains several pieces of infrastructure related to the cause. The documentation is lacking as of now, but there are plans to improve it.
* The [https://github.com/orgs/NixOS/teams/flutter team working on flutter in nixpkgs] maintains several pieces of infrastructure related to the cause. The documentation is lacking as of now, but there are plans to improve it.
[[Category: Development]]