100% found this document useful (5 votes)
1K views

Download Complete Flutter Recipes: Mobile Development Solutions for iOS and Android Fu Cheng PDF for All Chapters

Solutions

Uploaded by

gackeyunan5q
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (5 votes)
1K views

Download Complete Flutter Recipes: Mobile Development Solutions for iOS and Android Fu Cheng PDF for All Chapters

Solutions

Uploaded by

gackeyunan5q
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

Download the Full Version of textbook for Fast Typing at textbookfull.

com

Flutter Recipes: Mobile Development Solutions for


iOS and Android Fu Cheng

https://textbookfull.com/product/flutter-recipes-mobile-
development-solutions-for-ios-and-android-fu-cheng/

OR CLICK BUTTON

DOWNLOAD NOW

Download More textbook Instantly Today - Get Yours Now at textbookfull.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Build Mobile Apps with Ionic 2 and Firebase: Hybrid Mobile


App Development 1st Edition Fu Cheng

https://textbookfull.com/product/build-mobile-apps-with-ionic-2-and-
firebase-hybrid-mobile-app-development-1st-edition-fu-cheng/

textboxfull.com

Build Mobile Apps with Ionic 4 and Firebase: Hybrid Mobile


App Development [Lingua inglese] 2nd Edition Fu Cheng

https://textbookfull.com/product/build-mobile-apps-with-ionic-4-and-
firebase-hybrid-mobile-app-development-lingua-inglese-2nd-edition-fu-
cheng/
textboxfull.com

Developing Inclusive Mobile Apps: Building Accessible Apps


for iOS and Android 1st Edition Rob Whitaker

https://textbookfull.com/product/developing-inclusive-mobile-apps-
building-accessible-apps-for-ios-and-android-1st-edition-rob-whitaker/

textboxfull.com

Practical Mobile Forensics A hands on guide to mastering


mobile forensics for the iOS Android and the Windows Phone
platforms 3rd Edition Rohit Tamma
https://textbookfull.com/product/practical-mobile-forensics-a-hands-
on-guide-to-mastering-mobile-forensics-for-the-ios-android-and-the-
windows-phone-platforms-3rd-edition-rohit-tamma/
textboxfull.com
Learn Java for Android Development: Migrating Java SE
Programming Skills to Mobile Development 4th Edition Peter
Späth
https://textbookfull.com/product/learn-java-for-android-development-
migrating-java-se-programming-skills-to-mobile-development-4th-
edition-peter-spath/
textboxfull.com

Android Continuous Integration: Build-Deploy-Test


Automation for Android Mobile Apps Pradeep Macharla

https://textbookfull.com/product/android-continuous-integration-build-
deploy-test-automation-for-android-mobile-apps-pradeep-macharla/

textboxfull.com

Android Cookbook Problems and Solutions for Android


Developers 2nd Edition Ian F. Darwin

https://textbookfull.com/product/android-cookbook-problems-and-
solutions-for-android-developers-2nd-edition-ian-f-darwin/

textboxfull.com

iOS 11 Swift Programming Cookbook Solutions and Examples


for iOS Apps 1st Edition Vandad Nahavandipoor

https://textbookfull.com/product/ios-11-swift-programming-cookbook-
solutions-and-examples-for-ios-apps-1st-edition-vandad-nahavandipoor/

textboxfull.com

Learn Java for Android Development Friesen Jeff

https://textbookfull.com/product/learn-java-for-android-development-
friesen-jeff/

textboxfull.com
Flutter
Recipes
Mobile Development Solutions for
iOS and Android

Fu Cheng
Flutter Recipes
Mobile Development Solutions
for iOS and Android

Fu Cheng
Flutter Recipes: Mobile Development Solutions for iOS and Android
Fu Cheng
Sandringham, Auckland, New Zealand

ISBN-13 (pbk): 978-1-4842-4981-9 ISBN-13 (electronic): 978-1-4842-4982-6


https://doi.org/10.1007/978-1-4842-4982-6

Copyright © 2019 by Fu Cheng


This work is subject to copyright. All rights are reserved by the Publisher, whether the whole
or part of the material is concerned, specifically the rights of translation, reprinting, reuse of
illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical
way, and transmission or information storage and retrieval, electronic adaptation, computer
software, or by similar or dissimilar methodology now known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a
trademark symbol with every occurrence of a trademarked name, logo, or image we use the
names, logos, and images only in an editorial fashion and to the benefit of the trademark
owner, with no intention of infringement of the trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms,
even if they are not identified as such, is not to be taken as an expression of opinion as to
whether or not they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the
date of publication, neither the authors nor the editors nor the publisher can accept any
legal responsibility for any errors or omissions that may be made. The publisher makes no
warranty, express or implied, with respect to the material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Aaron Black
Development Editor: James Markham
Coordinating Editor: Jessica Vakili
Cover image designed by Freepik (www.freepik.com)
Distributed to the book trade worldwide by Springer Science+Business Media New York,
233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201)
348-4505, e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. Apress
Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business
Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
For information on translations, please e-mail rights@apress.com, or visit http://www.
apress.com/rights-permissions.
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook
versions and licenses are also available for most titles. For more information, reference our
Print and eBook Bulk Sales web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is
available to readers on GitHub via the book’s product page, located at www.apress.com/
978-1-4842-4981-9. For more detailed information, please visit http://www.apress.com/
source-code.
Printed on acid-free paper
Table of Contents
About the Author����������������������������������������������������������������������������� xxxi

About the Technical Reviewer������������������������������������������������������� xxxiii

Chapter 1: Get Started��������������������������������������������������������������������������1


1-1. Installing Flutter SDK on Windows���������������������������������������������������������������� 1
Problem����������������������������������������������������������������������������������������������������������� 1
Solution����������������������������������������������������������������������������������������������������������� 1
Discussion������������������������������������������������������������������������������������������������������� 1
1-2. Installing Flutter SDK on Linux���������������������������������������������������������������������� 4
Problem����������������������������������������������������������������������������������������������������������� 4
Solution����������������������������������������������������������������������������������������������������������� 4
Discussion������������������������������������������������������������������������������������������������������� 4
1-3. Installing Flutter SDK on macOS�������������������������������������������������������������������� 5
Problem����������������������������������������������������������������������������������������������������������� 5
Solution����������������������������������������������������������������������������������������������������������� 6
Discussion������������������������������������������������������������������������������������������������������� 6
1-4. Setting Up iOS Platform��������������������������������������������������������������������������������� 7
Problem����������������������������������������������������������������������������������������������������������� 7
Solution����������������������������������������������������������������������������������������������������������� 7
Discussion������������������������������������������������������������������������������������������������������� 7
1-5. Setting Up iOS Simulators����������������������������������������������������������������������������� 9
Problem����������������������������������������������������������������������������������������������������������� 9
Solution����������������������������������������������������������������������������������������������������������� 9
Discussion������������������������������������������������������������������������������������������������������� 9
iii
Table of Contents

1-6. Setting Up iOS Devices����������������������������������������������������������������������������������9


Problem�����������������������������������������������������������������������������������������������������������9
Solution�����������������������������������������������������������������������������������������������������������9
Discussion�����������������������������������������������������������������������������������������������������10
1-7. Setting Up Android Platform������������������������������������������������������������������������11
Problem���������������������������������������������������������������������������������������������������������11
Solution���������������������������������������������������������������������������������������������������������11
Discussion�����������������������������������������������������������������������������������������������������11
1-8. Setting Up Android Emulators����������������������������������������������������������������������13
Problem���������������������������������������������������������������������������������������������������������13
Solution���������������������������������������������������������������������������������������������������������13
Discussion�����������������������������������������������������������������������������������������������������13
1-9. Setting Up Android Devices�������������������������������������������������������������������������18
Problem���������������������������������������������������������������������������������������������������������18
Solution���������������������������������������������������������������������������������������������������������18
Discussion�����������������������������������������������������������������������������������������������������18
1-10. Creating Flutter Apps Using Command Line����������������������������������������������19
Problem���������������������������������������������������������������������������������������������������������19
Solution���������������������������������������������������������������������������������������������������������19
Discussion�����������������������������������������������������������������������������������������������������19
1-11. Creating Flutter Apps Using Android Studio�����������������������������������������������20
Problem���������������������������������������������������������������������������������������������������������20
Solution���������������������������������������������������������������������������������������������������������20
Discussion�����������������������������������������������������������������������������������������������������20
1-12. Creating Flutter Apps Using VS Code���������������������������������������������������������24
Problem���������������������������������������������������������������������������������������������������������24
Solution���������������������������������������������������������������������������������������������������������24
Discussion�����������������������������������������������������������������������������������������������������25

