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 re | |
first_message_index = 4 | |
step_index = 6 | |
def get_first_alphabetic_character_pos(s): | |
m = re.search(r'[a-z]', s, re.I) | |
if m is not None: | |
return m.start() | |
return 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
data class User(val id: String, val nickname: String) | |
data class Message(val id: String, val message: String?, val user: User) | |
val users = listOf( | |
User("000", "Bender"), | |
User("001", "Leela"), | |
User("002", "Fry"), | |
User("003", "Zoidberg") | |
) |
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
data class User(val id: String, val nickname: String) | |
data class Message(val id: String, val message: String?, val user: User) | |
val users = listOf( | |
User("000", "Bender"), | |
User("001", "Leela"), | |
User("002", "Fry"), | |
User("003", "Zoidberg") | |
) |
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:async'; | |
void main() async { | |
final subscription = numberStreamWithController(8) | |
.listen((event) => print("received $event")); | |
await Future.delayed(Duration(seconds: 3)); | |
print("idling for 2 seconds"); | |
subscription.pause(); |
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( | |
home: Scaffold(body: MyStatefulWidget()), | |
); |
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() { | |
Future.delayed(Duration(seconds: 1), () => throw 'Boom!') | |
.catchError( | |
(e) => print('error we caught: $e'), | |
) | |
.whenComplete(() => | |
print('doing something regardless of what happened previously')); | |
} |
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() async { | |
try { | |
await Future.delayed(Duration(seconds: 1), () => throw 'Boom!'); | |
} catch (e) { | |
print('error we caught: $e'); | |
} finally { | |
print('doing something regardless of what happened previously'); | |
} | |
} |
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() { | |
final myFuture = _runTheFuture(); | |
print('myFuture.runtimeType: ${myFuture.runtimeType}'); | |
} | |
_runTheFuture() { | |
print('print statement before invoking the future'); | |
Future.delayed(Duration(seconds: 2), () { | |
print('Future completed!'); |
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() async { | |
final myFuture = _runTheFuture(); | |
print('myFuture.runtimeType: ${myFuture.runtimeType}'); | |
} | |
_runTheFuture() async { | |
print('print statement before invoking the future'); | |
final myValue = await Future.delayed(Duration(seconds: 2), () { | |
print('Future completed!'); |
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( | |
home: Scaffold( | |
body: RaisedButton( |
NewerOlder