Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

ashdik daiki1003

🏠
Working from home
View GitHub Profile
View spacer_in_custom_scroll_view.dart
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
View spacer_in_list_view.dart
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
View after_override_with_value.dart
final valueProvider = Provider(
(ref) => 1,
);
void main() {
runApp(
ProviderScope(
overrides: [
valueProvider.overrideWith(
(ref) => 2,
View with_override_with_value.dart
final valueProvider = Provider(
(ref) => 1,
);
void main() {
runApp(
ProviderScope(
overrides: [
valueProvider.overrideWithValue(2),
],
View with_ref_repository.dart
final someRepositoryProvider = Provider(
(ref) => SomeRepository(ref.read),
);
class SomeRepository {
const SomeRepository(this._read);
final Ref _ref;
Future<void> fetch() async {
View with_reader_repository.dart
final someRepositoryProvider = Provider(SomeRepository.new);
class SomeRepository {
const SomeRepository(this._read);
final Reader _read;
Future<void> fetch() async {
final response = _read(dioProvider).get(...);
// ...
View bad_association_widget.dart
class BadAssociationWidget extends StatelessWidget {
const BadAssociationWidget();
@override
Widget build(BuildContext context) {
return Container(
margin: const EdgeInsets.symmetric(horizontal: 16),
child: Text('Hello with Margin'),
);
}
View many_callbacks_widget_sample.dart
class AwesomeWidget extends StatelessWidget {
const AwesomeWidget({
super.key,
});
@override
Widget build(BuildContext, context) {
void showUserScreen() {
// show user screen
}
View arguments_sample.dart
class Awesome {
const Awesome.positional(this.value);
const Awesome.named({required this.value});
final int value;
}
/// Instanciation
final positional = Awesome.positional(1);
View in_build_method_after.dart
class SomeWidget extends ConsumerWidget {
const SomeWidget({
super.key,
});
@override
Widget build(BuildContext context, WidgetRef ref) {
final musicId = ref.watch(musicIdProvider);
final volume = ref.watch(volumeProvider);