iv
Table of Contents

1-13. Running Flutter Apps���������������������������������������������������������������������������������26


Problem���������������������������������������������������������������������������������������������������������26
Solution���������������������������������������������������������������������������������������������������������26
Discussion�����������������������������������������������������������������������������������������������������26
1-14. Understanding Code Structure of Flutter Apps������������������������������������������27
Problem���������������������������������������������������������������������������������������������������������27
Solution���������������������������������������������������������������������������������������������������������27
Discussion�����������������������������������������������������������������������������������������������������27
1-15. Fixing Configuration Issues of Flutter SDK������������������������������������������������28
Problem���������������������������������������������������������������������������������������������������������28
Solution���������������������������������������������������������������������������������������������������������28
Discussion�����������������������������������������������������������������������������������������������������28
1-16. Summary���������������������������������������������������������������������������������������������������28

Chapter 2: Know the Tools������������������������������������������������������������������29


2-1. Using Dart Observatory�������������������������������������������������������������������������������29
Problem���������������������������������������������������������������������������������������������������������29
Solution���������������������������������������������������������������������������������������������������������29
Discussion�����������������������������������������������������������������������������������������������������29
2-2. Using Hot Reload and Hot Restart���������������������������������������������������������������31
Problem���������������������������������������������������������������������������������������������������������31
Solution���������������������������������������������������������������������������������������������������������31
Discussion�����������������������������������������������������������������������������������������������������32
2-3. Upgrading Flutter SDK���������������������������������������������������������������������������������34
Problem���������������������������������������������������������������������������������������������������������34
Solution���������������������������������������������������������������������������������������������������������34
Discussion�����������������������������������������������������������������������������������������������������35

v
Table of Contents

2-4. Debugging Flutter Apps in Android Studio���������������������������������������������������36


Problem���������������������������������������������������������������������������������������������������������36
Solution���������������������������������������������������������������������������������������������������������36
Discussion�����������������������������������������������������������������������������������������������������36
2-5. Viewing Outline of Flutter Apps in Android Studio���������������������������������������39
Problem���������������������������������������������������������������������������������������������������������39
Solution���������������������������������������������������������������������������������������������������������39
Discussion�����������������������������������������������������������������������������������������������������40
2-6. Debugging Flutter Apps in VS Code�������������������������������������������������������������41
Problem���������������������������������������������������������������������������������������������������������41
Solution���������������������������������������������������������������������������������������������������������41
Discussion�����������������������������������������������������������������������������������������������������41
2-7. Creating Flutter Projects������������������������������������������������������������������������������42
Problem���������������������������������������������������������������������������������������������������������42
Solution���������������������������������������������������������������������������������������������������������42
Discussion�����������������������������������������������������������������������������������������������������43
2-8. Running Flutter Apps�����������������������������������������������������������������������������������46
Problem���������������������������������������������������������������������������������������������������������46
Solution���������������������������������������������������������������������������������������������������������46
Discussion�����������������������������������������������������������������������������������������������������46
2-9. Building Flutter App Binaries�����������������������������������������������������������������������51
Problem���������������������������������������������������������������������������������������������������������51
Solution���������������������������������������������������������������������������������������������������������51
Discussion�����������������������������������������������������������������������������������������������������51
2-10. Installing Flutter Apps��������������������������������������������������������������������������������53
Problem���������������������������������������������������������������������������������������������������������53
Solution���������������������������������������������������������������������������������������������������������53
Discussion�����������������������������������������������������������������������������������������������������53

vi
Table of Contents

2-11. Managing Packages����������������������������������������������������������������������������������54


Problem���������������������������������������������������������������������������������������������������������54
Solution���������������������������������������������������������������������������������������������������������54
Discussion�����������������������������������������������������������������������������������������������������54
2-12. Running Flutter Tests���������������������������������������������������������������������������������56
Problem���������������������������������������������������������������������������������������������������������56
Solution���������������������������������������������������������������������������������������������������������56
Discussion�����������������������������������������������������������������������������������������������������56
2-13. Analyzing the Code������������������������������������������������������������������������������������58
Problem���������������������������������������������������������������������������������������������������������58
Solution���������������������������������������������������������������������������������������������������������59
Discussion�����������������������������������������������������������������������������������������������������59
2-14. Managing Emulators����������������������������������������������������������������������������������61
Problem���������������������������������������������������������������������������������������������������������61
Solution���������������������������������������������������������������������������������������������������������61
Discussion�����������������������������������������������������������������������������������������������������61
2-15. Taking Screenshots�����������������������������������������������������������������������������������62
Problem���������������������������������������������������������������������������������������������������������62
Solution���������������������������������������������������������������������������������������������������������62
Discussion�����������������������������������������������������������������������������������������������������62
2-16. Attaching to Running Apps������������������������������������������������������������������������63
Problem���������������������������������������������������������������������������������������������������������63
Solution���������������������������������������������������������������������������������������������������������63
Discussion�����������������������������������������������������������������������������������������������������64
2-17. Tracing Running Flutter Apps���������������������������������������������������������������������65
Problem���������������������������������������������������������������������������������������������������������65
Solution���������������������������������������������������������������������������������������������������������65
Discussion�����������������������������������������������������������������������������������������������������65

vii
Table of Contents

2-18. Configuring Flutter SDK�����������������������������������������������������������������������������66


Problem���������������������������������������������������������������������������������������������������������66
Solution���������������������������������������������������������������������������������������������������������66
Discussion�����������������������������������������������������������������������������������������������������66
2-19. Showing App Logs�������������������������������������������������������������������������������������67
Problem���������������������������������������������������������������������������������������������������������67
Solution���������������������������������������������������������������������������������������������������������67
Discussion�����������������������������������������������������������������������������������������������������68
2-20. Formatting Source Code����������������������������������������������������������������������������68
Problem���������������������������������������������������������������������������������������������������������68
Solution���������������������������������������������������������������������������������������������������������69
Discussion�����������������������������������������������������������������������������������������������������69
2-21. Listing Connected Devices������������������������������������������������������������������������70
Problem���������������������������������������������������������������������������������������������������������70
Solution���������������������������������������������������������������������������������������������������������70
Discussion�����������������������������������������������������������������������������������������������������70
2-22. Running Integration Tests��������������������������������������������������������������������������70
Problem���������������������������������������������������������������������������������������������������������70
Solution���������������������������������������������������������������������������������������������������������71
Discussion�����������������������������������������������������������������������������������������������������71
2-23. Enabling Bash Completion of Flutter SDK Commands�������������������������������72
Problem���������������������������������������������������������������������������������������������������������72
Solution���������������������������������������������������������������������������������������������������������72
Discussion�����������������������������������������������������������������������������������������������������72
2-24. Cleaning Build Files of Flutter Apps�����������������������������������������������������������74
Problem���������������������������������������������������������������������������������������������������������74
Solution���������������������������������������������������������������������������������������������������������74
Discussion�����������������������������������������������������������������������������������������������������74

viii
Table of Contents

2-25. Managing Flutter SDK Cache���������������������������������������������������������������������74


Problem���������������������������������������������������������������������������������������������������������74
Solution���������������������������������������������������������������������������������������������������������74
Discussion�����������������������������������������������������������������������������������������������������75
2-26. Summary���������������������������������������������������������������������������������������������������75

Chapter 3: Essential Dart��������������������������������������������������������������������77


