Skip to content

Instantly share code, notes, and snippets.

@MariaMelnik
MariaMelnik / main.dart
Created July 13, 2021 16:51
flutter: widgets vs build methods
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. 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';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
@MariaMelnik
MariaMelnik / main.dart
Created June 17, 2022 09:45
dart: stop future with CancelableOperation
import 'package:async/async.dart';
void main() async {
final cancellableOperation = CancelableOperation.fromFuture(operation());
cancellableOperation.then((p0) => print('cancelable operation finished normally'),
onCancel: () => print('cancelable operation was canceled'));
await Future.delayed(Duration(seconds: 1)).then((_) {
cancellableOperation.cancel();
print('operation cancelled');
});
@MariaMelnik
MariaMelnik / main.dart
Last active August 18, 2022 10:18
flutter: check bloc updates
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@MariaMelnik
MariaMelnik / main.dart
Created February 11, 2024 13:25
flutter: suffixIcon alignment
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override