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:async/async.dart'; | |
/// Example of how AsyncCache can prevent concurrent execution. | |
void main() async { | |
// Call _execute every second. | |
// In a real use case, multiple triggers can call [_execute] | |
// e.g: start up, user interaction, connectivity change, etc | |
for (int i = 0; i < 10; i++) { | |
_execute(i); | |
await Future.delayed(Duration(seconds: 1)); |
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(const MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
const MyApp({super.key}); | |
@override |
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(const MyApp()); | |
} | |
final _scaffoldMessengerKey = GlobalKey<ScaffoldMessengerState>(); | |
void showThemedSnackBar() { | |
final messenger = _scaffoldMessengerKey.currentState!; |
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'; | |
import 'dart:math'; | |
import 'dart:ui' as ui; | |
import 'dart:ui'; | |
void main() { | |
runApp(const MyApp()); | |
} | |
class MyApp extends StatelessWidget { |
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
#!/bin/bash | |
# This script applies Dart fixes to a project and commits the changes for each fix separately. | |
# It uses the `dart fix --dry-run` command to find the fixes that can be applied. | |
# For each fix, it applies the fix and commits the changes with a message indicating the fix code. | |
checkDart() { | |
if ! command -v dart &> /dev/null | |
then | |
echo "Dart could not be found. Please install Dart first." |
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
// When there are external events triggering notifyListeners() in a ChangeNotifier, | |
// how can we easily test them? Not sure if something like this `ChangeNotifierListener` below | |
// is a valid approach, or if there are easy ways to test `ChangeNotifier` in a unit test, without a widget test. | |
// Just for sake of the example | |
class MyViewModel with ChangeNotifier { | |
MyViewModel(Stream<Object> eventStream) { | |
eventStream.listen((event) { | |
_counter++; |
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(const MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
const MyApp({super.key}); | |
// This widget is the root of your application. |
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'; | |
import 'dart:convert'; | |
final Color darkBlue = Color.fromARGB(255, 18, 32, 47); | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { |
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 MyWidget extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return SizedBox( | |
width: 500.0, | |
child: Column( | |
children: [ | |
Row( | |
mainAxisAlignment: MainAxisAlignment.spaceBetween, | |
children: ['English', 'Russian', 'Spanish'] |
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
#!/bin/bash | |
# Absolute path of the Flutter sandbox project | |
sandbox_path="/Users/fre.dumazy/Developer/Playground/flutter_sandbox" | |
# Name of Android emulator to open. | |
# Check with `emulator -list-avds` | |
avd_name="Pixel_4_API_30" | |
main() { | |
processOptions "$@" |
NewerOlder