Giter Site home page Giter Site logo

nash0x7e2 / awesome-flutter-snippets Goto Github PK

View Code? Open in Web Editor NEW
157.0 157.0 72.0 411 KB

Awesome Flutter Snippets is a collection snippets and shortcuts for commonly used Flutter functions and classes

Home Page: https://marketplace.visualstudio.com/items?itemName=Nash.awesome-flutter-snippets

License: Apache License 2.0

dartlang flutter snippets-collection vscode vscode-snippets

awesome-flutter-snippets's People

Contributors

aaabramenko avatar arthurdenner avatar ascenio avatar biplab-dutta avatar brutalcoding avatar eligt avatar ianwith avatar javilledo avatar joaopedrocoelho avatar josealvaradoo avatar kabagouda avatar leonardorosaa avatar leoshusar avatar marcossevilla avatar nash0x7e2 avatar ninghao avatar rubensdemelo avatar runexes avatar sinadarvi avatar sultanic avatar tahatesser avatar taym95 avatar timilehinjegede avatar tnorbury avatar vinayakvivek avatar zfinix avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

awesome-flutter-snippets's Issues

Bug : Exception in plugin Flutter Snippets 1.3.4

I'm getting a crash every time I start Android Studio

IDE version :

image

Plugin version

image

And I have flutter V3

Here's the log stack trace :

