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 'dart:ui'; | |
import 'package:flutter/material.dart'; | |
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
import sketch from "sketch"; | |
// const Style = require("sketch/dom").Style; | |
// const SharedStyle = require("sketch/dom").SharedStyle; | |
// const Flow = require("sketch/dom").Flow; | |
// const Rectangle = require("sketch/dom").Rectangle; | |
// const SmartLayout = require("sketch").SmartLayout; | |
// const Group = require("sketch/dom").Group; | |
// const Artboard = require("sketch/dom").Artboard; | |
// const Shape = require("sketch/dom").Shape; |
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
/*** | |
* Excerpted from "Functional Programming in Java", | |
* published by The Pragmatic Bookshelf. | |
* Copyrights apply to this code. It may not be used to create training material, | |
* courses, books, articles, and the like. Contact us if you are in doubt. | |
* We make no guarantees that this code is fit for any purpose. | |
* Visit http://www.pragmaticprogrammer.com/titles/vsjava8 for more book information. | |
***/ | |
package fpij; |
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
void main() { | |
try { | |
throw 1; | |
} catch (e) { | |
print('What is thrown: $e'); | |
} | |
printDivider(); | |
try { |
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
E/flutter (21138): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: ServicesBinding.defaultBinaryMessenger was accessed before the binding was initialized. | |
E/flutter (21138): If you're running an application and need to access the binary messenger before `runApp()` has been called (for example, during plugin initialization), then you need to explicitly call the `WidgetsFlutterBinding.ensureInitialized()` first. | |
E/flutter (21138): If you're running a test, you can call the `TestWidgetsFlutterBinding.ensureInitialized()` as the first line in your test's `main()` method to initialize the binding. | |
E/flutter (21138): #0 defaultBinaryMessenger.<anonymous closure> (package:flutter/src/services/binary_messenger.dart:73:7) | |
E/flutter (21138): #1 defaultBinaryMessenger (package:flutter/src/services/binary_messenger.dart:86:4) | |
E/flutter (21138): #2 MethodChannel.binaryMessenger (package:flutter/src/services/platform_channel.dart:140:62) | |
E/flutter (21138): #3 MethodChannel.invokeMethod |
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
typedef Compare = int Function(Object a, Object b); | |
class SortedCollection { | |
Compare compare; | |
SortedCollection(this.compare); | |
} | |
// Initial, broken implementation. | |
int sort(Object a, Object b) => 0; |
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 (var value in stream) { | |
print("sum = $sum"); | |
sum += value; | |
} | |
return sum; | |
} | |
Stream<int> countStream(int to) 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
void main() { | |
try { | |
throw Exception(); | |
} on Exception { | |
// A specific exception | |
print('Exception exception'); | |
} catch (e) { | |
// No specified type, handles all | |
print('Something really unknown: $e'); | |
} |
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
void main() { | |
var names = <String>{}; | |
print(names); | |
Set<String> set = {}; | |
print(set); | |
Map<String, String> map = {}; | |
print(map); | |
var set_or_map = {}; | |
print(set_or_map is Set); |
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
void main() { | |
var constantList = const [1, 2, 3]; | |
// constantList[1] = 1; // Uncommenting this causes an error. | |
var list = [1, 2, 3]; | |
var list2 = [0, ...list, ...list]; | |
print(list2); | |
var promoActive = false; | |
var nav = [ |
NewerOlder