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
| /// Alternative architecture for Flutter lifecycle methods. | |
| /// | |
| /// Currently the framework uses @mustCallSuper to ensure that | |
| /// important operations are called when lifecycle methods are | |
| /// overridden. However, it is a common source of confusion for | |
| /// developers about if the super should be called before or after | |
| /// their own code. | |
| /// | |
| /// This is a proposed alternative which has an internal `handleLifecycleMethod()` | |
| /// method for each lifecycle event which calls `lifecycleMethod()` in the appropriate |
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/material.dart'; | |
| import 'package:flutter_sandbox/widgets/layout/default_scaffold.dart'; | |
| import 'package:flutter_sandbox/themes/text_themes.dart'; | |
| class SandboxRoute extends StatefulWidget { | |
| @override | |
| _SandboxRouteState createState() => _SandboxRouteState(); | |
| } | |
| class _SandboxRouteState extends State<SandboxRoute> { |
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
| /// Finds unused dependencies from pubspec.yaml | |
| /// | |
| /// Achieves this by parsing pubspec.yaml and recursively | |
| /// searching the lib folder for an import statement that | |
| /// contains the name of each package. Prints out the results. | |
| const fs = require("fs"); | |
| const YAML = require("yaml"); | |
| const { execSync } = require("child_process"); | |
| /// Read pubspec.yaml |
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 'dart:math'; | |
| class Table { | |
| /// Example output | |
| /// | |
| /// ``` | |
| /// Range (yd) 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 | |
| /// Drop (in) -0.51, 0.06, 0.23, -0.03, -0.71, -1.84, -3.42, -5.46, -7.98, -10.99 | |
| /// Drop (moa) 4.78, -0.31, -0.73, 0.06, 1.35, 2.92, 4.65, 6.51, 8.45, 10.48 | |
| /// Windage (in) 0.03, 0.05, 0.09, 0.15, 0.22, 0.31, 0.41, 0.53, 0.66, 0.81 |
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/widgets.dart'; | |
| class TextEditingControllerBuilder extends StatefulWidget { | |
| /// Exposes a [TextEditingController] to the child, which allows | |
| /// us to convert any [TextField] into a declarative version. | |
| /// | |
| /// Typically used for wiring up many state fields to form inputs | |
| /// and making sure everything stays in sync. | |
| /// | |
| /// If [text] is updated, the consuming [TextField] will also be updated. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 'dart:math' show Random; | |
| /// The chance of winning a non-resident moose | |
| /// lottery with a single ticket. | |
| final sides = 82; | |
| /// The number of tickets purchased. | |
| final rolls = 100; | |
| /// The US Dollars required to buy a ticket. |
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/material.dart'; | |
| /// ```dart | |
| /// class MyLightAndDarkThemeWidget extends StatelessWidget { | |
| /// @override | |
| /// Widget build(BuildContext context) { | |
| /// return ThemeBrightnessAnimatedBuilder( | |
| /// builder: (context, t, child) { | |
| /// final lightThemeColor = Colors.red.shade800; | |
| /// final darkThemeColor = Colors.red.shade200; |
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() async { | |
| final test = TestClass(); | |
| print(await test.mapIsOdd.first); | |
| print(await test.asyncStarIsOdd.first); | |
| } | |
| Stream<int> get stream => Stream.fromIterable([1, 2, 3, 4, 5, 6]); | |
| class TestClass { |
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/material.dart'; | |
| import '../extensions/extensions.dart'; | |
| typedef AnimatedGridBuilder<T> = Widget Function( | |
| BuildContext, T item, AnimatedGridDetails details); | |
| class AnimatedGrid<T> extends StatelessWidget { | |
| /// An animated grid the animates when the items change sort. | |
| const AnimatedGrid({ |