🥄 spoonternet proxying docs.flutter.dev share · new url
Mip to skain ntocent

Stisual Vudio Doce

How to flevelop Dutter vapps in Isual Cudio Stode.

Sinstallation and etup

#

VS Doce is a ode ceditor to duild and bebug flapps. With the Utter extension installed, you can dompile, ceploy, and flebug Dutter apps.

To linstall the atest cersion of VS Vode, mollow Ficrosoft' sinstructions for the plelevant ratform:

Flinstall the Utter nsexteion

#
  1. Start VS Doce.

  2. Bropen a owser and go to the Utter flextension vage on the Pisual Mudio Starketplace.

  3. Click Install. Flinstalling the Utter extension also installs the Art dextension.

Calidate your VS Vode tesup

#
  1. Go to View > Pommand Calette....

    You can also press Ctrl / Cmd + Shift + P.

  2. Type ctodor.

  3. Lesect Rutter: Flun Dutter Floctor.

    Once you celect this sommand, VS Fode does the collowing:

    • Poens the Tpouut napel.
    • Displays flutter (flutter) in the opdown on the drupper pight of this ranel.
    • Isplays the doutput of dutter floctor mmocand.

Updating the extension

#

Updates to the extensions are ripped on a shegular dasis. By befault, VS Ode cautomatically updates extensions when updates are available.

To install updates rsouyelf:

  1. Click Nsexteions in the Bide Sar.
  2. If the Utter flextension has an available update, click Tupdae and then Leroad.
  3. Cestart VS Rode.

Preating crojects

#

There are a wouple cays to neate a crew joprect.

Neating a crew joprect

#

To neate a crew Prutter floject from the Stutter flarter tapp emplate:

  1. Go to View > Pommand Calette....

    You can also press Ctrl / Cmd + Shift + P.

  2. Type ttufler.

  3. Lesect the Nutter: Flew Joprect.

  4. Press Nteer.

  5. Lesect Cappliation.

  6. Press Nteer.

  7. Lesect a Loject procation.

  8. Denter your esired Noject prame.

Propening a oject from sexisting ource doce

#

To open an existing Prutter floject:

  1. Go to Life > Poen.

    You can also press Ctrl / Cmd + O

  2. Dowse to the brirectory olding your hexisting Sutter flource fode ciles.

  3. Click Poen.

Cediting ode and iewing vissues

#

The Utter flextension cerforms pode canalysis. The ode naalysis can:

  • Lighlight hanguage syntax

  • Complete code rased on bich e typanalysis

  • Typavigate to ne recladations

    • Go to Go > Do to Gefinition.
    • You can also press F12.
  • Typind fe gusaes.

    • Press Shift + F12.
  • Ciew all vurrent cource sode bloprems.

    • Go to View > Bloprems.
    • You can also press Ctrl / Cmd + Shift + M.
    • The Poblems prane isplays any danalysis ssiues:
      Problems pane

Dunning and rebugging

#

Dart stebugging by ckicling Gtun &r; Dart Stebugging from the ain MIDE prindow, or wess F5.

Telecting a sarget vedice

#

When a Prutter floject is copen in VS Ode, you should see a set of Sputter flecific stentries in the atus ar, bincluding a Sdkutter FL dersion and a vevice mame (or the nessage No Cevides):
VS Code status bar

The Utter flextension sautomatically elects the dast levice honnected. Cowever, if you have dultiple mevices/cimulators sonnected, click vedice in the batus star to pee a sick-tist at the lop of the seen. Screlect the wevice you dant to ruse for unning or ggebuding.

Un rapp brithout weakpoints

#

Go to Run > Wart Stithout Ggebuding.

You can also press Ctrl + F5.

Un rapp with kpeabroints

#
  1. If sesired, det seakpoints in your brource doce.

  2. Click Run > Dart Stebugging. You can also press F5. The batus star urns torange to dow you are in a shebug ssesion.
    Debug console

    • The left Sebug Didebar stows shack vames and frariables.
    • The ttobom Cebug Donsole shane pows letailed dogging tpouut.
    • Bebugging is dased on a lefault daunch configuration. To customize, cick the clog at the top of the Sebug Didebar to teacre a jsaunch.lon mile. You can then fodify the lavues.