3-1. Understanding Built-In Types�����������������������������������������������������������������������77
Problem���������������������������������������������������������������������������������������������������������77
Solution���������������������������������������������������������������������������������������������������������77
Discussion�����������������������������������������������������������������������������������������������������77
3-2. Using Enumerated Types�����������������������������������������������������������������������������81
Problem���������������������������������������������������������������������������������������������������������81
Solution���������������������������������������������������������������������������������������������������������81
Discussion�����������������������������������������������������������������������������������������������������82
3-3. Using Dynamic Type������������������������������������������������������������������������������������83
Problem���������������������������������������������������������������������������������������������������������83
Solution���������������������������������������������������������������������������������������������������������83
Discussion�����������������������������������������������������������������������������������������������������83
3-4. Understanding Functions�����������������������������������������������������������������������������84
Problem���������������������������������������������������������������������������������������������������������84
Solution���������������������������������������������������������������������������������������������������������84
Discussion�����������������������������������������������������������������������������������������������������84
3-5. Using Typedefs��������������������������������������������������������������������������������������������86
Problem���������������������������������������������������������������������������������������������������������86
Solution���������������������������������������������������������������������������������������������������������86
Discussion�����������������������������������������������������������������������������������������������������86

ix
Table of Contents

3-6. Using Cascade Operator������������������������������������������������������������������������������87


Problem���������������������������������������������������������������������������������������������������������87
Solution���������������������������������������������������������������������������������������������������������87
Discussion�����������������������������������������������������������������������������������������������������87
3-7. Overriding Operators�����������������������������������������������������������������������������������88
Problem���������������������������������������������������������������������������������������������������������88
Solution���������������������������������������������������������������������������������������������������������88
Discussion�����������������������������������������������������������������������������������������������������88
3-8. Using Constructors��������������������������������������������������������������������������������������89
Problem���������������������������������������������������������������������������������������������������������89
Solution���������������������������������������������������������������������������������������������������������89
Discussion�����������������������������������������������������������������������������������������������������90
3-9. Extending a Class����������������������������������������������������������������������������������������92
Problem���������������������������������������������������������������������������������������������������������92
Solution���������������������������������������������������������������������������������������������������������92
Discussion�����������������������������������������������������������������������������������������������������92
3-10. Adding Features to a Class������������������������������������������������������������������������94
Problem���������������������������������������������������������������������������������������������������������94
Solution���������������������������������������������������������������������������������������������������������94
Discussion�����������������������������������������������������������������������������������������������������94
3-11. Using Interfaces�����������������������������������������������������������������������������������������96
Problem���������������������������������������������������������������������������������������������������������96
Solution���������������������������������������������������������������������������������������������������������96
Discussion�����������������������������������������������������������������������������������������������������96
3-12. Using Generics�������������������������������������������������������������������������������������������97
Problem���������������������������������������������������������������������������������������������������������97
Solution���������������������������������������������������������������������������������������������������������97
Discussion�����������������������������������������������������������������������������������������������������98

x
Table of Contents

3-13. Using Libraries�����������������������������������������������������������������������������������������100


Problem�������������������������������������������������������������������������������������������������������100
Solution�������������������������������������������������������������������������������������������������������100
Discussion���������������������������������������������������������������������������������������������������100
3-14. Using Exceptions�������������������������������������������������������������������������������������101
Problem�������������������������������������������������������������������������������������������������������101
Solution�������������������������������������������������������������������������������������������������������101
Discussion���������������������������������������������������������������������������������������������������101
3-15. Summary�������������������������������������������������������������������������������������������������104

Chapter 4: Widget Basics�����������������������������������������������������������������105


4-1. Understanding Widgets�����������������������������������������������������������������������������105
Problem�������������������������������������������������������������������������������������������������������105
Solution�������������������������������������������������������������������������������������������������������105
Discussion���������������������������������������������������������������������������������������������������105
4-2. Understanding BuildContext����������������������������������������������������������������������108
Problem�������������������������������������������������������������������������������������������������������108
Solution�������������������������������������������������������������������������������������������������������109
Discussion���������������������������������������������������������������������������������������������������109
4-3. Understanding Stateless Widget���������������������������������������������������������������111
Problem�������������������������������������������������������������������������������������������������������111
Solution�������������������������������������������������������������������������������������������������������111
Discussion���������������������������������������������������������������������������������������������������111
4-4. Understanding Stateful Widget������������������������������������������������������������������112
Problem�������������������������������������������������������������������������������������������������������112
Solution�������������������������������������������������������������������������������������������������������112
Discussion���������������������������������������������������������������������������������������������������112

xi
Table of Contents

4-5. Understanding Inherited Widget����������������������������������������������������������������113


Problem�������������������������������������������������������������������������������������������������������113
Solution�������������������������������������������������������������������������������������������������������113
Discussion���������������������������������������������������������������������������������������������������113
4-6. Displaying Text�������������������������������������������������������������������������������������������116
Problem�������������������������������������������������������������������������������������������������������116
Solution�������������������������������������������������������������������������������������������������������116
Discussion���������������������������������������������������������������������������������������������������116
Text��������������������������������������������������������������������������������������������������������������116
TextSpan������������������������������������������������������������������������������������������������������119
RichText�������������������������������������������������������������������������������������������������������121
4-7. Applying Styles to Text�������������������������������������������������������������������������������122
Problem�������������������������������������������������������������������������������������������������������122
Solution�������������������������������������������������������������������������������������������������������122
Discussion���������������������������������������������������������������������������������������������������122
4-8. Displaying Images�������������������������������������������������������������������������������������126
Problem�������������������������������������������������������������������������������������������������������126
Solution�������������������������������������������������������������������������������������������������������126
Discussion���������������������������������������������������������������������������������������������������126
4-9. Displaying Icons����������������������������������������������������������������������������������������128
Problem�������������������������������������������������������������������������������������������������������128
Solution�������������������������������������������������������������������������������������������������������128
Discussion���������������������������������������������������������������������������������������������������128
4-10. Using Buttons with Text���������������������������������������������������������������������������130
Problem�������������������������������������������������������������������������������������������������������130
Solution�������������������������������������������������������������������������������������������������������130
Discussion���������������������������������������������������������������������������������������������������130

xii
Table of Contents

4-11. Using Buttons with Icons�������������������������������������������������������������������������132


Problem�������������������������������������������������������������������������������������������������������132
Solution�������������������������������������������������������������������������������������������������������132
Discussion���������������������������������������������������������������������������������������������������132
4-12. Adding Placeholders��������������������������������������������������������������������������������133
Problem�������������������������������������������������������������������������������������������������������133
Solution�������������������������������������������������������������������������������������������������������133
Discussion���������������������������������������������������������������������������������������������������133
4-13. Summary�������������������������������������������������������������������������������������������������134

Chapter 5: Layout Widgets����������������������������������������������������������������135


5-1. Understanding Layout in Flutter����������������������������������������������������������������135
Problem�������������������������������������������������������������������������������������������������������135
Solution�������������������������������������������������������������������������������������������������������135
Discussion���������������������������������������������������������������������������������������������������135
RenderObject�����������������������������������������������������������������������������������������������137
BoxConstraints��������������������������������������������������������������������������������������������138
Layout Algorithm�����������������������������������������������������������������������������������������138
Layout Widgets��������������������������������������������������������������������������������������������139
5-2. Placing Widgets in the Center�������������������������������������������������������������������139
Problem�������������������������������������������������������������������������������������������������������139
Solution�������������������������������������������������������������������������������������������������������139
Discussion���������������������������������������������������������������������������������������������������139
5-3. Aligning Widgets����������������������������������������������������������������������������������������140
Problem�������������������������������������������������������������������������������������������������������140
Solution�������������������������������������������������������������������������������������������������������140
Discussion���������������������������������������������������������������������������������������������������140

xiii
Table of Contents

5-4. Imposing Constraints on Widgets��������������������������������������������������������������144


Problem�������������������������������������������������������������������������������������������������������144
Solution�������������������������������������������������������������������������������������������������������144
Discussion���������������������������������������������������������������������������������������������������144
5-5. Imposing No Constraints on Widgets���������������������������������������������������������146
Problem�������������������������������������������������������������������������������������������������������146
Solution�������������������������������������������������������������������������������������������������������147
Discussion���������������������������������������������������������������������������������������������������147
5-6. Imposing Constraints on Widgets when Ignoring Parents�������������������������148
Problem�������������������������������������������������������������������������������������������������������148
Solution�������������������������������������������������������������������������������������������������������148
Discussion���������������������������������������������������������������������������������������������������148
5-7. Limiting Size to Allow Child Widget to Overflow����������������������������������������149
Problem�������������������������������������������������������������������������������������������������������149
Solution�������������������������������������������������������������������������������������������������������149
Discussion���������������������������������������������������������������������������������������������������150
5-8. Limiting Widgets Size when Unbounded���������������������������������������������������150
Problem�������������������������������������������������������������������������������������������������������150
Solution�������������������������������������������������������������������������������������������������������150
Discussion���������������������������������������������������������������������������������������������������151
5-9. Scaling and Positioning Widgets���������������������������������������������������������������151
Problem�������������������������������������������������������������������������������������������������������151
Solution�������������������������������������������������������������������������������������������������������151
Discussion���������������������������������������������������������������������������������������������������152
5-10. Rotating Widgets�������������������������������������������������������������������������������������156
Problem�������������������������������������������������������������������������������������������������������156
Solution�������������������������������������������������������������������������������������������������������156
Discussion���������������������������������������������������������������������������������������������������156

