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
import { factory, manyOf, nullable, oneOf, primaryKey } from "@mswjs/data"; | |
import { faker } from "@faker-js/faker"; | |
import { Address, Category, Tag } from "./petstore.openapi.ts"; | |
import { ModelDefinition } from "@mswjs/data/lib/glossary"; | |
const PetStatus = ["available", "pending", "sold"]; | |
const OrderStatus = ["placed", "approved", "delivered"]; | |
const Pet = { |
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
{ | |
"title": "Some title", | |
"excerpt": "Some excerpt", | |
"showNotification": true, | |
"status": "SUCCESS", | |
"publishedAt": "asdf", | |
"url": "https://storybook.js.org/blog/whats-new-april-2023/" | |
} |
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
type MyObject = { a: 1; b: 2; c: 3 } | { a: 4; b: 5; c: 6 } | { a: 7; b: 8; c: 9 }; | |
declare const object: MyObject; | |
const { a, b, c } = object; | |
if (a === 1) { | |
console.log(object); // type is {a: 1, b: 2, c: 3} (since 4.4) | |
} else if (a === 2) { | |
// TS2367: This condition will always return 'false' since the types '4 | 7' and '2' have no overlap. | |
console.log(object); // type inferred as never | |
} else if (b === 5) { |
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
class MyScaffold extends HookWidget { | |
const MyScaffold({ | |
Key? key, | |
}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
final theme = useTheme(); | |
final currentPage = usePage(); | |
final count = useState(0); |
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
import 'package:provider/provider.dart'; | |
enum Page { counter, settings } | |
class MyApp extends HookWidget { | |
const MyApp({Key? key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
final currentPage = useState(Page.counter); |
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
ThemeData useTheme() => Theme.of(useContext()); | |
class MyScaffold extends HookWidget { | |
const MyScaffold({Key? key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
final count = useState(0); | |
final theme = useTheme(); | |
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
class MyScaffold extends HookWidget { | |
const MyScaffold({Key? key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
final count = useState(0); | |
final theme = Theme.of(context); | |
return Scaffold( | |
appBar: AppBar(title: Text('Title')), |
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
import 'package:flutter_hooks/flutter_hooks.dart'; | |
class MyScaffold extends HookWidget { | |
const MyScaffold({Key? key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
final count = useState(0); | |
return Scaffold( | |
appBar: AppBar(title: Text('Title')), |
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
class MyButton extends StatelessWidget { | |
const MyButton({Key? key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return GestureDetector( | |
onTap: () { | |
print('MyButton was tapped!'); | |
}, | |
child: Container( |
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
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
const MyApp({Key? key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp(home: MyScaffold()); | |
} | |
} |
NewerOlder