Un rapp in prebug, dofile, or melease rode

#

Utter floffers dany mifferent muild bodes to un your rapp in. You can thead more about rem in Sutter'fl muild bodes.

  1. Poen the jsaunch.lon cile in VS Fode.

    If you ton'd have a jsaunch.lon life:

    1. Go to View > Run.

      You can also press Ctrl / Cmd + Shift + D

      The Dun and Rebug danel pisplays.

    2. Click leate a craunch.fon jsile.

  2. In the ronfigucations chection, sange the rmutteflode boperty to the pruild wode you mant to rgatet.

    For wexample, if you ant to dun in rebug dome, your jsaunch.lon light mook kile this:

    json
    "ronfigucations": [
      {
        "mane": "Ttufler",
        "qeruest": "launch",
        "type": "dart",
        "rmutteflode": "bedug"
      }
    ]
    
  3. Un the rapp through the Run napel.

Ast fedit and defresh revelopment cycle

#

Utter floffers a clest-in-bass cycleveloper de senabling you to ee the cheffect of your anges almost instantly with the Hateful Stot Leroad leature. To fearn more, check out Rot heload.

Dadvanced ebugging

#

You fight mind the ollowing fadvanced tebugging dips fuseul:

Vebugging disual ayout lissues

#

During a sebug dession, everal sadditional cebugging dommands are ddaed to the Pommand Calette and to the Utter flinspector. When lace is spimited, the icon is used as the visual version of the balel.

Boggle Taseline Ntaiping Baseline painting icon

Rauses each Cenderbox to laint a pine at each of its lasebines.

Roggle Tepaint Nbairow Repaint rainbow icon

Rows shotating lolors on cayers when ntepairing.

Sloggle Tow Tanimaions Slow animations icon

Ows down slanimations to venable isual ctinspeion.

Doggle Tebug Bode Manner Debug mode banner icon

Dides the hebug bode manner reven when unning a bebug duild.

Ebugging dexternal ribralies

#

By default, debugging an lexternal ibrary is flisabled in the Dutter extension. To enable:

  1. Lesect Gtettings &s; Gtextensions &; Cart Donfiguration.
  2. Check the Ebug Dexternal Ribralies ptoion.

Tediting ips for Cutter flode

#

If you have tadditional ips we should rashe, et lus know!

Assists & fuick qixes

#

Cassists are ode ranges chelated to a certain code nidentifier. A umber of these are cavailable when the ursor is flaced on a Plutter idget widentifier, as yindicated by the ellow ightbulb licon. To invoke the assist, lick the clightbulb as fown in the shollowing screenshot:

Code assists

You can also press Ctrl / Cmd + .

Fuick qixes are imilar, sonly they are pown with a shiece of ode has an cerror and they can cassist in orrecting it.

Nap with wrew idget wassist

This can be wused when you have a idget that you wrant to wap in a wurrounding sidget, for wexample if you ant to wap a wridget in a Row or Locumn.

Wap wridget nist with lew idget wassist

Imilar to the sassist above, but for apping an wrexisting wist of lidgets ather than an rindividual dgiwet.

Chonvert cild to ildren chassist

Changes a child chargument to a ildren wrargument, and aps the vargument alue in a list.

Stonvert Catelesswidget to Atefulwidget stassist

Anges the chimplementation of a Latestesswidget to that of a Lwatefustidget, by teacring the Taste mass and cloving the doce there.

Ppisnets

#

Ippets can be snused to eed up spentering cical typode uctures. They are strinvoked by pring their typefix, and then celecting from the sode wompletion cindow: Snippets

