Skip to content

Instantly share code, notes, and snippets.

View martynov-alex's full-sized avatar
🟢
Ready

Alex Martynov martynov-alex

🟢
Ready
View GitHub Profile
@martynov-alex
martynov-alex / main.dart
Created October 24, 2024 10:37
Resolve animation
// Copyright 2019 the Dart project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
@martynov-alex
martynov-alex / main.dart
Last active October 9, 2024 07:44
await-unawait-ignore
import 'dart:async';
Future<void> main() async {
await runZonedGuarded(
() async {
try {
await call();
} catch (e) {
print('$e поймана в catch внутри runZonedGuarded');
}
@martynov-alex
martynov-alex / main.dart
Last active July 22, 2024 06:36
FutureOr
import 'dart:async';
Future<void> main() async {
print('SyncDataSource');
await f(SyncDataSource('sync data'));
print('==');
print('AsyncDataSource');
await f(AsyncDataSource('async data'));
}
@martynov-alex
martynov-alex / mail.dart
Last active March 18, 2024 04:48
FutureRecord example
void main() async {
final tenNumberStream =
Stream.periodic(const Duration(milliseconds: 100), (count) => count + 1)
.take(10)
.asBroadcastStream();
tenNumberStream.listen(print);
final (Future<int>, Future<int>, Future<int>, Future<int>) futuresRecord = (
tenNumberStream.first,
@martynov-alex
martynov-alex / main.dart
Created February 9, 2024 03:29
Linear Indicator based on CustomPainter
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
@martynov-alex
martynov-alex / main.dart
Last active February 1, 2024 02:50
Lifting State Up example
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
const _everestHeightInMeters = 8849;
enum _Unit { meters, feet }
void main() {
runApp(MyApp());
}
@martynov-alex
martynov-alex / main.dart
Last active October 30, 2023 04:25
Surf UI Quiz #1
import 'dart:math' as math;
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@martynov-alex
martynov-alex / main.dart
Last active September 4, 2023 12:01
Queue example
import 'dart:collection';
void main() async {
final repository = ProductDetailRepository();
final service = RecentlyWatchedService(productDetailRepository: repository);
await Future.delayed(const Duration(seconds: 1));
service.add(const Product(7));
service.add(const Product(3));
service.add(const Product(2));
@martynov-alex
martynov-alex / main.dart
Last active February 24, 2023 07:22
Text widgets and textScaleFactor property
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
@martynov-alex
martynov-alex / main.dart
Last active February 1, 2024 02:52
Example of Flutter text styles organization
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override