This file contains 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'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter Demo', | |
debugShowCheckedModeBanner: false, |
This file contains 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
class MeinSingleton { | |
/// Unsere Singleton Instanz, die einmalig instanziiert wird | |
static final MeinSingleton _singleton = MeinSingleton._internal(); | |
/// Member Variable, die zugreifbar gemacht werden soll | |
late List<dynamic> data = []; | |
/// Factory Constructor, der die Instanz der Klasse zurückgibt, egal wann sie aufgerufen wird | |
factory MeinSingleton() { | |
return _singleton; |
This file contains 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
// 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 |
This file contains 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
class MeinObjektPositionsParameter { | |
String name = ""; | |
// Positions Parameter an Stelle 1 | |
MeinObjektPositionsParameter(this.name); | |
} | |
class MeinObjektOptionalParameterDefault { | |
String name = ""; | |
// Positions Parameter an Stelle 1, aber optional mit default value | |
MeinObjektOptionalParameterDefault([this.name = 'FOO']) ; |
This file contains 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
class User { | |
String name; | |
String type; | |
User({required this.name, required this.type}); | |
} | |
enum MyEnum { | |
foo("test", "admin"), | |
bar("test2", "user"); |
This file contains 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
Future<int> sumStream(Stream<int> stream) async { | |
var sum = 0; | |
await for (final value in stream) { | |
sum += value; | |
} | |
return sum; | |
} | |
Stream<int> countStream(int to) async* { | |
for (int i = 1; i <= to; i++) { |
This file contains 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'; | |
import 'dart:async'; | |
import 'dart:math'; | |
void main() { | |
runApp(const MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
const MyApp({Key? key}) : super(key: key); |
This file contains 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
// Erweitere die Klasse string um die NumberParsing Extension | |
extension StringParsing on String { | |
String changeDirection() { | |
return this.split('').reversed.join(); | |
} | |
// ··· | |
} | |
class Person { | |
String name = ''; |
This file contains 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
Future<void> printOrderMessage() async { | |
print('Awaiting user order...'); | |
var order = await fetchUserOrder(); | |
print('Your order is: $order'); | |
} | |
Future<String> fetchUserOrder() { | |
// Imagine that this function is more complex and slow. | |
return Future.delayed(const Duration(seconds: 4), () => 'Large Latte'); | |
} | |
void main() async { |
This file contains 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
add2Numbers(int number1, {required int number2}) { | |
return number1 + number2; | |
} | |
add2NumbersNotReq([int number1 = 5, int number2 = 10]) { | |
return number1 + number2; | |
} | |
add2NumbersNamedOptional({required int number1, int? number2}) { | |
return number1 + (number2 ?? 0); |
NewerOlder