Skip to content

Instantly share code, notes, and snippets.

View daiki1003's full-sized avatar
🏠
Working from home

ashdik daiki1003

🏠
Working from home
View GitHub Profile
const FlutterErrorDetails({
required this.exception,
this.stack,
this.library = 'Flutter framework',
this.context,
this.stackFilter,
this.informationCollector,
this.silent = false,
}) : assert(exception != null);
return MaterialApp(
...,
builder: (context, widget) {
// このbuilderを上書きするだけ
ErrorWidget.builder = (FlutterErrorDetails errorDetails) {
return CustomErrorPage(errorDetails: errorDetails);
};
return widget!;
},
home: ...,
SingleChildScrollView(
child: Column(
children: [
const Text('Hoge'),
ListView.builder(
shrinkWrap: true, // 肝は
physics: const NeverScrollableScrollPhysics(), // この2つ
itemCount: 100,
itemBuilder: (_, index) => Text(
'$index',
static Route<void> route() {
return PageRouteBuilder<void>(
pageBuilder: (_, __, ___) => const SomeScreen(),
transitionDuration: Duration.zero, // ここ
);
}
{
"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';",
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,
import 'dart:convert';
import 'packages:http/http.dart' as http;
Future<void> fetchSomethingRequest() async {
const url = '...';
final response = await http.get(url);
if (response.statusCode != 200) {
throw Exception('Something occurred.');
}
import 'dart:convert';
import 'packages:http/http.dart' as http;
Futur<void> fetchSomethingRequest() async {
const url = '...';
http.get(url).then((response) {
if (response.statusCode != 200) {
throw Exception('Something occurred.');
}
import 'dart:convert';
import 'packages:http/http.dart' as http;
Future<void> fetchSomethingRequest() {
const url = '...';
return http.get(url).then((response) {
if (response.statusCode != 200) {
throw Exception('Something occurred.');
}
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.');