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 the [Transitive Reduction] for a directed acyclic graph (DAG). | |
/// | |
/// This function assumes the graph is acyclic and it doesn't check for that. | |
/// | |
/// [nodes] should be a list of all nodes in the graph. | |
/// | |
/// [hasPath] should return `true` when the first argument has a path to the second argument. | |
/// > Note: [hasPath] should return `true` when there is a **path**, not only an edge. | |
/// | |
/// This function is a port of [jgrapht][] implementation of Harry Hsu's paper: |
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:analyzer/dart/analysis/analysis_context_collection.dart'; | |
import 'package:analyzer/dart/analysis/results.dart'; | |
import 'package:analyzer/file_system/overlay_file_system.dart'; | |
import 'package:analyzer/file_system/physical_file_system.dart'; | |
final string = ''' | |
class App { | |
final String id; | |
final String name; |
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 'package:flutter/services.dart'; | |
class TextFieldExample extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return TextField( | |
inputFormatters: <TextInputFormatter>[ | |
/// Replaces: any of [٠١٢٣٤٥٦٧٨٩] with its respective [0123456789] | |
...replaceArabicNumeralsFromEastToWestFormatters, |
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
// for SO question: https://stackoverflow.com/q/71134564/10976714 | |
// ignore_for_file: avoid_function_literals_in_foreach_calls, avoid_print | |
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(const ContainerWidthExampleApp()); | |
} | |
class ContainerWidthExampleApp 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
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(const NestedTopicsExample()); | |
} | |
class NestedTopicsExample extends StatelessWidget { | |
const NestedTopicsExample({Key? key}) : super(key: key); |
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
// ignore_for_file: avoid_function_literals_in_foreach_calls, avoid_print | |
import 'package:flutter/material.dart'; | |
void main() => runApp(MultipleTextFieldsExampleApp()); | |
class MultipleTextFieldsExampleApp extends StatelessWidget { | |
const MultipleTextFieldsExampleApp({Key? key}) : super(key: key); |
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:math'; | |
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(const WindowApp()); | |
} | |
class WindowApp extends StatelessWidget { | |
const WindowApp({Key? key}) : super(key: key); |
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({Key? key}) : super(key: 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'; | |
import 'package:provider/provider.dart'; | |
void main() { | |
runApp(const MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
const MyApp({Key? key}) : super(key: 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
// credit: https://stackoverflow.com/a/9195706/10976714 | |
// The formulas to calculate the coordinates of a point at any given position (from 0 to 1) on the Bezier curve are: | |
// x(t) = (1-t)^2 * x1 + 2 * (1-t) * t * x2 + t^2 * x3 | |
// y(t) = (1-t)^2 * y1 + 2 * (1-t) * t * y2 + t^2 * y3 | |
// where (x1, y1) is the starting point, (x2, y2) is the control point and (x3, y3) is the end point. | |
// get a point along the Bezier curve line | |
// If you pass the start, end & control points, along with 0.5 for the halfway position, you get the offset to that point | |
Offset getQuadraticCurvePoint(Offset start, Offset control, Offset end, double position) { |
NewerOlder