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; |
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
// Add these dependencies to your pubspec.yaml file: | |
// dependencies: | |
// flutter: | |
// sdk: flutter | |
// flutter_riverpod: ^2.5.1 | |
// http: ^1.2.1 | |
import 'package:flutter/material.dart'; | |
import 'package:flutter_riverpod/flutter_riverpod.dart'; |
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:math'; | |
import 'package:flutter/material.dart'; | |
import 'package:flutter_riverpod/flutter_riverpod.dart'; | |
// Riverpod AsyncNotifier/AsyncValue (List) | |
final _rng = Random(); | |
Future<String> fetchItem(int id) async { | |
await Future.delayed(Duration(milliseconds: 500 + _rng.nextInt(900))); |
NewerOlder