xiv
Table of Contents

5-11. Adding Padding when Displaying Widgets����������������������������������������������156


Problem�������������������������������������������������������������������������������������������������������156
Solution�������������������������������������������������������������������������������������������������������157
Discussion���������������������������������������������������������������������������������������������������157
5-12. Sizing Widgets to Aspect Ratio����������������������������������������������������������������158
Problem�������������������������������������������������������������������������������������������������������158
Solution�������������������������������������������������������������������������������������������������������158
Discussion���������������������������������������������������������������������������������������������������158
5-13. Transforming Widgets������������������������������������������������������������������������������160
Problem�������������������������������������������������������������������������������������������������������160
Solution�������������������������������������������������������������������������������������������������������160
Discussion���������������������������������������������������������������������������������������������������160
5-14. Controlling Different Layout Aspects on a Widget�����������������������������������161
Problem�������������������������������������������������������������������������������������������������������161
Solution�������������������������������������������������������������������������������������������������������161
Discussion���������������������������������������������������������������������������������������������������162
5-15. Implementing Flex Box Layout����������������������������������������������������������������164
Problem�������������������������������������������������������������������������������������������������������164
Solution�������������������������������������������������������������������������������������������������������164
Discussion���������������������������������������������������������������������������������������������������165
Flex Box Layout Algorithm���������������������������������������������������������������������������165
Flexible��������������������������������������������������������������������������������������������������������168
5-16. Displaying Overlapping Widgets��������������������������������������������������������������169
Problem�������������������������������������������������������������������������������������������������������169
Solution�������������������������������������������������������������������������������������������������������169
Discussion���������������������������������������������������������������������������������������������������169

xv
Table of Contents

5-17. Displaying Widgets in Multiple Runs�������������������������������������������������������171


Problem�������������������������������������������������������������������������������������������������������171
Solution�������������������������������������������������������������������������������������������������������171
Problem�������������������������������������������������������������������������������������������������������171
5-18. Creating Custom Single Child Layout������������������������������������������������������173
Problem�������������������������������������������������������������������������������������������������������173
Solution�������������������������������������������������������������������������������������������������������173
Discussion���������������������������������������������������������������������������������������������������173
5-19. Creating Custom Multiple Children Layout����������������������������������������������176
Problem�������������������������������������������������������������������������������������������������������176
Solution�������������������������������������������������������������������������������������������������������176
Discussion���������������������������������������������������������������������������������������������������176
5-20. Summary�������������������������������������������������������������������������������������������������180

Chapter 6: Form Widgets������������������������������������������������������������������181


6-1. Collecting Text Inputs��������������������������������������������������������������������������������181
Problem�������������������������������������������������������������������������������������������������������181
Solution�������������������������������������������������������������������������������������������������������181
Discussion���������������������������������������������������������������������������������������������������181
Using TextEditingController��������������������������������������������������������������������������182
Using Listeners of TextEditingController������������������������������������������������������184
Using Callbacks�������������������������������������������������������������������������������������������186
6-2. Customizing Keyboard for Text Input���������������������������������������������������������188
Problem�������������������������������������������������������������������������������������������������������188
Solution�������������������������������������������������������������������������������������������������������189
Discussion���������������������������������������������������������������������������������������������������189
6-3. Add Decorations to Text Input in Material Design��������������������������������������191
Problem�������������������������������������������������������������������������������������������������������191
Solution�������������������������������������������������������������������������������������������������������192

xvi
Table of Contents

Discussion���������������������������������������������������������������������������������������������������192
Borders��������������������������������������������������������������������������������������������������������192
Prefix and Suffix������������������������������������������������������������������������������������������194
Text��������������������������������������������������������������������������������������������������������������195
6-4. Setting Text Limits�������������������������������������������������������������������������������������196
Problem�������������������������������������������������������������������������������������������������������196
Solution�������������������������������������������������������������������������������������������������������196
Discussion���������������������������������������������������������������������������������������������������197
6-5. Selecting Text��������������������������������������������������������������������������������������������198
Problem�������������������������������������������������������������������������������������������������������198
Solution�������������������������������������������������������������������������������������������������������198
Discussion���������������������������������������������������������������������������������������������������198
6-6. Formatting Text������������������������������������������������������������������������������������������202
Problem�������������������������������������������������������������������������������������������������������202
Solution�������������������������������������������������������������������������������������������������������202
Discussion���������������������������������������������������������������������������������������������������202
6-7. Selecting a Single Value����������������������������������������������������������������������������203
Problem�������������������������������������������������������������������������������������������������������203
Solution�������������������������������������������������������������������������������������������������������204
Discussion���������������������������������������������������������������������������������������������������204
6-8. Selecting a Single Value from Dropdown��������������������������������������������������206
Problem�������������������������������������������������������������������������������������������������������206
Solution�������������������������������������������������������������������������������������������������������206
Discussion���������������������������������������������������������������������������������������������������207
6-9. Selecting Multiple Values��������������������������������������������������������������������������209
Problem�������������������������������������������������������������������������������������������������������209
Solution�������������������������������������������������������������������������������������������������������209
Discussion���������������������������������������������������������������������������������������������������209

xvii
Table of Contents

6-10. Toggling On/Off State�������������������������������������������������������������������������������211


Problem�������������������������������������������������������������������������������������������������������211
Solution�������������������������������������������������������������������������������������������������������211
Discussion���������������������������������������������������������������������������������������������������211
6-11. Selecting from a Range of Values������������������������������������������������������������214
Problem�������������������������������������������������������������������������������������������������������214
Solution�������������������������������������������������������������������������������������������������������214
Discussion���������������������������������������������������������������������������������������������������215
6-12. Using Chips����������������������������������������������������������������������������������������������217
Problem�������������������������������������������������������������������������������������������������������217
Solution�������������������������������������������������������������������������������������������������������217
Discussion���������������������������������������������������������������������������������������������������217
6-13. Selecting Date and Time��������������������������������������������������������������������������221
Problem�������������������������������������������������������������������������������������������������������221
Solution�������������������������������������������������������������������������������������������������������221
Discussion���������������������������������������������������������������������������������������������������221
6-14. Wrapping Form Fields������������������������������������������������������������������������������225
Problem�������������������������������������������������������������������������������������������������������225
Solution�������������������������������������������������������������������������������������������������������225
Discussion���������������������������������������������������������������������������������������������������225
6-15. Creating Forms����������������������������������������������������������������������������������������230
Problem�������������������������������������������������������������������������������������������������������230
Solution�������������������������������������������������������������������������������������������������������230
Discussion���������������������������������������������������������������������������������������������������230
6-16. Summary�������������������������������������������������������������������������������������������������234

xviii
Table of Contents

Chapter 7: Common Widgets������������������������������������������������������������235


