Skip to content

Instantly share code, notes, and snippets.

View isacjunior's full-sized avatar

Isac isacjunior

View GitHub Profile
// GOOD
void main() { }
_Foo _bar() => _Foo();
class _Foo {
int _foo() => 42;
}
// BAD
main() { }
_bar() => _Foo();
class _Foo {
_foo() => 42;
}
linter:
rules:
- always_declare_return_types
- always_put_control_body_on_new_line
linter:
rules:
- always_declare_return_types
- always_put_control_body_on_new_line
- always_put_required_named_parameters_first
- always_require_non_null_named_parameters
- always_specify_types
- annotate_overrides
- avoid_annotating_with_dynamic
- avoid_as
class CustomText extends StatelessWidget {
final String text;
CustomText({ @required this.text });
@override
Widget build(BuildContext context) {
return Center(
child: Text(text),
);
class MyCount extends StatefulWidget {
@override
_MyCountState createState() => _MyCountState();
}
class _MyCountState extends State<MyCount> {
int _counter = 0;
void _incrementCounter() {
setState(() {
class CustomText extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Center(
child: Text('Flutter'),
);
}
}
import { StatusBar, StatusBarStyle } from 'react-native'
import { useEffect } from 'react'
function useStatusBar(style: StatusBarStyle) {
useEffect(() => {
StatusBar.setBarStyle(style, true)
}, [])
}
export default useStatusBar
// Response da query acima
{
"data": {
"peopleByIdOne": {
"name": "Luke Skywalker"
},
"peopleByIdTwo": {
"name": "C-3PO"
}
}
# Query que consulta múltiplos dados
query {
peopleByIdOne: people(id: "1") {
name
}
peopleByIdTwo: people(id: "2") {
name
}
}