Skip to content

Instantly share code, notes, and snippets.

@osaxma
osaxma / multiple_text_fields.dart
Last active January 13, 2022 15:47
An Example that shows how multiple TextFields are used together
// 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);
import 'package:flutter/material.dart';
void main() {
runApp(const NestedTopicsExample());
}
class NestedTopicsExample extends StatelessWidget {
const NestedTopicsExample({Key? key}) : super(key: key);
// 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 {
@osaxma
osaxma / main.dart
Created September 21, 2022 14:20
Replace Western Arabic Numerals with Western ones
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,
@osaxma
osaxma / resolve_ast_from_string.dart
Created January 15, 2024 12:46
generate a resolved AST fromString
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;
@osaxma
osaxma / transitive_reduction.dart
Last active February 7, 2024 08:39
Transitive Reduction Implementation in Dart (Harry Hsu)
/// 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: