This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
import 'package:flutter/material.dart'; | |
//Progress Popup Widget with Stream | |
/// Beispiel-Datenmodell, das vom Stream gesendet wird. | |
class MyStreamData { | |
final double progress; // 0.0 .. 1.0 | |
final String? message; | |
final bool done; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
import 'package:flutter/material.dart'; | |
//Overlay Popup with Stream | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) => MaterialApp(home: HomePage()); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// showDialog | |
/* | |
onPressed: () { | |
showDialog( | |
context: context, | |
builder: (context) { | |
return Dialog( | |
child: Text('DIALOG'), | |
); | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
//Flutter Shadow with CustomPainter | |
void main() { | |
runApp(const MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
const MyApp({super.key}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Button with BoxDecoration | |
//Button with BoxDecoration | |
import 'package:flutter/material.dart'; | |
void main() => runApp(const MyApp()); | |
class MyApp extends StatelessWidget { | |
const MyApp({super.key}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Flutter Animation/Tween (replace Widget) 2 | |
import 'package:flutter/material.dart'; | |
void main() => runApp(TimeSlideApp()); | |
class TimeSlideApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Flutter Animation/Tween (replace Widget) | |
import 'package:flutter/material.dart'; | |
import 'package:intl/intl.dart'; // add intl in pubspec.yaml oder entfernen und eigene Formatierung nutzen | |
void main() { | |
runApp(const MyApp()); | |
} | |
class MyApp extends StatelessWidget { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Flutter (broadcast) StreamController | |
import 'dart:async'; | |
void main() async { | |
// Broadcast allows multiple listeners | |
final controller = StreamController<int>.broadcast(); | |
// Listener A | |
final subA = controller.stream.listen( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Flutter Stream pause, resume, cancel | |
Stream<String> myStream() async* { | |
for (int i = 1; i < 10; i++) { | |
await Future.delayed(Duration(seconds: 1)); | |
yield "VALUE: $i"; | |
} | |
} | |
void main() async { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
import 'package:flutter/material.dart'; | |
//wrapper class for progress + data | |
class DataWithProgress<T> { | |
final T? data; | |
final int progress; // 0..100 | |
final Object? error; | |
final bool done; |
NewerOlder