com.intellij.diagnostic.PluginException: Cannot create extension (class=FlutterContext) [Plugin: com.gionchat] at com.intellij.serviceContainer.ComponentManagerImpl.createError(ComponentManagerImpl.kt:932) at com.intellij.openapi.extensions.impl.XmlExtensionAdapter.createInstance(XmlExtensionAdapter.java:88) at com.intellij.openapi.extensions.impl.ExtensionPointImpl.processAdapter(ExtensionPointImpl.java:486) at com.intellij.openapi.extensions.impl.ExtensionPointImpl.processAdapters(ExtensionPointImpl.java:434) at com.intellij.openapi.extensions.impl.ExtensionPointImpl.calcExtensionList(ExtensionPointImpl.java:241) at com.intellij.openapi.extensions.impl.ExtensionPointImpl.getExtensionList(ExtensionPointImpl.java:235) at com.intellij.codeInsight.template.impl.TemplateContextTypes.getAllContextTypes(TemplateContextTypes.java:20) at com.intellij.codeInsight.template.impl.TemplateContext$1.compute(TemplateContext.java:51) at com.intellij.codeInsight.template.impl.TemplateContext$1.compute(TemplateContext.java:31) at com.intellij.openapi.util.ClearableLazyValue.getValue(ClearableLazyValue.java:39) at com.intellij.codeInsight.template.impl.TemplateContext.readTemplateContext(TemplateContext.java:105) at com.intellij.codeInsight.template.impl.TemplateSettings.readTemplateFromElement(TemplateSettings.java:713) at com.intellij.codeInsight.template.impl.TemplateSettings.parseTemplateGroup(TemplateSettings.java:614) at com.intellij.codeInsight.template.impl.TemplateSettings$1.readScheme(TemplateSettings.java:199) at com.intellij.codeInsight.template.impl.TemplateSettings$1.readScheme(TemplateSettings.java:195) at com.intellij.configurationStore.schemeManager.SchemeLoader.loadScheme(schemeLoader.kt:187) at com.intellij.configurationStore.schemeManager.SchemeManagerImpl.loadSchemes(SchemeManagerImpl.kt:236) at com.intellij.codeInsight.template.impl.TemplateSettings.<init>(TemplateSettings.java:278) at com.intellij.codeInsight.template.impl.TemplateSettings.<init>(TemplateSettings.java:190) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) at com.intellij.serviceContainer.ConstructorInjectionKt.instantiateUsingPicoContainer(constructorInjection.kt:47) at com.intellij.serviceContainer.ComponentManagerImpl.instantiateClassWithConstructorInjection(ComponentManagerImpl.kt:877) at com.intellij.serviceContainer.ServiceComponentAdapter.createAndInitialize(ServiceComponentAdapter.kt:48) at com.intellij.serviceContainer.ServiceComponentAdapter.access$createAndInitialize(ServiceComponentAdapter.kt:12) at com.intellij.serviceContainer.ServiceComponentAdapter$doCreateInstance$1.run(ServiceComponentAdapter.kt:42) at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:705) at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:647) at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:63) at com.intellij.openapi.progress.impl.CoreProgressManager.executeNonCancelableSection(CoreProgressManager.java:223) at com.intellij.serviceContainer.ServiceComponentAdapter.doCreateInstance(ServiceComponentAdapter.kt:41) at com.intellij.serviceContainer.BaseComponentAdapter.getInstanceUncached(BaseComponentAdapter.kt:113) at com.intellij.serviceContainer.BaseComponentAdapter.getInstance(BaseComponentAdapter.kt:67) at com.intellij.serviceContainer.BaseComponentAdapter.getInstance$default(BaseComponentAdapter.kt:60) at com.intellij.serviceContainer.ComponentManagerImpl.doGetService(ComponentManagerImpl.kt:590) at com.intellij.serviceContainer.ComponentManagerImpl.getService(ComponentManagerImpl.kt:573) at com.intellij.openapi.client.ClientAwareComponentManager.getFromSelfOrCurrentSession(ClientAwareComponentManager.kt:37) at com.intellij.openapi.client.ClientAwareComponentManager.getService(ClientAwareComponentManager.kt:22) at com.intellij.codeInsight.template.impl.TemplateSettings.getInstance(TemplateSettings.java:302) at com.intellij.codeInsight.template.impl.LiveTemplatesOptionsTopHitProvider.getOptions(LiveTemplatesOptionsTopHitProvider.java:24) at com.intellij.ide.ui.TopHitCache.lambda$getCachedOptions$0(TopHitCache.java:66) at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1705) at com.intellij.ide.ui.TopHitCache.getCachedOptions(TopHitCache.java:58) at com.intellij.ide.ui.OptionsTopHitProvider.getCachedOptions(OptionsTopHitProvider.java:53) at com.intellij.ide.ui.OptionsTopHitProvider$Activity.lambda$cacheAll$1(OptionsTopHitProvider.java:200) at com.intellij.openapi.extensions.impl.ExtensionPointImpl.processWithPluginDescriptor(ExtensionPointImpl.java:293) at com.intellij.openapi.extensions.ExtensionPointName.processWithPluginDescriptor(ExtensionPointName.java:156) at com.intellij.ide.ui.OptionsTopHitProvider$Activity.cacheAll(OptionsTopHitProvider.java:196) at com.intellij.ide.ui.OptionsTopHitProvider$Activity.preload(OptionsTopHitProvider.java:177) at com.intellij.idea.ApplicationLoader$executePreloadActivity$1.run(ApplicationLoader.kt:412) at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:705) at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:647) at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:63) at com.intellij.idea.ApplicationLoader.executePreloadActivity(ApplicationLoader.kt:402) at com.intellij.idea.ApplicationLoader.access$executePreloadActivity(ApplicationLoader.kt:1) at com.intellij.idea.ApplicationLoader$executePreloadActivities$2.run(ApplicationLoader.kt:467) at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1426) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020) at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656) at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183) Caused by: java.lang.ClassNotFoundException: FlutterContext PluginClassLoader(plugin=PluginDescriptor(name=Flutter Snippets, id=com.gionchat, descriptorPath=plugin.xml, path=~\AppData\Roaming\Google\AndroidStudio2021.2\plugins\FlutterSnippets.jar, version=1.3.4, package=null), packagePrefix=null, instanceId=48, state=active) at com.intellij.serviceContainer.ComponentManagerImplKt.doLoadClass(ComponentManagerImpl.kt:1489) at com.intellij.serviceContainer.ComponentManagerImplKt.access$doLoadClass(ComponentManagerImpl.kt:1) at com.intellij.serviceContainer.ComponentManagerImpl.loadClass(ComponentManagerImpl.kt:821) at com.intellij.openapi.extensions.impl.InterfaceExtensionImplementationClassResolver.resolveImplementationClass(InterfaceExtensionImplementationClassResolver.java:25) at com.intellij.openapi.extensions.impl.XmlExtensionAdapter.createInstance(XmlExtensionAdapter.java:65) ... 62 more

Snippets missing from autocomplete

My flutter snippets have disappeared from the autocomplete pop-up. For example, if I create a new dart file, and want to import the material.dart package, I type 'import'. I used to then get an autocomplete with the 'importm' snippet being one of the options. Currently I only get the 'import' snippet:

image

However, when I hit Ctrl+Shft+P and select Insert Snippet, then 'importm' is one of the options:

image

I have tried uninstalling and reinstalling the Awesome Flutter Snippets extension.

This may be unrelated to this extension and purely be a VSCode issue, but I'm currently experiencing the issue with flutter snippets.

[Feature Request] Auto Imports along with Snippets

First, thanks for creating these snippets. Being able to leverage modern conveniences like this makes using vim (neovim, in my case) extremely feasible, which is great because it's my favorite coding editor.

The context for this request is the following: When using coc.nvim, the standard completion suggestion for something like StatelessWidget includes the automatic import '...' line at the top of the file, if it doesn't exist. This is not only helpful so I don't have to remember where the import comes from and type it out myself, but it also prevents a lot of errors from appearing since the system won't be confused as to where from StatelessWidget comes.

When using awesome-flutter-snippets however, the automatic import is not done, which throws a lot of errors until I go add it in.