7-1. Displaying a List of Items��������������������������������������������������������������������������235
Problem�������������������������������������������������������������������������������������������������������235
Solution�������������������������������������������������������������������������������������������������������235
Discussion���������������������������������������������������������������������������������������������������235
ListView with Static Children�����������������������������������������������������������������������236
ListView with Item Builders�������������������������������������������������������������������������237
ListTile���������������������������������������������������������������������������������������������������������238
7-2. Displaying Items in a Grid��������������������������������������������������������������������������244
Problem�������������������������������������������������������������������������������������������������������244
Solution�������������������������������������������������������������������������������������������������������244
Discussion���������������������������������������������������������������������������������������������������244
7-3. Displaying Tabular Data�����������������������������������������������������������������������������250
Problem�������������������������������������������������������������������������������������������������������250
Solution�������������������������������������������������������������������������������������������������������250
Discussion���������������������������������������������������������������������������������������������������250
7-4. Scaffolding Material Design Pages������������������������������������������������������������255
Problem�������������������������������������������������������������������������������������������������������255
Solution�������������������������������������������������������������������������������������������������������255
Discussion���������������������������������������������������������������������������������������������������255
App Bar��������������������������������������������������������������������������������������������������������256
Floating Action Button���������������������������������������������������������������������������������258
Drawer���������������������������������������������������������������������������������������������������������258
Bottom App Bar�������������������������������������������������������������������������������������������260
Bottom Navigation Bar��������������������������������������������������������������������������������260
Bottom Sheet�����������������������������������������������������������������������������������������������263
Scaffold State����������������������������������������������������������������������������������������������264
SnackBar�����������������������������������������������������������������������������������������������������264

xix
Table of Contents

7-5. Scaffolding iOS Pages�������������������������������������������������������������������������������265


Problem�������������������������������������������������������������������������������������������������������265
Solution�������������������������������������������������������������������������������������������������������265
Discussion���������������������������������������������������������������������������������������������������265
7-6. Creating Tab Layout in Material Design�����������������������������������������������������266
Problem�������������������������������������������������������������������������������������������������������266
Solution�������������������������������������������������������������������������������������������������������266
Discussion���������������������������������������������������������������������������������������������������267
7-7. Implementing Tab Layout in iOS����������������������������������������������������������������270
Problem�������������������������������������������������������������������������������������������������������270
Solution�������������������������������������������������������������������������������������������������������270
Discussion���������������������������������������������������������������������������������������������������270
7-8. Summary���������������������������������������������������������������������������������������������������271

Chapter 8: Page Navigation��������������������������������������������������������������273


8-1. Implementing Basic Page Navigation��������������������������������������������������������273
Problem�������������������������������������������������������������������������������������������������������273
Solution�������������������������������������������������������������������������������������������������������273
Discussion���������������������������������������������������������������������������������������������������273
8-2. Using Named Routes���������������������������������������������������������������������������������276
Problem�������������������������������������������������������������������������������������������������������276
Solution�������������������������������������������������������������������������������������������������������276
Discussion���������������������������������������������������������������������������������������������������276
8-3. Passing Data Between Routes�������������������������������������������������������������������278
Problem�������������������������������������������������������������������������������������������������������278
Solution�������������������������������������������������������������������������������������������������������278
Discussion���������������������������������������������������������������������������������������������������278

xx
Table of Contents

8-4. Implementing Dynamic Route Matching���������������������������������������������������284


Problem�������������������������������������������������������������������������������������������������������284
Solution�������������������������������������������������������������������������������������������������������284
Discussion���������������������������������������������������������������������������������������������������284
8-5. Handling Unknown Routes������������������������������������������������������������������������285
Problem�������������������������������������������������������������������������������������������������������285
Solution�������������������������������������������������������������������������������������������������������285
Discussion���������������������������������������������������������������������������������������������������286
8-6. Displaying Material Design Dialogs�����������������������������������������������������������286
Problem�������������������������������������������������������������������������������������������������������286
Solution�������������������������������������������������������������������������������������������������������287
Discussion���������������������������������������������������������������������������������������������������287
8-7. Displaying iOS Dialogs�������������������������������������������������������������������������������290
Problem�������������������������������������������������������������������������������������������������������290
Solution�������������������������������������������������������������������������������������������������������291
Discussion���������������������������������������������������������������������������������������������������291
8-8. Displaying iOS Action Sheets���������������������������������������������������������������������293
Problem�������������������������������������������������������������������������������������������������������293
Solution�������������������������������������������������������������������������������������������������������293
Discussion���������������������������������������������������������������������������������������������������293
8-9. Showing Material Design Menus���������������������������������������������������������������296
Problem�������������������������������������������������������������������������������������������������������296
Solution�������������������������������������������������������������������������������������������������������296
Discussion���������������������������������������������������������������������������������������������������296
8-10. Managing Complicated Page Flows Using Nested Navigators����������������301
Problem�������������������������������������������������������������������������������������������������������301
Solution�������������������������������������������������������������������������������������������������������301
Discussion���������������������������������������������������������������������������������������������������301

xxi
Table of Contents

8-11. Observing Navigator State Changes��������������������������������������������������������305


Problem�������������������������������������������������������������������������������������������������������305
Solution�������������������������������������������������������������������������������������������������������305
Discussion���������������������������������������������������������������������������������������������������305
8-12. Stopping Routes from Popping����������������������������������������������������������������310
Problem�������������������������������������������������������������������������������������������������������310
Solution�������������������������������������������������������������������������������������������������������310
Discussion���������������������������������������������������������������������������������������������������310
8-13. Summary�������������������������������������������������������������������������������������������������312

Chapter 9: Service Interaction����������������������������������������������������������313


9-1. Working with Futures��������������������������������������������������������������������������������313
Problem�������������������������������������������������������������������������������������������������������313
Solution�������������������������������������������������������������������������������������������������������313
Discussion���������������������������������������������������������������������������������������������������313
9-2. Using async and await to Work with Futures��������������������������������������������317
Problem�������������������������������������������������������������������������������������������������������317
Solution�������������������������������������������������������������������������������������������������������317
Discussion���������������������������������������������������������������������������������������������������317
9-3. Creating Futures����������������������������������������������������������������������������������������318
Problem�������������������������������������������������������������������������������������������������������318
Solution�������������������������������������������������������������������������������������������������������319
Discussion���������������������������������������������������������������������������������������������������319
9-4. Working with Streams�������������������������������������������������������������������������������320
Problem�������������������������������������������������������������������������������������������������������320
Solution�������������������������������������������������������������������������������������������������������320
Discussion���������������������������������������������������������������������������������������������������320

xxii
Table of Contents

9-5. Creating Streams���������������������������������������������������������������������������������������328


Problem�������������������������������������������������������������������������������������������������������328
Solution�������������������������������������������������������������������������������������������������������328
Discussion���������������������������������������������������������������������������������������������������328
9-6. Building Widgets Based on Streams and Futures��������������������������������������330
Problem�������������������������������������������������������������������������������������������������������330
Solution�������������������������������������������������������������������������������������������������������330
Discussion���������������������������������������������������������������������������������������������������330
9-7. Handle Simple JSON Data�������������������������������������������������������������������������335
Problem�������������������������������������������������������������������������������������������������������335
Solution�������������������������������������������������������������������������������������������������������335
Discussion���������������������������������������������������������������������������������������������������335
9-8. Handle Complex JSON Data����������������������������������������������������������������������337
Problem�������������������������������������������������������������������������������������������������������337
Solution�������������������������������������������������������������������������������������������������������338
Discussion���������������������������������������������������������������������������������������������������338
9-9. Handling XML Data������������������������������������������������������������������������������������344
Problem�������������������������������������������������������������������������������������������������������344
Solution�������������������������������������������������������������������������������������������������������344
Discussion���������������������������������������������������������������������������������������������������344
9-10. Handling HTML Data��������������������������������������������������������������������������������349
Problem�������������������������������������������������������������������������������������������������������349
Solution�������������������������������������������������������������������������������������������������������349
Discussion���������������������������������������������������������������������������������������������������349
9-11. Sending HTTP Requests��������������������������������������������������������������������������350
Problem�������������������������������������������������������������������������������������������������������350
Solution�������������������������������������������������������������������������������������������������������351
Discussion���������������������������������������������������������������������������������������������������351

xxiii
Table of Contents

9-12. Connecting to WebSocket������������������������������������������������������������������������353


Problem�������������������������������������������������������������������������������������������������������353
Solution�������������������������������������������������������������������������������������������������������354
Discussion���������������������������������������������������������������������������������������������������354
9-13. Connecting to Socket������������������������������������������������������������������������������355
Problem�������������������������������������������������������������������������������������������������������355
Solution�������������������������������������������������������������������������������������������������������355
Discussion���������������������������������������������������������������������������������������������������355
9-14. Interacting JSON-Based REST Services��������������������������������������������������356
Problem�������������������������������������������������������������������������������������������������������356
Solution�������������������������������������������������������������������������������������������������������356
Discussion���������������������������������������������������������������������������������������������������357
9-15. Interacting with gRPC Services���������������������������������������������������������������360
Problem�������������������������������������������������������������������������������������������������������360
Solution�������������������������������������������������������������������������������������������������������361
Discussion���������������������������������������������������������������������������������������������������361
9-16. Summary�������������������������������������������������������������������������������������������������363

