Skip to content

Instantly share code, notes, and snippets.

View yjbanov's full-sized avatar
💭
Building a Web runtime for Flutter: http://bit.ly/flutter-web

Yegor yjbanov

💭
Building a Web runtime for Flutter: http://bit.ly/flutter-web
  • Google
  • United States
View GitHub Profile
WidgetsFlutterBinding - DEBUG MODE
[root]
└View(state: _ViewState#7a937)
└RawView
└_RawViewInternal-[_DeprecatedRawViewKey EngineFlutterWindow#b1dd3](renderObject: _ReusableRenderView#4ed98)
└_ViewScope
└_PipelineOwnerScope
└_MediaQueryFromView(state: _MediaQueryFromViewState#6203c)
└MediaQuery(MediaQueryData(size: Size(1200.0, 1444.0), devicePixelRatio: 1.0, textScaler: no scaling, platformBrightness: Brightness.dark, padding: EdgeInsets.zero, viewPadding: EdgeInsets.zero, viewInsets: EdgeInsets.zero, systemGestureInsets: EdgeInsets.zero, alwaysUse24HourFormat: false, accessibleNavigation: false,
highContrast: false, onOffSwitchLabels: false, disableAnimations: false, invertColors: false, boldText: false, navigationMode: traditional, gestureSettings: DeviceGestureSettings(touchSlop: null), displayFeatures: [], supportsShowingSystemContextMenu: false))
@yjbanov
yjbanov / labeled_text_field.dart
Last active March 4, 2025 18:15
Text field with a label
import 'package:flutter/material.dart';
import 'package:flutter/semantics.dart';
void main() {
runApp(MyApp());
SemanticsBinding.instance.ensureSemantics();
}
// Shared label
const _fieldLabel = 'Enter Text';
@yjbanov
yjbanov / login.dart
Created February 6, 2025 18:42
Sample Flutter login form implemented using HTML DOM
import 'dart:js_interop';
import 'package:flutter/material.dart';
import 'package:web/web.dart' as web;
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
void main() {
for (final day in List<int>.generate(365, (n) => n)) {
print('day $day, week ${day ~/ 7}, 28-day period ${day ~/ 28}');
}
}
/// The names for the values computed for each [BenchmarkMetric].
enum BenchmarkMetricComputation {
/// The name for the computed value tracking the average value of the measured
/// samples without outliers.
average,
/// The name for the computed value tracking the average of outlier samples.
outlierAverage,
/// The name for the computed value tracking the outlier average divided by
sealed class BenchmarkMetricComputation {
const BenchmarkMetricComputation(this.name);
final String name;
/// The name for the computed value tracking the average value of the measured
/// samples without outliers.
static const NamedMetricComputation average = NamedMetricComputation('average');
/// The name for the computed value tracking the average of outlier samples.
@yjbanov
yjbanov / flutter_paragraph_example.dart
Created June 26, 2024 00:10
An example of a paragraph of text
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
@pragma('dart2js:tryInline')
bool get assertionsEnabled {
var enabled = false;
assert(enabled = true);
return enabled;
}
// Elsewhere
void main() {
if (assertionsEnabled) {
@widget Counter {
final int initialValue;
@state {
int count = initialValue;
String buttonLabel = 'Increment';
}
Widget build(context) {
return Column(children: [
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp(name: 'Dash'));
}
class MyApp extends StatelessWidget {
const MyApp({super.key, required this.name});
final String name;