skip to Main Content

i dont know, after flutter 3.0.0 update, i can’t use snippet in android studio. maybe i can, but inside a function. i cant easily import material.dart. but i used snippet in it worked (i can use snippet without flutter snipet plugin in android studio before).

this flutter snippet didn’t work inside statefull widget,

enter image description here

but it works inside function.
enter image description here

i can use snippet before finally using flutter snippet plugin, but when i upgrade flutter to 3.0.0, i cant use it. and when i use flutter snippet plugin, i can’t do like @override.
i’ve try updating all the plugin, reinstalling android studio, but it doesn’t work.

any solution ?
i’ve already comfortable making flutter app with android studio, and i actually doesn’t wanted to use vscode to make flutter app..

3

Answers


  1. You need to write in Widget build function. Currently you are in the wrong scope

    Login or Signup to reply.
  2. Same here. So how i solved this issue! I just use Ctrl+O for overriding any method.
    N:B sometimes hints don’t work. so I have to press ESC a couple of times or navigate to another page and come back again.

    Login or Signup to reply.
  3. Me too, after I’ve updated flutter and android studio on my Ubuntu 22 I can’t use initState and setState snippet even I’ve installed snippet plugin. Then I can use it again by changing Live Template setting, but not like before (works on StatefulWidget only). You can follow this steps:

    1. Open File->Settings->Editor->Live Templates->Flutter then click initS
      enter image description here

    2. Click Change button on the bottom and check mark Flutter then click Apply
      enter image description here

    3. Finish, you can use initState snippet now.

    You can add setState or other template you want by clicking + button on top-right and fill all needed.

    Happy coding! 🙂

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search