Chapter 10: State Management��������������������������������������������������������365


10-1. Managing State Using Stateful Widgets��������������������������������������������������365
Problem�������������������������������������������������������������������������������������������������������365
Solution�������������������������������������������������������������������������������������������������������365
Discussion���������������������������������������������������������������������������������������������������365
10-2. Managing State Using Inherited Widgets������������������������������������������������371
Problem�������������������������������������������������������������������������������������������������������371
Solution�������������������������������������������������������������������������������������������������������371
Discussion���������������������������������������������������������������������������������������������������371

xxiv
Table of Contents

10-3. Managing State Using Inherited Model���������������������������������������������������378


Problem�������������������������������������������������������������������������������������������������������378
Solution�������������������������������������������������������������������������������������������������������378
Discussion���������������������������������������������������������������������������������������������������379
10-4. Managing State Using Inherited Notifier�������������������������������������������������382
Problem�������������������������������������������������������������������������������������������������������382
Solution�������������������������������������������������������������������������������������������������������382
Discussion���������������������������������������������������������������������������������������������������382
10-5. Managing State Using Scoped Model������������������������������������������������������384
Problem�������������������������������������������������������������������������������������������������������384
Solution�������������������������������������������������������������������������������������������������������384
Discussion���������������������������������������������������������������������������������������������������385
10-6. Managing State Using Bloc���������������������������������������������������������������������389
Problem�������������������������������������������������������������������������������������������������������389
Solution�������������������������������������������������������������������������������������������������������389
Discussion���������������������������������������������������������������������������������������������������389
10-7. Managing State Using Redux������������������������������������������������������������������397
Problem�������������������������������������������������������������������������������������������������������397
Solution�������������������������������������������������������������������������������������������������������397
Discussion���������������������������������������������������������������������������������������������������397
10-8. Managing State Using Mobx��������������������������������������������������������������������405
Problem�������������������������������������������������������������������������������������������������������405
Solution�������������������������������������������������������������������������������������������������������406
Discussion���������������������������������������������������������������������������������������������������406
10-9. Summary�������������������������������������������������������������������������������������������������412

xxv
Table of Contents

Chapter 11: Animations��������������������������������������������������������������������413


11-1. Creating Simple Animations��������������������������������������������������������������������413
Problem�������������������������������������������������������������������������������������������������������413
Solution�������������������������������������������������������������������������������������������������������413
Discussion���������������������������������������������������������������������������������������������������413
11-2. Creating Animations Using Linear Interpolation��������������������������������������418
Problem�������������������������������������������������������������������������������������������������������418
Solution�������������������������������������������������������������������������������������������������������418
Discussion���������������������������������������������������������������������������������������������������418
11-3. Creating Curved Animations��������������������������������������������������������������������421
Problem�������������������������������������������������������������������������������������������������������421
Solution�������������������������������������������������������������������������������������������������������421
Discussion���������������������������������������������������������������������������������������������������421
11-4. Chaining Tweens��������������������������������������������������������������������������������������425
Problem�������������������������������������������������������������������������������������������������������425
Solution�������������������������������������������������������������������������������������������������������425
Discussion���������������������������������������������������������������������������������������������������425
11-5. Creating Sequences of Tweens���������������������������������������������������������������426
Problem�������������������������������������������������������������������������������������������������������426
Solution�������������������������������������������������������������������������������������������������������426
Discussion���������������������������������������������������������������������������������������������������426
11-6. Running Simultaneous Animations����������������������������������������������������������427
Problem�������������������������������������������������������������������������������������������������������427
Solution�������������������������������������������������������������������������������������������������������427
Discussion���������������������������������������������������������������������������������������������������427

xxvi
Table of Contents

11-7. Creating Staggered Animations���������������������������������������������������������������428


Problem�������������������������������������������������������������������������������������������������������428
Solution�������������������������������������������������������������������������������������������������������428
Discussion���������������������������������������������������������������������������������������������������429
11-8. Creating Hero Animations������������������������������������������������������������������������430
Problem�������������������������������������������������������������������������������������������������������430
Solution�������������������������������������������������������������������������������������������������������430
Discussion���������������������������������������������������������������������������������������������������431
11-9. Using Common Transitions����������������������������������������������������������������������434
Problem�������������������������������������������������������������������������������������������������������434
Solution�������������������������������������������������������������������������������������������������������434
Discussion���������������������������������������������������������������������������������������������������434
11-10. Creating Physics Simulations����������������������������������������������������������������436
Problem�������������������������������������������������������������������������������������������������������436
Solution�������������������������������������������������������������������������������������������������������436
Discussion���������������������������������������������������������������������������������������������������437
11-11. Summary�����������������������������������������������������������������������������������������������440

Chapter 12: Platform Integration������������������������������������������������������441


12-1. Reading and Writing Files������������������������������������������������������������������������441
Problem�������������������������������������������������������������������������������������������������������441
Solution�������������������������������������������������������������������������������������������������������441
Discussion���������������������������������������������������������������������������������������������������441
12-2. Storing Key-Value Pairs���������������������������������������������������������������������������444
Problem�������������������������������������������������������������������������������������������������������444
Solution�������������������������������������������������������������������������������������������������������444
Discussion���������������������������������������������������������������������������������������������������444

xxvii
Table of Contents

12-3. Writing Platform-Specific Code���������������������������������������������������������������446


Problem�������������������������������������������������������������������������������������������������������446
Solution�������������������������������������������������������������������������������������������������������446
Discussion���������������������������������������������������������������������������������������������������446
12-4. Creating Plugins��������������������������������������������������������������������������������������452
Problem�������������������������������������������������������������������������������������������������������452
Solution�������������������������������������������������������������������������������������������������������452
Discussion���������������������������������������������������������������������������������������������������452
12-5. Displaying Web Pages�����������������������������������������������������������������������������456
Problem�������������������������������������������������������������������������������������������������������456
Solution�������������������������������������������������������������������������������������������������������456
Discussion���������������������������������������������������������������������������������������������������456
12-6. Playing Videos�����������������������������������������������������������������������������������������460
Problem�������������������������������������������������������������������������������������������������������460
Solution�������������������������������������������������������������������������������������������������������460
Discussion���������������������������������������������������������������������������������������������������461
12-7. Using Cameras����������������������������������������������������������������������������������������465
Problem�������������������������������������������������������������������������������������������������������465
Solution�������������������������������������������������������������������������������������������������������466
Discussion���������������������������������������������������������������������������������������������������466
12-8. Using System Share Sheet����������������������������������������������������������������������470
Problem�������������������������������������������������������������������������������������������������������470
Solution�������������������������������������������������������������������������������������������������������470
Discussion���������������������������������������������������������������������������������������������������470
12-9. Summary�������������������������������������������������������������������������������������������������471

xxviii
Other documents randomly have
different content
The Project Gutenberg eBook of In the swim
This ebook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this ebook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.

Title: In the swim


A story of currents and under-currents in gayest New
York

Author: Richard Savage

