-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.dart
104 lines (94 loc) · 2.52 KB
/
main.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import 'package:flutter/material.dart';
import 'package:fleasy/fleasy.dart';
void main() => runApp(FleasyExamples());
class FleasyExamples extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Fleasy examples',
home: EasyFutureBuilderExampleInt(),
//home: EasyFutureBuilderExampleList(),
//home: EasyStreamBuilderExampleInt(),
//home: EasyStreamBuilderExampleList(),
);
}
}
class EasyFutureBuilderExampleInt extends StatelessWidget {
final Future<int?> future = (() async {
await Future<void>.delayed(const Duration(seconds: 1));
return 1;
//return null;
//return throw ('TEST ERROR');
})();
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: EasyFutureBuilder<int?>(
future: future,
dataBuilder: (context, data) => Text(data.toString()),
),
),
);
}
}
class EasyFutureBuilderExampleList extends StatelessWidget {
final Future<List<int>?> future = (() async {
await Future<void>.delayed(const Duration(seconds: 1));
return <int>[1, 2, 3];
//return <int>[];
//return null;
//return throw ('TEST ERROR');
})();
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: EasyFutureBuilder<List<int>?>(
future: future,
dataBuilder: (context, data) => Text(data.toString()),
),
),
);
}
}
class EasyStreamBuilderExampleInt extends StatelessWidget {
final Stream<int?> stream = (() async* {
await Future<void>.delayed(const Duration(seconds: 1));
yield 1;
//yield null;
//yield throw ('TEST ERROR');
})();
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: EasyStreamBuilder<int?>(
stream: stream,
dataBuilder: (context, data) => Text(data.toString()),
),
),
);
}
}
class EasyStreamBuilderExampleList extends StatelessWidget {
final Stream<List<int>?> stream = (() async* {
await Future<void>.delayed(const Duration(seconds: 1));
yield <int>[1, 2, 3];
//yield <int>[];
//yield null;
//yield throw ('TEST ERROR');
})();
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: EasyStreamBuilder<List<int>?>(
stream: stream,
dataBuilder: (context, data) => Text(data.toString()),
),
),
);
}
}