This file contains 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 MyGreatestWidget extends StatelessWidget { | |
const MyGreatestWidget({ | |
Key? key, | |
required this.onPressed, | |
}) : super(key: key); | |
final ValueCallback<String> onPressed; | |
@override | |
Widget build(BuildContext context) { |
This file contains 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 'packages:http/http.dart' as http; | |
void fetchSomethingRequest() { | |
const url = '...'; | |
http.get(url); | |
} |
This file contains 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 'dart:convert'; | |
import 'packages:http/http.dart' as http; | |
void fetchSomethingRequest() { | |
const url = '...'; | |
http.get(url).then((response) { | |
if (response.statusCode != 200) { | |
throw Exception('Something occurred.'); | |
} |
This file contains 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 'dart:convert'; | |
import 'packages:http/http.dart' as http; | |
void fetchSomethingRequest(BuildContext context) { | |
final scaffold = Scaffold.of(context); | |
const url = '...'; | |
http.get(url).then((response) { | |
if (response.statusCode != 200) { | |
throw Exception('Something occurred.'); |
This file contains 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/material.dart'; | |
void main() => runApp(App()); | |
class App extends StatefulWidget { | |
@override | |
_AppState createState() => _AppState(); | |
} | |
class _AppState extends State<App> with WidgetsBindingObserver { |
This file contains 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/foundation.dart'; | |
import 'package:freezed_annotation/freezed_annotation.dart'; | |
part 'sample_model.freezed.dart'; | |
part 'sample_model.g.dart'; | |
@freezed | |
class SampleModel with _$SampleModel { | |
factory SampleModel({ | |
required String id, |
This file contains 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
{ | |
"freezed snippet": { | |
"scope": "dart", | |
"prefix": "freezed", | |
"body": [ | |
"import 'package:flutter/foundation.dart';", | |
"import 'package:freezed_annotation/freezed_annotation.dart';", | |
"", | |
"part '$TM_FILENAME_BASE.freezed.dart';", | |
"part '$TM_FILENAME_BASE.g.dart';", |
This file contains 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
static Route<void> route() { | |
return PageRouteBuilder<void>( | |
pageBuilder: (_, __, ___) => const SomeScreen(), | |
transitionDuration: Duration.zero, // ここ | |
); | |
} |
This file contains 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
SingleChildScrollView( | |
child: Column( | |
children: [ | |
const Text('Hoge'), | |
ListView.builder( | |
shrinkWrap: true, // 肝は | |
physics: const NeverScrollableScrollPhysics(), // この2つ | |
itemCount: 100, | |
itemBuilder: (_, index) => Text( | |
'$index', |
This file contains 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
return MaterialApp( | |
..., | |
builder: (context, widget) { | |
// このbuilderを上書きするだけ | |
ErrorWidget.builder = (FlutterErrorDetails errorDetails) { | |
return CustomErrorPage(errorDetails: errorDetails); | |
}; | |
return widget!; | |
}, | |
home: ..., |