This is not a big deal, and I can imagine that it could be hard for a snippets engine to know if the import is already done or not, but I wanted to mention that it would be nice to have a single completion take care of the snippet as well as any necessary imports.

But I'm not sure where the functionality lies between coc.nvim and these snippets, so I don't know what the feasibility is of having something like this work.

Thanks for reading!

snippets code is not right

image

class name extends StatefulWidget {
  const name({Key? key}):super(key: key);

  @override
  State<name> createState() => _nameState();
}

class _nameState extends State<name> {
  @override
  Widget build(BuildContext context) {
    return Container();
  }
}

Compatible with VI Mode

I'm happy to use awesome-flutter-snippets. Thank you

Here is my problem.
1 Input "statefuW", then I got the snippets. That's awesome!
befor_delete
)

2 But after I tap "Delete" key, the snippets got wrong.
If I move cursor first,then press ”Delete“, this problem won't happen.
after_delete

3 My environment:

  • macOS Catalina
  • Visual Studio Code 1.44.2 , vim plugin version 1.13.1

I hope this problem to be fixed. Thanks a lot!

On initiating widgets

Can you change that when on initializing stateful or stateless widget, on widget container there is no "child" word? Every time i use this snippet it underscores red and it's so tilting to me. Maybe it's personal thing, but still - there is no reason for that " child" word to be there. And every time i see that underscoring i have to urge to immediately delete that line. Thanks.

Generate null-safe code

Currently snippets are generating legacy non null-safe code.

Expected behavior

Snippets are generating null-safe code.

Add Null Safety support

Description

Hi, recently I've migrated to the latest version of Flutter which is currently 2.0.3.. which also supports Null Safety.
And few little issues I found while using this snippets (which are great btw), is that it doesn't support null safety features
for example if I use the snippet "statelessW" it will add the following

class WidgetTest extends StatelessWidget {
  const WidgetTest({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container();
  }
}

but, since all Null Safety features are enabled, the Key property should be nullable (marked with '?').. like this

class WidgetTest extends StatelessWidget {
  const WidgetTest({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container();
  }
}

I didn't tried all the snippets if they may have the same issue, but it would be awesome if you add this features to it.

Suggestions

  • you could add an option in the settings whether to enable null safe or not.
  • you could add 2 separate snippets one for null safe and one for non-null safe.
  • or something else

Missing @override annotation in statefulW

When I convert a stateless widget to a stateful Widget, an @override annotation is added on createState:
image

image

But when creating a stateful Widget using the "statefulW" template no @override annotation is added on createState:
image

image

For consistency, the @OverRide annotation should also be added by the snippet since Dart Code adds it.

Stateful and Statless Widget

Hi,

You removed Stateful and Statless Widget from this library because Dart Code has them. How to access them? I don't see anything similar in their documentation.

Thanks,
Adrian

update snippets to flutter 3

currently the snippets don't seem to leverage flutter 3 features

e.g.:statelessW

  • expected result
class name extends StatelessWidget {
  const name({super.key});

  @override
  Widget build(BuildContext context) {
    return Container();
  }
}
  • actual result
class name extends StatelessWidget {
  const name({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container();
  }
}

typo: oriantationBldr

One of the snippets is named "oriantationBldr". It should be "orientationBldr" (it creates an OrientationBuilder)

Support with old Flutter versions

I jump back and forth between new Flutter SDKs and projects with old SDKs regularly. Is it possible to add in a check for the Flutter SDK of the current project?

If project SDK > 2.0, use null safety json, otherwise use the old snippets.json

The fix for now is to go into the extension and manually switch the version back and forth, but it can be cumbersome if done regularly.

How do one use this extension?!

Hi,

The readme is missing one little and very important note, how to use this extension.
I've downloaded and installed it on my Visual Studio code, but I have not discovered the way to use it...

Thank you,
Yaniv

Config file

Maybe creating possible edits on snippets through the config file would be interesting.

Looking over #41 and my own experience using the use_super_parameters linter on my projects, for example, I would like to be able to use the statelessW and statefulW with the constructors starting with Name({super.key}).

Maybe adding the comma at the end by default on the constructors, making them const, removing BuildContext from the builder
at StatefulBuilder snippet (as suggested by avoid_types_on_closure_parameters linter), or any of these little changes.

And for the #41 maybe a property where you set whether this project uses null-safety or not.

Maybe even change the "always Container" rule for something like a const SizedBox.shrink() or something else chosen by the project owners.

404 Not Found

Hi, I tried to install this plugin but it is not showing up in the plugin store. In the marketplace section the 404 error is displayed. What's happening? Thanks for sharing knowledge.

imports missing from statelessW

There is no import 'package:flutter/material.dart'; inside the snippet, leaving us to add missing import manually.

Added, Pull Request:
#60

(this is my first PR on GitHub, apologies for mistakes)

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.