-
-
Notifications
You must be signed in to change notification settings - Fork 130
Adding the dart language #161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
[ | ||
{ | ||
"categoryName": "Basic", | ||
"snippets": [ | ||
{ | ||
"title": "Hello, World!", | ||
"description": "Prints Hello, World! to the terminal.", | ||
"author": "CreeperFarm", | ||
"tags": [ | ||
"printing", | ||
"hello-world" | ||
], | ||
"contributors": [], | ||
"code": "print(\"Hello, World!\"); // Prints Hello, World! to the console\n" | ||
} | ||
] | ||
}, | ||
{ | ||
"categoryName": "Flutter", | ||
"snippets": [ | ||
{ | ||
"title": "Button ElevatedButton", | ||
"description": "Display a button with a border and elevation set automatically", | ||
"author": "CreeperFarm", | ||
"tags": [ | ||
"button", | ||
"flutter", | ||
"widget" | ||
], | ||
"contributors": [], | ||
"code": "ElevatedButton(\n onPressed: () {\n // Do something when the button is pressed\n },\n child: Text('Click me!'),// Display the text Click me!\n) \n\n// If you want a button with an icon\nElevatedButton.icon(\n onPressed: () {\n // Do something when the button is pressed\n },\n icon: Icon(Icons.add), // Show the add icon\n label: Text('Add'), // Display the text Add\n)\n" | ||
}, | ||
{ | ||
"title": "Button InkWell", | ||
"description": "Display a button who is clickable in his whole area where his child is displayed", | ||
"author": "CreeperFarm", | ||
"tags": [ | ||
"button", | ||
"flutter", | ||
"widget" | ||
], | ||
"contributors": [], | ||
"code": "InkWell(\n onTap: () {\n // Do something when the button is pressed\n },\n child: Container( // Create a container to hold any widget\n padding: EdgeInsets.all(12.0),\n child: Text('Click me!'), // Display the text Click me!\n ),\n)\n" | ||
}, | ||
{ | ||
"title": "Custom Icon", | ||
"description": "Display a custom icon from an .svg file, with the file inside the assets folder. The following code must be added to a components folder then icons folder inside the lib folder. This code should be inside a file called custom_icon.dart . You must have the package flutter_svg in your pubspec.yaml file.", | ||
"author": "CreeperFarm", | ||
"tags": [ | ||
"flutter", | ||
"widget", | ||
"icon", | ||
"svg" | ||
], | ||
"contributors": [], | ||
"code": "import 'package:flutter/material.dart';\nimport 'package:flutter_svg/flutter_svg.dart';\n\nclass CustomIcon extends StatelessWidget {\n Color iconColor;\n final String iconName;\n final double? height;\n\n CustomIcon({required this.iconColor, required this.iconName, this.height, super.key});\n\n @override\n Widget build(BuildContext context) {\n return SvgPicture.asset(\n 'assets/icons/$iconName.svg', // The path to the .svg file\n colorFilter: ColorFilter.mode(iconColor, BlendMode.srcIn), // Change the icon's color\n height: height?.toDouble(), // If the height is null, it will be be set as the svg's default height\n );\n }\n}\n" | ||
} | ||
] | ||
} | ||
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
[γγ¬γΌγ ]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
title: Hello, World! | ||
description: Prints Hello, World! to the terminal. | ||
author: CreeperFarm | ||
tags: printing,hello-world | ||
--- | ||
|
||
```dart | ||
print("Hello, World!"); // Prints Hello, World! to the console | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
title: Button ElevatedButton | ||
description: Display a button with a border and elevation set automatically. | ||
author: CreeperFarm | ||
tags: button,widget | ||
--- | ||
|
||
```dart | ||
ElevatedButton( | ||
onPressed: () { | ||
// Do something when the button is pressed | ||
}, | ||
child: Text('Click me!'),// Display the text Click me! | ||
) | ||
|
||
// If you want a button with an icon | ||
ElevatedButton.icon( | ||
onPressed: () { | ||
// Do something when the button is pressed | ||
}, | ||
icon: Icon(Icons.add), // Show the add icon | ||
label: Text('Add'), // Display the text Add | ||
) | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
title: Button InkWell | ||
description: Display a button who is clickable in his whole area where his child is displayed | ||
author: CreeperFarm | ||
tags: button,widget | ||
--- | ||
|
||
```dart | ||
InkWell( | ||
onTap: () { | ||
// Do something when the button is pressed | ||
}, | ||
child: Container( // Create a container to hold any widget | ||
padding: EdgeInsets.all(12.0), | ||
child: Text('Click me!'), // Display the text Click me! | ||
), | ||
) | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
title: Custom Icon | ||
description: Display a custom icon from an .svg file, with the file inside the assets folder. The following code must be added to a components folder then icons folder inside the lib folder. This code should be inside a file called custom_icon.dart . You must have the package flutter_svg in your pubspec.yaml file. | ||
author: CreeperFarm | ||
tags: widget,icon,svg | ||
--- | ||
|
||
```dart | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_svg/flutter_svg.dart'; | ||
|
||
class CustomIcon extends StatelessWidget { | ||
Color iconColor; | ||
final String iconName; | ||
final double? height; | ||
|
||
CustomIcon({required this.iconColor, required this.iconName, this.height, super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return SvgPicture.asset( | ||
'assets/icons/$iconName.svg', // The path to the .svg file | ||
colorFilter: ColorFilter.mode(iconColor, BlendMode.srcIn), // Change the icon's color | ||
height: height?.toDouble(), // If the height is null, it will be be set as the svg's default height | ||
); | ||
} | ||
} | ||
|
||
// Usage: | ||
CustomIcon( | ||
iconColor: Colors.red, // Set the icon's color | ||
iconName: 'icon_name', // Set the icon's name | ||
height: 24, // Set the icon's height | ||
) | ||
``` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
[γγ¬γΌγ ]
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.