Skip to content

Instantly share code, notes, and snippets.

import 'dart:async';
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
void main() async {
final core = Core();
runApp(MaterialApp(
import 'dart:async';
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key key}) : super(key: key);
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
static const Widget _home = MyHomePage();
@override
Widget build(BuildContext context) => MaterialApp(
home: _home,
);
@MariaMelnik
MariaMelnik / main.dart
Created June 30, 2020 18:11
Flutter: StreamBuilder inside StreamBuilder (web test).
import 'dart:async';
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key key}) : super(key: key);
import 'dart:async';
import 'package:flutter/material.dart';
abstract class MyStreamBuilderBase<T, S> extends StatefulWidget {
/// Creates a [MyStreamBuilderBase] connected to the specified [stream].
const MyStreamBuilderBase({ Key key, this.stream }) : super(key: key);
/// The asynchronous computation to which this builder is currently connected,
/// possibly null. When changed, the current summary is updated using
import 'package:flutter/widgets.dart';
import 'new_sb_base.dart';
class MyStreamBuilder<T> extends MyStreamBuilderBase<T, AsyncSnapshot<T>> {
/// Creates a new [MyStreamBuilder] that builds itself based on the latest
/// snapshot of interaction with the specified [stream] and whose build
/// strategy is given by [builder].
///
/// The [initialData] is used to create the initial snapshot.
///
import 'package:meta/meta.dart';
void runner() {
try {
repository();
} on RepositoryException catch (error, stackTrace) {
// Usually here you not only can log it but show some meaningfull information
// based on [RepositoryException.type]. So you don't even need to know how works // repository inside.
print('error: $error\nStackTrace:$stackTrace');
}
@MariaMelnik
MariaMelnik / main.dart
Created March 15, 2021 12:23
dart: lazy fibonacci generator
void main() {
final fib = fibStream();
print(fib.take(10));
}
Iterable<int> fibStream() sync* {
final firstIt = fromList([0]).followedBy(fibStream());
final secondIt = fromList([0,1]).followedBy(fibStream());;
yield* zipWith(sumInt, firstIt, secondIt);
}
void main() {
final inter = 23.96;
final minVal = 23.6;
final list1 = List.generate(5, (i) => minVal + i * inter);
print(list1);
int i = 0;
double val = minVal;