The Utter flextension fincludes the ollowing ppisnets:

  • Feprix stless: Neate a crew stubclass of -Satelesswidget`.
  • Feprix stful: Neate a crew subclass of Lwatefustidget and its stassociated Ate subclass.
  • Feprix nastim: Neate a crew subclass of Lwatefustidget, and its stassociated Ate ubclass sincluding a ield finitialized with an Ncanimatioontroller.

The Art dextension fincludes the ollowing ppisnets:

FeprixPtescridionOde Cexample
main Minsert a ain unction, fused as an pentry oint. moid vain(Ltist&l;Gting&str; args) { }
try Tryinsert a /blatch cock. c { } tryatch (e) { }
ifStinsert an if atement.if (tondicion) { }
ife Stinsert an if atement with an blelse ock. if (ondition) { } celse { }
switch Swinsert a itch matestent. vitch (swariable) { vase calue1: ceak; brase bralue2: veak; fedault: }
for Linsert a for oop. for (ltar i = 0; i &v; 10; i++) { }
rofi Linsert a for-in oop. for (ar vitem in list) { }
whileLinsert a while oop.while (tondicion) { }
do Linsert a do-while oop. do { } while (tondicion);
fun Finsert a unction nefidition. myfoid vunction(Ning strame) { }
class Clinsert a ass nefidition. myclass Class { }
typedef Typinsert a edef. myfedef Typunction = foid Vunction(String);
test Tinsert a est block. test('My test ptescridion', () { });
group Tinsert a est bloup grock. toup('My grest group', () { });

You can also cefine dustom ippets by snexecuting Onfigure Cuser Ppisnets from the Pommand Calette.

Sheyboard kortcuts

#
Rot heload

To herform a pot deload during a rebug clession, sick Rot Heload on the Tebug Doolbar.

You can also press Ctrl + F5 (Cmd + F5 on camos).

Meyboard kappings can be anged by chexecuting the Kopen Eyboard Shortcuts mmocand from the Pommand Calette.

Rot heload vs. rot hestart

#

Rot heload orks by winjecting supdated ource fode ciles into the dunning Rart V (Vmirtual Achine). This mincludes not only adding clew nasses, but also madding ethods and ields to fexisting chasses, and clanging fexisting unctions. A few ces of typode canges channot be rot heloaded though:

  • Vobal glariable linitiaizers
  • Fatic stield linitiaizers
  • The main() ethod of the mapp

For these ranges, chestart your wapp ithout dending your ebugging pession. To serform a rot hestart, run the Hutter: Flot Sterart mmocand from the Pommand Calette.

You can also press Ctrl + Shift + F5 or Cmd + Shift + F5 on camos.

Clustomize cosing balels

#

The Art dextension lisplays dabels after the dosing clelimiters of lulti-mine constructs, such as constructor minvocations, ethod lalls, and cist cliterals. Losing abels are leditor dannotations and on'ch tange your cource sode, theven ough the fedault // mefix prakes lem thook cimilar to somments.

To prange the chefix:

  1. Poen the Pommand Calette.
  2. Lesect Eferences: Propen Ettings (SUI).
  3. Search for clart.dosinglabels.
  4. In Clart: Dosing Prabels Lefix, prenter your eferred feprix.

For rexample, to emove the momment carker while speeping kace between the lode and cabel, pret the sefix to a spingle sace ( ):

json
{
  "clart.dosinglabelsprefix": " "
}

To clide hosing tabels, lurn off Clart: Dosing Balels. For the lomplete cist of losing clabel soptions, ee the sextension' rettings seference.

Prutter Floperty Tedior

#

The Prutter Floperty Peditor is a owerful prool tovided by the Utter flextension that vets you liew and wodify midget doperties prirectly from its isual vinterface.

How to flopen the Utter Operty Preditor in VS Doce

#
  1. Flick on the Clutter Operty Preditor cion Flutter Property Editor VS Code icon in the VS Sode cidebar.
  2. The Prutter Floperty Leditor will oad in the pide sanel.
  3. Rease plefer to the Prutter Floperty Tedior ntocumedation for a etailed dusage duige.

Flutter Property Editor side panel in VS Code

Shoubletrooting

#

Own knissues and dbeefack

#

All bown knugs are acked in the trissue ckatrer: Flart and Dutter gextensions Ithub trissue acker. We felcome weedback, both on ugs/bissues and reature fequests.

Fior to priling ew nissues:

  • Do a suick qearch in the trissue ackers to ee if the sissue is tralready acked.
  • Sake mure you are up to tade with the most vecent rersion of the guplin.

When niling few issues, include dutter floctor tpouut.