Release date: September 29, 2023 [eBook #71751]

Language: English

Original publication: Chicago: Rand, McNally & Company, 1898

Credits: Sonya Schermann, David Wilson and the Online


Distributed Proofreading Team at https://www.pgdp.net
(This file was produced from images generously made
available by The Internet Archive)

*** START OF THE PROJECT GUTENBERG EBOOK IN THE SWIM


***
IN THE SWIM.
IN THE SWIM

A Story of
Currents and Under-Currents
in Gayest New York.

By
Richard Henry Savage

Chicago and New York:


Rand, McNally & Company,
Publishers.
Copyright, 1898, by Richard Henry Savage.
All Rights Reserved.
CONTENTS.

BOOK I.
A RISING STAR.
Chapter. Pages
I— “Young
. . Lochinvar
. . . has . .Come
. . out. of. the. West,”
. . . . 5–23
II— The. Drift
. of . a. Day
. in. New
. . York
. City,
. . . . . . . 24–43
III— A Frank
. . Disclosure,
. . . . . . . . . . . . . . 44–67
IV— “Wyman
. . and . . Vreeland”
. . . Swing
. . the. Street,
. . . . . . 68–88
V— Toward
. . the . Zenith,
. . . . . . . . . . . . . 89–110

BOOK II.
WITH THE CURRENT.

VI— In the
. .“Elmleaf”
. . .Bachelor
. . .Apartments,
. . . . . . . . 111–131
VII— “Plunger”
. . .Vreeland’s
. . . Gay
. . Life,
. “Under
. . .the. Rose,”
. . . 132–151
VIII— Miss
. Romaine
. . . Garland,
. . . Stenographer,
. . . . . . . . . 152–170
IX— Senator
. . Alynton’s
. . . Colleague,
. . . . . . . . . . . 171–188
X— An Interview at Lakemere. Some Ingenious
Mechanism.
. . . . “Whose
. . . Picture
. . is . That?”
. . . . . . 189–209

BOOK III.
ON A LEE SHORE.
XI— Miss Marble’s Waterloo! A Lost Lamb! Her Vacant
Chair. Senator Garston’s Disclosure. Sara
Conyers’ Mission. Miss Garland’s Dishonorable
Discharge.
. . . . A .Defiance
. . .to the
. .Death.
. . “Robbed!”
. . . . 210–234
XII— Mine
. and
. .Countermine,
. . . . . . . . . . . . . 235–257
XIII— A Wedding
. . . in. High. .Life,
. . . . . . . . . . 258–279
XIV— For. the. Child’s
. . Sake!
. . . . . . . . . . . . 280–315
XV— In the
. .Dark. Waters,
. . . . . . . . . . . . . 316–361
I N T H E S W I M.
BOOK I—A Rising Star.

CHAPTER I.

“YOUNG LOCHINVAR HAS COME OUT OF THE WEST.”

There was an expression of sullen discontent upon the handsome


features of Mr. Harold Vreeland (gentleman unattached), as the
inbound Hudson River train dashed along under the castled cliffs of
Rhinebeck.
The afternoon was fair—the river of all rivers glittered gaily in the
sun, and a dreamy peace rested on field and stream. But, the peace
of this June afternoon of ’95 entered not into the young wayfarer’s
soul.
The five years which the traveler from nowhere in particular had
thrown away in the far wilds of the sporadic West had not yet robbed
his chiseled features of the good looks which he had borne away
from old Nassau.
And, though his glittering blue eye had been trained to a habitual
impassiveness by much frontier poker, he had always abjured that
Rocky Mountain whisky which “biteth like an adder.”
As he restlessly sought the smoking-car, after a vain struggle with
the all too-evident immorality of a saucy French novel, several
quickly thrilled spinsters followed his retreating form with warm
glances of furtive admiration and half-suppressed sighs.
Vreeland’s stalwart figure was clearly reminiscent of well-played
football and long straining at the oar. His well-set head was bravely
carried, his eye was searching and even audaciously daring in its
social explorations.
At twenty-seven he had not lost the fascination of his soft and
perfectly modulated voice nor the winning insinuation of his too
frequent smile. The chin was far too softly molded for an ascetic, and
an expression of lurking insincerity flickered in the pleasure-loving
curves of his handsome mouth.
But, shapely and glowing with manly vigor, he was a very “proper
man-at-arms” in the battle of life, his sweeping cavalry mustache
lending an air of decision to his sun-burned features.
Though he was perfectly dressed up to the memories of his never-
forgotten “varsity” grade, the “wanderjahre” had given to him a little
of that easy swing which is the gift of wandering on boundless
prairies, long nights spent al fresco under the glittering dome of
stars, and a close commune with the sighing pines of the West.
The shade of bitterness deepened upon his moody face as he noted
a three-masted steam yacht swinging along up the river, with the
elastic quivering throb of her quadruple compounded engines. This
queenly vessel bore the private signal of one American citizen
whose personal finances beggar the resources of many modern
kings.
“Those are the cold-hearted fellows who rule America now with a rod
of iron—the new money kings,” he growled. “Royal by the clink of the
dollar, sovereign by the magic wand of monopoly, impregnable with
the adamantine armor of trusts!”
And then, a lively hatred of the social grandees luxuriously grouped
aft on that splendid yacht crept into his embittered soul.
He could see the Venetian awning which covered the clustered fair-
faced patrician women from the fierce sun, which rudely burns by
day.
And he knew, too, by distant rumors of that superb luxury in which
the American women of the creed of the Golden Calf passed their
happy days in a splendid and serene indolence, only lit up now and
then with gleams of the passion play of high life.
“It’s no use to fight those fellows,” mused Vreeland, as he carefully
trimmed a cigar. “They have come to stay, and I must try and fall into
the train of some one of them.”
He looked back at all those unprofitable years spent beyond the
rugged Rockies. There was a sense of shame and resentment as he
recalled the shabby career of his talented father.
“Thank God, I am now alone in the world, ‘with no one nigh to
hender!’” he bitterly reflected, unconsciously quoting Lowell’s “Zekle
and Huldy.”
The train had rushed on past Poughkeepsie, and the parade music
from West Point floated sweetly across the cool river as the train
halted at Garrison’s for a few moments, before he had morosely
reviewed all the dismal events which brought him a lonely stranger
back to New York.
Erastus Vreeland, a lawyer of no mean accomplishment, had
destined his only son for the bar.
The elder Vreeland was a human spider, who had finally gravitated
downward into the exercise of only the meaner craft of his much-
abused profession.
For long years, in his little office on William Street he had legally
carried on the intrigues of a daring band of clients who rightly should
have ornamented the Academy of Belles-Lettres of New York at Sing
Sing.
During the life of his hoodwinked wife, Vreeland père led a double
existence of more or less moral turpitude, and, at last, a shameless
and successful coup of rascality aroused the ire of a great financial
company.
It was his “notice to quit,” and after the death of his wife, Erastus
Vreeland “swung round the distant circle,” often followed by the
déclassé lawyer.
Omaha, Leadville, Salt Lake, Los Angeles, and other Western cities
finally knew his fox-like cunning and gradually weakening grip.
A political affray, the result of a heated election in Montana, had
been the occasion of the elder Vreeland’s sudden taking off.
And so, the man who had never learned the homely adage that
“corruption wins not more than honesty,” slept far away from his
fathers on the rocky hillsides of Helena, in wild Montana. It was a
miserable summation of failures.
The hegira of the father had left the son stranded in life at the start
upon his finishing the four years at Princeton which had made him
an expert in all the manly arts save any definite plan of money-
getting.
A still self-deceiving man, Erastus Vreeland had hopefully invited his
son to share the suggested exile, and thus, the plan of the law
course for the junior was perforce abandoned. It had not been long
till father and son drifted coldly apart.
The mean, shabby moral nature of the demoralized elder could not
long impose upon the quick-witted youth. The slights of the bench,
the slurs of the bar, the wasp-like thrusts of a bold frontier press, all
proved that the “trail of the serpent” followed on after the talented
weakling whose professional honor was never proof against gold or
gain secured from either side.
And so, with only a hypocritical pretense of a certain lingering
friendly feeling, the two men had finally parted, dividing a few
hundred dollars which were the remains of a retainer in a case,
which deftly went wrong on its trial, sold out, to the benefit of lawyer
Vreeland’s adversary. Then came the bloody finale—and, and—exit
Vreeland pater!
Harold Vreeland sighed in disgust as he recalled the five lost years
of his golden youthful promise.
“It’s all rot,” he muttered, “this idea that the loafer life of the far West
gives either scope, strength, or courage to any man. It is all mere
barbarism, and only a windy discounting of a future which never
comes. A long, bootless struggle with the meaner conditions of life.”
He recalled his varied experiences as notary public, deputy county
clerk, cashier of a shoddy bank—a concern which “folded its Arabian
tents” in six months.
Real estate dealer he had been in several aspiring “boom towns,”
and also, secretary of many frontier “wind” corporations, whose
beautifully engraved stock certificates were now either carried
around in the pocketbooks of dupes or else stuck up in Western
saloons, to the huge edification of the ungodly.
This strange wandering life had made him a fox in cunning, though
not as yet a ravening wolf, for there was little to prey upon in those
dreary distant Occidental preserves. But, his fangs were well
sharpened for the fray.
He realized, as the lights of Haverstraw gleamed out “beyond the
swelling tide,” that he was as yet without any definite plan of
operations.
A singular incident, illustrative of the roughly good-humored social
code of the wild West had caused him to seek the city of Manhattan.
The political clique which had coolly plotted the murder of his crafty
father, with a last generous twinge of conscience, had sent all the
private papers of the defunct lawyer over to his son, who was
listlessly engaged at the time in endeavoring, on a net cash capital of
a hundred and fifty dollars, to float a ten million dollar corporation, in
order to utilize certain waste energy of those foaming falls of the
Spokane River, which have so long caused both the salmon and the
Indians a great deal of unnecessary trouble.
And then, young Vreeland wearily explored those ashes of life—the
“papers in the case” of the defunct.
The unwelcome discovery of many evidences of his father’s shame
and the revealing of all that secret life which had sent his patient
mother to the shadowy bourne of heartbroken wives, was somewhat
mitigated by the discovery of a paid-up policy of ten thousand dollars
in the great “Acqueduct Life Insurance of New York City.”
There was, as usual, some strings and filaments hanging out loosely
knotted up, and it had been a labor of months, involving a
correspondence of some acerbity, for him to obtain letters of
administration, close up his father’s “estate,” and depart to Gotham
to receive a check for seven thousand dollars in full settlement of the
claim.
On the road over from Spokane, Mr. Harold Vreeland had carefully
counted all his ships. He had even gone over all his own abortive
attempts at opening any useful career, and so, on this summer
evening, he gloomily felt how poorly prepared he was to fight the
battle of life against the keen competition and increasing pressure of
his peers in New York City.
“If I had only my father’s profession, I would have a chance to get in
among these fellows, and I would soon have my share of the gate
money,” he growled.
“But to take a place in the line of mere drudges, to sink down into the
death in life of a hall room and a cheap boarding-house. Once
planted there, I am there forever. And I have not a friend in the whole
world!”
His mental harvest had only been one of husks, and he keenly felt
the absence of any definite calling pour accrocher.
Suddenly his eye caught the gleam of a sunset upon a dozen
drifting, glittering white sails on the river.
They all seemed to float on serenely, borne along upon the broad
tide, with no visible man’s hand to guide.
“I will drift a while,” he murmured. “I have a few thousand dollars.
Something will surely turn up. If it does not,” he resolutely said,
“then, I will turn it up myself.”
“There are women here, too—women with hearts of flame, and who
are to be won. I was a fool ever to go out to the frontier. Perhaps—”
And his mind reverted to a lucky college chum who had married a
woman nearly two generations older than himself, but a well-
preserved Madame “Midas.”
“By Jove! anything is better than this beastly poverty,” he mused.
“Even that.”
“This is no era for poor men. Poverty is the only crime nowadays.”
His cynicism was broken off by the approach of two men, who rose
to rejoin friends in the train as it dashed along toward the Bronx
River.
As they came up the smoking-car, Vreeland easily recognized Fred
Hathorn, the stroke of the college crew in which he had once won
hard-fought honors for the orange.
There was no mistaking the easy luxury which exhaled from Mr. Fred
Hathorn of the great firm of Hathorn and Potter, bankers and brokers
of dingy Wall Street, a man who had already arrived!
The first crucial glance of rapid inspection was not lost on Vreeland,
as Hathorn, in an easy way cried: “Hello, Hod Vreeland! What brings
you over here?”
With a perfunctory politeness, Mr. James Potter halted and calmly
acknowledged Hathorn’s listless introduction.
The little blonde man-about-town, however, gazed longingly ahead at
the car where certain fair dames now awaited their escorts.
Jimmy Potter was born to “no end of easy money,” and so his
dashing senior partner’s genius for finance was strongly buttressed
by the whirlwind of cash which clustered around Jimmy Potter’s
lucky head.
All sorts of financial bees seemed to swarm around Potter and
quietly settle in his hive.
“What’s the use of making a row?” he often remarked. “Sit still, and
what you want in life will come to you.” Mr. James Potter of New York
was an Epicurean disciple.
The blood mounted to Vreeland’s forehead as he noted all the
deprecating courtesy of Hathorn’s welcome.
“Damn him! I’ll give him a bit of a bluff,” he quickly decided, under
the inspiration of some bold, familiar spirit.
There was an air of quiet comfort in the careless response of
Vreeland.
“I have just fallen into a good bit of money by my father’s death, and
so have come on here to enjoy myself. I may spend a couple of
years abroad.”
Vreeland then blessed that daring, familiar spirit which so saucily
suggested his “cheeky” retort, as the man who had been his chum
and fellow of several Greek letter societies stopped short. “Wait for
me at the station, old fellow. We are bothered yet with some ladies.
They leave at the station. Then we will dine later at the club and talk
over old times a bit. You’ll come, too, won’t you, Potter?”
Jimmy Potter carelessly nodded an assent from sheer laziness, and
then the two members of the jeunesse dorée, passed on into the
boudoir car.
There was a twinkle of triumph in Vreeland’s eye as he sank back in
his seat.
“I got a dinner out of you at any rate, Mr. Snob,” he gleefully
chuckled.
And, highly elated, he decided then and there, to vary his first plan of
drifting with the tide, and to cautiously put his oar in a bit where it
would help him on.
His step was as light as the tread of a panther when he leaped out of
the car at Forty-second Street.
“I’ll have a stolen glance at their women,” he quickly resolved.
“Perhaps they may give dinners, too.”
And just then, there seemed to be the twinkle of a little star of Hope
lighting up that devious, unknown path which he was so soon to
tread.
“I’ll let him give me a Club card,” he mused, as the wearied
passengers hurried along to brave the din of importunate jehus.
He was wondering how much of a social show he could make at
need with his slender fortune, when the two men slowly approached
with three “shining ones” of the golden strata of womanly New York.
“These people are all in the swim,” he murmured. “I will find the way!
I am as good as any of them.”
And as he raised his eyes, he met the glances of the imperial-looking
woman who was Fred Hathorn’s companion.
The lady’s eyes rested for a moment upon the handsome stranger,
and then fell with a peculiar abruptness.
“If that woman plays any star part in his life, I will try and take her
away from him,” resolved Vreeland, whose whole soul was now
thrilling with the beautiful woman’s sudden, startled admission of
interest in a passing stranger. The wine of life stirred in the young
wanderer’s veins.
His audacious, familiar sprite suggested the profound bow which
was Mr. Harold Vreeland’s first salutation upon the outskirts of the
“Four Hundred.”
He had adroitly managed to convey the respectful homage of the
salutation by his velvety eyes to the very person intended, for, while
Jimmy Potter was placidly listening to the brilliant chatter of two very
vivacious rosebuds, Mrs. Elaine Willoughby turned to Hathorn:
“Fred, who is your Western friend?” she asked, with an assumed
carelessness.
It was by sheer good luck that Hathorn, who was watching the young
millionairess whom he was soon to marry, answered with an unusual
warmth:
“An old college chum—Vreeland of Princeton, and a rattling good
fellow.”
Fred Hathorn eyed with a certain qualminess the easy aplomb of his
Crœsus partner, as Jimmy Potter pressed closely to the side of
Hathorn’s destined bride, Miss Moneybags.
That young lady was destined to play the rôle of Queen of Diamonds
in the ambitious young banker’s life.
He had resolutely set up the motto, “Aut Cæsar, aut nullus,” and he
was just a bit shy of the beloved James trifling with his dashing
fiancée.
“All sorts of things happen in New York,” mused the agnostic
Hathorn, as he handed the ladies into a waiting victoria and then
turned to rejoin the man who more than ever had now decided to
paddle a bit, as well as to drift on with the tide of fortune.
There was a glow of satisfaction burning in the Western adventurer’s
heart as, half an hour later, he noted Hathorn dash off his potent
signature behind his guest’s name on the visitor’s book of the Old
York Club. It was the open sesame to the regions of the blest—
young New York par excellence.
The trio adjourned to the billiard room, and, then and there, Vreeland
for the first time tasted the famous club cocktail.
He was “living up to his blue china,” as he gravely bowed when
Hathorn gave him a two-weeks’ card.
“I’ll have it renewed for you, old fellow,” lightly remarked the young
banker.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like