100% found this document useful (1 vote)
22 views

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

Flutter

Uploaded by

drnekmbiabo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
22 views

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

Flutter

Uploaded by

drnekmbiabo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

Experience Seamless Full Ebook Downloads for Every Genre 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

Explore and download more ebook at https://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
Discovering Diverse Content Through
Random Scribd Documents
neat appearance of which exceeded all our expectations. My sons
had not patience to wait, but had broken the cocoa-nuts, and already
convinced themselves of their delicious flavour; and then they fell to
making spoons with the fragments of the shells. The little monkey,
thanks to the kind temper of Jack, had been served the first, and
each amused himself with making him suck the corner of his pocket-
handkerchief, dipped in the milk of the cocoa-nut. He appeared
delighted with the treatment he received, and we remarked with
satisfaction, that we should most likely be able to preserve him.
The boys were preparing to break some more of the nuts with the
hatchet, after having drawn out the milk through the three little holes
which I have already observed are found near the stalk of the cocoa-
nut, and which are guarded by a soft substance which may easily be
pierced. I pronounced the word halt, and bade them bring me a saw;
the thought struck me, that by dividing the nuts carefully with this
instrument, the two halves when emptied, would remain with the
form of some well looking tea-cups or basons already made to our
hands. Jack, who was on every occasion the most active, brought
me a saw. I performed my undertaking in the best manner I could,
and in a short time each of us was provided with a convenient
receptacle for food. Accordingly my wife put the share of soup which
belonged to each, into those basons or vessels. The excellent
creature appeared delighted that we should no longer be under the
necessity, as before, of scalding our fingers by dipping into the pot;
and I firmly believe, that never did the most magnificent service of
china occasion half the pleasure to its possessor, as our utensils,
manufactured by our own hands from gourds and cocoa-nuts,
excited in the kind heart of my wife. Fritz asked me if he might not
invite our company to taste his fine champain, which he said would
not fail to make us all the merrier.
I have not the least objection, answered I, but remember to taste it
yourself, before you serve it to your guests.
He ran to draw out the stopple and to taste it.......How unfortunate!
said he, it is already turned to vinegar.
What is it? vinegar, did you say? exclaimed my wife. How lucky! it
will make the most delicious sauce for our bird, mixed with the fat
which has fallen from it in roasting, and will be as good a relish as a
salad. No sooner said than done. This vinegar produced from cocoa-
nut proved a most agreeable corrective of the wild and fishy flavour
of the penguin, and without which I am afraid we should have found
it not very palatable. The same sauce considerably improved our
dish of fish also. Each boasted most of what he himself had been the
means of procuring; it was Jack and Francis who had caught the fish
in one of the shallows, while Ernest was employed with very little
trouble to himself in securing his penguin the stupid. My poor wife
had herself performed the most difficult task of all, that of rolling the
cask of Dutch cheeses into the kitchen, and then knocking out its
head. But if it was she who had most exerted herself, it was she also
who received the highest commendations; for one and all agreed,
that nothing we had tasted since we left the ship, was half so
agreeable to our appetites as this cheese which she served for our
dessert.
By the time we had finished our meal, the sun was retiring from
our view; and recollecting how quickly the night would fall upon us,
we were in the greatest haste to regain our place of rest. My wife
had considerately procured for us a tenfold quantity of dry grass,
which she had spread in the tent, so that we anticipated with joy the
prospect which was now afforded, of stretching our limbs on a
substance somewhat approaching to the quality of mattresses, while,
the night before, our bodies seemed to touch the ground. Our whole
flock of fowls placed themselves as they had done the preceding
evening; we said our prayers, and, with an improved serenity of
mind, lay down in the tent, taking the young monkey with us, who
was become the little favourite of all. Fritz and Jack contended for a
short time which should enjoy the honour of his company for the
night; and it was at last decided that he should be laid between
them; after which, each would have a hand in covering him carefully,
that he might not catch cold. We now all lay down upon the grass, in
the order of the night before, myself remaining last to fasten the sail-
cloth in front of the tent; when heartily fatigued by the exertions of
the day, I as well as the rest soon fell into a profound and refreshing
sleep.
But I had not long enjoyed this pleasing state, when I was
awakened by the motion of the fowls on the ridge of the tent, and by
a violent barking of our vigilant safeguards, the dogs. I rushed out
instantly; my wife and Fritz, who had also been alarmed by the
noise, followed my example: we each took a gun, and sallied forth to
their assistance. Shall you, my dearest, have the courage to fire, if it
should be necessary? said I to my wife.
Most certainly, said she, if, as you say, it should be necessary. I
can depend upon myself for daring to do whatever can be the means
of preservation to our dear children. At the same time it would
perhaps be better that I should leave to you the task of firing, while I
can undertake to load your guns, and to hand them to you as fast as
you may want them.
Best of all, said I; so let us not lose a moment in examining what
enemy it is we have to deal with. Our dogs continued barking with
the same violence, and at intervals even howled. We had not
proceeded many steps from the tent, when, to our great
astonishment, we perceived by the light of the moon a terrible
combat. At least a dozen of jackalls had surrounded our brave dogs,
who defended themselves with an almost unexampled courage.
Already the fierce champions had laid three or four of their
adversaries on the ground, while those which remained began to
make a timid kind of noise, as if imploring pity and forbearance.
Meanwhile they did not the less endeavour to entangle and surprise
the dogs, when thrown off their guard, and thus secure themselves
the advantage. But our watchful combatants were not so easily to be
deceived; they took good care not to let the enemy approach them
too nearly.
I, for my part, apprehended something much worse than jackalls.
We shall soon manage to set these gentlemen at rest, said I. Let us
fire both together, my boy; but let us take care how we aim, for fear
of killing the dogs; your mother shall give us the word of command;
mind how you fire, that you may not miss, and I shall do the same.
We fired, and two of the intruders fell instantly dead upon the sands.
The others made their escape; but we perceived it was with great
difficulty, in consequence, no doubt, of being wounded. Turk and
Ponto afterwards pursued them, and put the finishing stroke to what
we had begun; and thus the battle ended: but the dogs, true
Caribees by nature, made a hearty meal on the flesh of their fallen
enemies. Their doing this was a proof of the keen hunger they
experienced; for dogs do not readily feed on foxes, and the jackall is
a more fierce and mischievous species of the fox, than the animal
known by that name in Europe. My wife, seeing that all was now
quiet, entreated us to lie down again and finish our night’s sleep; but
Fritz asked my permission to let him first drag the jackall he had
killed, towards the tent, that he might be able to exhibit him the next
morning to his brothers. Having obtained my consent, he ran to fetch
him, and, with great difficulty, succeeded in his plan, the animal
being of the size of a large dog. I however observed to Fritz, that if
Turk and Ponto were still hungry, we ought to give them this last
jackall in addition, as a recompense for their courageous behaviour.
We had now done with this affair. The body of the jackall was left
on the rock, by the side of the tent, in which were the little sleepers,
who had not once awaked during the whole of the scene which had
been passing. Having therefore nothing further to prevent us, we lay
down by their side till day began to break, and till the cocks, with
their shrill morning salutation, awoke us both. The children being still
asleep, afforded us an excellent opportunity to consult together
respecting the plan we should pursue for the ensuing day.
CHAPTER V.
Return to the wreck.

I broke a silence of some moments, with observing to my wife,


that I could not conquer my alarm at the view of so many cares and
such a variety of exertions to be made! In the first place, a journey to
the vessel. This is of absolute necessity; at least, if we would not be
deprived of the cattle and various other useful things, all of which
from moment to moment we ran the risk of losing, by the first
approach of a heavy sea. On the other hand, there are so many
things to think of, and so much exertion is to be made, for the
comfort of all in this desert spot! What ought we to resolve upon? For
example,—is it not, above all, necessary to contrive a better kind of
habitation, and also the means of procuring a more secure retreat
from wild beasts, for ourselves, and some separate place of
accommodation for our provisions? I own I am at a loss what to
begin upon first.
All will fall into the right order by degrees, observed my wife;
patience and regularity in our plans will go as far as actual labour. I
cannot, I confess, help shuddering at the thought of this voyage to
the vessel; but if you judge it to be of absolute necessity, it appears
to me that it cannot be undertaken too soon. In the mean while,
nothing that is immediately under my own care shall stand still, I
promise you. Let us not be over anxious about the morrow; sufficient
unto the day is the evil thereof. These were the words of the great
and true friend of mankind, and let us use so wise a counsel for our
own benefit.
I will follow your advice, said I, and without further loss of time. You
shall stay here with the three youngest boys; and Fritz, being so
much stronger and more intelligent than the others, shall accompany
me in the undertaking.
At this moment I started from my bed, crying out loudly and briskly:
Get up, children, get up; it is almost light, and we have some
important projects for today; it would be a shame to suffer the sun to
find us still sleeping, we who are to be the founders of a new colony!
At these words Fritz sprang nimbly out of the tent, while his little
brothers began to gape and rub their eyes, to get rid of their
sleepiness. Fritz ran to visit his jackall, which during the night had
become cold and perfectly stiff. He fixed him upon his legs, and
placed him to look like a sentinel at the entrance of the tent, joyously
expecting the wonder and exclamations of his little brothers at so
singular and unexpected an appearance. But no sooner had the
dogs caught a sight of him, than they began a horrible barking, and
set themselves in motion to fall upon him instantly, thinking he was
alive. Fritz had enough to do to restrain them, and succeeded only
by dint of coaxing and perseverance.
In the mean time, their barking had awaked the younger boys, and
they all ran out of the tent, curious to know what could be the
occasion. Jack was the first who appeared, with the young monkey
on his shoulders; but when the little creature perceived the jackall,
he sprang away in terror, and hid himself at the furthest extremity of
the grass which composed our bed; with which he covered himself
so completely, that scarcely could the tip of his nose be seen.
The children were much surprised at the sight of a yellow-coloured
animal standing without motion at the entrance of the tent. O
heavens! exclaimed Francis, and stepping back a few paces for fear;
it is a wolf! No, no, said Jack, going near the jackall and taking one
of his paws; it is a yellow dog, and he is dead; he does not move at
all. It is neither a dog nor a wolf, interrupted Ernest in a
consequential tone; do you not see that it is a golden fox? Best of all,
most learned professor! now exclaimed Fritz. So you can tell an
agouti, when you see him, but you cannot tell a jackall; for jackall is
the creature you see before you, and I killed him myself in the night!
Ernest.—In the night, you say, Fritz! In your sleep, I suppose.....
Fritz.—No, Mr. Ernest; not in my sleep, as you so good-naturedly
suppose, but broad awake, and on the watch to protect you from wild
beasts! But I cannot wonder at this mistake in one who does not
know the difference between a jackall and a golden fox!
Ernest.—You would not have known it either, if papa had not told
you.....
Come, come, my lads, I will have no disputes, said I. Fritz, you are
to blame in ridiculing your brother for the mistake he made. Ernest,
you are also to blame for indulging that little peevishness of yours.
But as to the animal, you all are right and all are wrong; for he
partakes at once of the nature of the dog, the wolf, and the fox; and
for his skin, it is really of a golden tint! The boys in an instant became
friends; and then followed questions, answers, and wonder in
abundance.
And now, my boys, let me remind you, that he who begins the day
without first addressing the Almighty, ought to expect neither
success nor safety in his undertakings. Let us therefore acquit
ourselves of this duty before we engage in any other occupation.
Having finished our prayers, the next thing thought of was breakfast;
for the appetites of young boys open with their eyes. Today their
mother had nothing to give them for their morning meal but some
biscuit, which was so hard and dry, that it was with difficulty we could
swallow it. Fritz asked for a piece of cheese to eat with it, and Ernest
spied about the second cask we had drawn out of the sea, and
which was standing in our kitchen, to discover whether, as we had all
imagined, it also contained some Dutch cheeses. In a minute or two
he came up to us, joy sparkling in his eyes. Papa, said he, if we had
but a little butter spread upon our biscuit, do you not think it would
improve it?
That indeed it would; but—if,—if; these never-ending ifs are but a
poor dependence. For my part, I had rather eat a bit of cheese with
my biscuit at once, than think of ifs, which bring us so meagre a
harvest.
Ernest.—Perhaps though, the ifs may be found to be worth
something, if we were to knock out the head of this cask.
Father.—What cask, my boy? and what are you talking of?
Ernest.—I am talking of this cask, which is filled with excellent salt
butter. I made a little opening in it with a knife; and see, I got out
enough of it to spread nicely upon this piece of biscuit.
That glutton instinct of yours for once is of some general use,
answered I; and justice requires that I should also commend, with
moderation, the excellence of your nose. But now let us profit by the
event. Who will have some butter on their biscuits? The boys
surrounded the cask in a moment, while I was in some perplexity as
to the safest and most speedy method of getting out its contents.
Fritz proposed taking off the topmost hoop, by which means one of
the ends could be got out. But this I objected to, observing, that we
should be careful not to loosen the staves, as the great heat of the
sun would not fail to melt the butter, which would run out, and thus
be wasted. The idea occurred to me, that I would make a hole in the
bottom of the cask, sufficiently large to take out a small quantity of
butter at a time; and I immediately set about manufacturing a little
wooden shovel, to use it for the purpose. All this succeeded vastly
well, and we sat down to breakfast, some biscuits and a cocoa-nut
shell full of salt butter being placed upon the ground, round which we
all assembled, and none of us failing from time to time to wish for a
fairy’s wand, to have enabled us to add a little milk from the cow, or
from some cocoa-nuts, to quench our thirst. We however toasted our
biscuit, and while it was hot applied the butter, and contrived, without
the fairy’s wand, to make a hearty breakfast.
Our dogs allowed us to finish our meal in tranquillity. They were
sleeping by our side; but I did not fail to remark, that their late
encounter with the jackalls had not concluded without their receiving
several wounds, which I now, for the first time, observed in various
parts of their body, and principally round their necks. Fearing that the
heat might bring on inflammation, I desired Jack, the valiant, to wash
a small quantity of the butter thoroughly in fresh water, and then to
anoint the wounds with it while they continued sleeping. This he
effected with much skill and tenderness. The dogs awoke, but did
not attempt the least resistance, seeming to be sensible of the
benefit he was conferring on them; they themselves assisted the
cure, by frequently licking the parts; so that in a few days they were
as well as before.
One of the things we must not forget to look for in the vessel, said
Fritz, is a spiked collar or two for our dogs, as a protection to them,
should they again be called upon to defend themselves from wild
beasts, which I fear it is too probable will be the case.
Oh! says Jack, I can make some spiked collars, if mamma will give
me a little help.
That I will most readily, my boy; for I should like to see what new
fancy has come into your head, cried mamma.
Yes, yes, pursued I, as many new inventions as you please; you
cannot better employ your time; and if you produce something
useful, you will be rewarded with the honour of our commendations.
But now we must think of setting ourselves to some occupation. You,
Mr. Fritz, who, from your superior age and discretion, enjoy the high
honour of being my privy counsellor, must make haste and get
yourself ready, and we will undertake today our voyage to the vessel,
to save and bring away whatever may be possible. You younger
boys will remain here, under the wing of your kind mother; I hope I
need not mention that I rely on your perfect obedience to her will,
and general good behaviour.
While Fritz was getting the boat ready, I looked about for a pole,
and put a piece of white linen to the end of it; this I drove into the
ground, in a place where it would be visible from the vessel; and I
concerted with my wife, that in case of any accident that should
require my immediate presence, they should take down the pole and
fire a gun three times as a signal of distress, in consequence of
which I would immediately return. But I gave her notice, that there
being so many things to accomplish on board the vessel, it was very
probable that we should not be able to return the same day; in which
case I, on my part, also promised to make them signals. My wife had
the courage and the good sense to consent to my plan. Though she
was well aware that it could not but be dangerous to pass a night
alone with the children, without my protection, she yet preferred the
risk, to that of my returning late from the vessel. She, however,
extorted from me a promise that we should pass the night in our
tubs, and not on board the ship. We took nothing with us but our
guns and a recruit of powder and shot, relying that we should find
plenty of provisions on board; yet I did not refuse to indulge Fritz in
the wish he expressed to let him take the young monkey, he feeling
the most eager impatience to see how the young creature would like
some milk from the cow or from a goat.
We embarked in silence, casting our anxious looks on the beloved
objects we were quitting. Fritz rowed steadily, and I did my best to
second his endeavours, by rowing from time to time, on my part, with
the oar which served me for a rudder. When we had reached to a
considerable distance, I remarked, that beside the opening by which
we had the first time made land, there was another that formed the
mouth of the river, running not far from that spot, and the current of
which was visible a good way into the sea.
To take advantage of this current, and to husband our strength by
means of it, was my first thought and my first care. Little as I knew of
the management of sea affairs, I however succeeded in keeping our
boat in the direction in which it ran, by which means we were drawn
gently on, till it had conducted us to within a short distance of the
vessel, without our having any other trouble than that of keeping in
the same line: at length, in consequence of the gradual diminution of
its force, we were again obliged to have recourse to our oars; but our
arms having now rested for some time, we were ready for new
exertions. A little afterwards we found ourselves safely arrived at the
cleft of the vessel, and fastened our boat securely to one of its
timbers.
Scarcely had we got out of the boat than Fritz proceeded with his
young monkey on his arm to the main deck, where he found all the
animals we had left on board assembled. I followed him with great
readiness, well pleased to observe the generous impatience he
betrayed, to relieve the wants of the poor abandoned creatures, who,
one and all, now saluted us by the cry or the sounds natural to its
species! It was not so much the want of food, as the desire of seeing
once more their accustomed human companions, which occasioned
them to manifest their joy in this manner, for they had a portion of the
food and water we had left them, still remaining. The first thing we
did was to put the young monkey to one of the goats, that he might
suck; and this he did with such evident pleasure, and such odd
grimaces, that he afforded us much amusement.—We next
examined the food and water of the other animals, taking away what
was half spoiled, and adding a fresh supply, that no anxiety on their
account might afterwards interrupt our enterprise. Nor did we neglect
the care of renewing our own strength by a plentiful repast.
While we were seated, and appeasing the calls of hunger, Fritz
and I consulted what should be our first occupation; when, to my
great surprise, the advice he gave was, that we should immediately
contrive a sail for our boat. In the name of Heaven, cried I, what
makes you think of such a thing at so critical a moment, and when
we have so many other things of indispensable necessity to
arrange? We will think of a sail when we have leisure, with all my
heart, for it is an affair which will take a considerable time to
accomplish. In reality, I experienced great uneasiness at the thought
of passing the night at a distance from my family.
All you say is very true, father, said Fritz; but let me confess the
truth, which is, that I found it very difficult to perform the task of
rowing for so long a time, though I assure you I did my best, and did
not spare my strength. I observed that, though the wind blew strong
in my face, the current nevertheless carried us on. Now, as we
cannot be benefited on our return by the current, I was thinking that
we might make the wind supply its place. Our boat will be very heavy
when we have loaded it with all the useful things we mean to take
away, and I am afraid I shall not be strong enough to row to land.
Now do you not think that a sail would be of great assistance?
Ah ha, Mr. Fritz! So you wish to spare yourself a little trouble, do
you? But to speak seriously, I perceive a great deal of good sense in
your argument, and think myself much obliged to my privy counsellor
for his good advice. The best thing we can do is, to take care and not
overload the boat, and thus avoid the danger of sinking, or of being
obliged to throw some of our stores over-board. Come then, let us
set to work upon your sail, which, if it saves your labour in rowing,
will be at least a little troublesome at present. Come along, and let us
look about for what we want.
I assisted Fritz to carry a pole strong enough to serve for a mast,
and another not so thick for a sail-yard. I directed him to make a hole
in a plank with a chisel, large enough for the mast to stand upright in
it.
I then went to the sail-chamber, and cut off from an ample piece of
sail-cloth enough to make a triangular sail: in the edges I made
holes, and passed cords through them. I then sought for a pulley,
that I might fasten it to the top of the mast, and thus be enabled to
raise and lower my sail at pleasure. Thus prepared, I hastened to
join Fritz, who was earnestly working at the mast. As soon as he had
done, we placed the plank that he had perforated, upon the fourth of
our tubs, and made it fast. The pulley was suspended from a ring at
the top of the mast, and the cord, attached to the sharpest angle of
the sail, was passed through it. The sail formed a right-angle
triangle, one side of which touched the mast, and was fastened to it.
The shortest side was also fastened with cords to a pole, stretching
from the mast beyond the circumference of our bark, and of which
one end was fastened to the mast, and the other, by means of a
cord, to the helm, in such a manner that I could, from my position,
either weather the sail, or let it go altogether. In the foremost and
hindmost bench of our little bark, we made holes with a piercer, and
passed cords through them, by means of which we could pass the
sail from the right to the left side of us, and back again, without being
obliged to turn the boat entirely round.
While I was thus occupied, Fritz had been taking observations
through a telescope of what was passing on land, and which we had
already done several times. He imparted the agreeable tidings that
all was still well with our dear family. He had distinguished his mother
walking tranquilly along the shore. He soon after brought me a small
streamer, which he had cut from a piece of linen, and which he
entreated me to tie to the extremity of the mast, and he appeared as
much delighted with the streamer as with the sail itself. He gave to
our machine the name of The Deliverance; and in speaking of it,
instead of calling it a boat, it was now always denominated the little
vessel. I could not withhold a smile at vanity like this, in such a
situation as ours; it gave me too an opportunity of observing the
operation of this prominent feature of human nature, in a lad of
fourteen years of age. I myself took great pleasure in seeing the little
streamer floating in the air, and in the respectable appearance of our
machine altogether.
But now, father, said Fritz, looking kindly on me as he spoke, as
you have eased me of the labour of rowing, it is my turn to take care
of you. I am thinking about making you a better-contrived rudder;
one that would enable you to steer the boat both with greater ease
and greater safety. Your thought would be a very good one, said I,
but that I am unwilling to lose the advantage of being able to proceed
this way and that, without being obliged to veer. I shall therefore fix
our oars in such a manner as to enable me to steer the raft from
either end. Accordingly, I fixed bits of wood to the stem and stern of
the vessel, in the nature of grooves, which were calculated to spare
us a great deal of trouble.
During these exertions the day became far advanced, and I
perceived that we should be obliged to pass the night in our tubs, not
having as yet entered upon our task of emptying the vessel. We had
promised our family to hoist a flag as a signal of our intention to pass
the night from home, and we decided that our streamer was
precisely the thing we wanted for this purpose.
We employed the rest of the day in emptying the tubs of the
useless ballast of stone, and putting in their place what would be of
service, such as nails, pieces of cloth, and different kinds of utensils,
&c. &c. The Vandals themselves could not have made a more
complete pillage than we had done. The prospect we seemed to
have of an entire solitude, made us devote our principal attention to
the securing as much powder and shot as might fall in our way, that
we might thus secure the means of catching animals for food, and of
defending ourselves against wild beasts to the latest moment
possible. Utensils also for every kind of workmanship, of which there
was a large provision in the ship, were also objects of incalculable
value to us. The vessel, which was now a wreck, had been sent out
as a preparation for the establishment of a colony in the South Seas,
and for that reason had been provided with a variety of stores not
commonly included in the loading of a ship. Among the rest, care
had been taken to have on board considerable numbers of European
cattle; but so long a voyage had proved unfavourable to the oxen
and the horses, the greatest part of which had died, and the others
were in so bad a condition that it had been found necessary to
destroy them. The quantity of useful things which presented
themselves in the store-chambers, made it difficult for me to select
among them, and I much regretted that circumstances compelled me
to leave some of them behind. Fritz, however, already meditated a
second visit; but we took good care not to lose the present occasion
for securing knives and forks and spoons, and a complete
assortment of kitchen utensils. In the captain’s cabin we found some
services of silver, dishes and plates of high-wrought metal, and a
little chest filled with bottles of all sorts of excellent wine. Each of
these articles we put into our boat. We next descended to the
kitchen, which we stripped of gridirons, kettles, pots of all kinds, a
small roasting-jack, &c. Our last prize was a chest of choice
eatables, intended for the table of the officers, containing Westphalia
hams, Bologna sausages, and other savoury food. I took good care
not to forget some little sacks of maize, of wheat, and other grain,
and some potatoes. We next added such implements for husbandry
as we could find;—shovels, hoes, spades, rakes, harrows, &c. &c.
Fritz reminded me that we had found sleeping on the ground both
cold and hard, and prevailed upon me to increase our cargo by some
hammocks, and a certain number of blankets: and as guns had
hitherto been the source of his pleasures, he added such as he
could find of a particular costliness or structure, together with some
sabres and clasp knives. The last articles we took, were a barrel of
sulphur, a quantity of ropes, some small string, and a large roll of
sail-cloth. The vessel appeared to us to be in so wretched a
condition, that the coming on of the least tempest must make her go
to pieces.
It was then quite uncertain whether we should be able to approach
her any more.
Our cargo was so considerable, that the tubs were filled to the
very brim, and no inch of the boat’s room was lost. The first and last
of the tubs were reserved for Fritz and me to seat ourselves in and
row the boat, which sunk so low in the water, that, if the sea had
been otherwise than quite calm, we should have been obliged to
ease her of some of the loading: we, however, used the precaution
of putting on our swimming-jackets, for fear of any misfortune.
It will easily be imagined that every moment of the day had been
laboriously employed. Night suddenly surprised us, and it was no
longer possible to form a hope of returning to our family the same
evening. A large blazing fire on the shore soon after greeted our
sight,—the signal we had agreed upon for assuring us that all was
well, and to bid us close our eyes in peace. We returned the
compliment by tying four lanterns with lights in them to our mast-
head. This was answered on their part, according to agreement, by
the firing of two guns; so that both parties had reason to be satisfied
and easy.
After offering up our earnest prayers for the safety and happiness
of all, yet not without some apprehension for the night, we resigned
ourselves to sleep in our tubs, which, it must be confessed, did not
afford us a very enviable place of rest: they were, however, safer
than the vessel, and more convenient for guarding our heavily
loaded machine. At the least cracking of the vessel, we might cut the
rope in an instant, and get out to sea. Our night, thank God, passed
tranquilly enough: my boy Fritz slept as soundly as if he had been in
a bed; while I, notwithstanding my fatigue, could neither close my
eyes, nor keep them from the direction of the shore, perpetually
haunted by the recollection of the nocturnal visit of the jackalls, some
of whose race I feared might come and enter the tent. I had,
however, great reliance that my valiant dogs would do their duty, and
was thankful to Heaven for having enabled us to preserve so good a
protection.
CHAPTER VI.
A troop of animals in cork jackets.

Early the next morning, though it was scarcely light enough to


distinguish the coast, I was already on the deck of the vessel,
endeavouring to have a sight of the beloved inhabitants of the tent
through a spying-glass. Fritz speedily prepared a good substantial
breakfast of biscuit and ham; but before we sat down to this
refreshment, we recollected that in the captain’s cabin we had seen
a telescope of a much superior size and power, and we hastily
conveyed it upon the deck. While this was doing, the brightness of
the day had succeeded to the imperfect light of an earlier hour. I
eagerly fixed my eye to the glass, and discovered my wife coming
out of the tent and looking attentively towards the vessel, and we at
the same moment perceived the motion of the flag upon the shore. A
load of care and solicitude was thus taken from my heart; for now I
had obtained the certainty that the beloved beings I had left were all
in good health, and had escaped the dangers of the night. Fritz, said
I to my boy, I thought this morning that it would be impossible for me
to remain another moment on board the vessel, without returning to
see what was passing in the island; but now that I have had a sight
of your mother, and an assurance of their being well and safe, my
compassion is awakened for the poor creatures on board, who are in
so wretched a condition, and every hour in danger of destruction: a
great object of my anxiety now, is to endeavour to save the lives of
some of them at least, and to take them with us to the shore.
Would it be impossible to construct a raft, to get them all upon it,
and in this way afford them a conveyance? said Fritz.
But recollect, my boy, what a difficulty we should find in completing
such a raft, and that a greater still would be to induce a cow, an ass,
and a sow, either to get upon a raft, or, when there, to remain
motionless and quiet. The sheep and goats one might perhaps find
means to remove, they being of a more accommodating temper; but
for the larger animals, I am quite at a loss how to proceed. Do you
consider of it, and tell me what thoughts occur to your young and
active imagination.
My advice, father, is, to tie a long rope round the sow’s neck, and
throw her without ceremony into the sea: her immense weight will be
sure to sustain her above water; and we can easily get hold of the
other end of the rope and draw her after the boat.
Your idea is excellent, my boy: but unfortunately it cannot be
applied to any of the animals except the pig; and I confess, she is
the one I care the least about preserving.
Then here is another idea, father: let us tie a swimming-jacket
round the body of each animal, and contrive to throw them into the
water; you will see that they will swim like fish, and we can draw
them after us in the same manner.
Right, very right, my boy; your invention is admirable: let us
therefore not lose a moment in making the experiment.
We accordingly hastened to the execution of our design: we fixed
on a jacket to one of the lambs, and threw it into the sea; and full of
fear, of hope, and anxious curiosity, I followed the poor animal with
my eyes. He sunk at first under water, and I thought he was
drowned; but he soon re-appeared, shaking the water from his head,
and in a few seconds we perceived that he had learned completely
the art of swimming. After another interval, we observed that he
appeared fatigued, gave up his efforts, and suffered himself without
resistance to be borne along by the course of the water, which
conducted and sustained him to our complete satisfaction. Victory!
exclaimed I, hugging my boy with delight: these useful animals are
all our own; let us not lose a moment in adopting the same measures
with those that remain, but take care not to lose our little lamb. Fritz
now would have jumped eagerly into the water to follow the poor
creature, who was still floating safely on the surface; but I stopped
him till I had seen him tie on one of the swimming-jackets, and then I
suffered him to go. He took with him a rope, first making a slip knot
in it, and, soon overtaking the lamb, threw it round his neck, and thus
drew him to our boat; and then, to his great content, drew him out of
the water.
We then went and looked out four small casks, such as had been
used for keeping the fresh water for the vessel. I first emptied them
of their contents, and then carefully closed them again; next I bound
them together with a large piece of sail-cloth, the two ends of which I
nailed to each. I strengthened this with a second piece of sail-cloth,
and this machine I destined to support the cow and the ass, two
casks to each, the animal being placed in the middle with a cask on
either side. The weight of the animal pressed down the sail-cloth,
and would have brought the casks into close contact on each side,
but that I took care to insert a wisp of hay or straw, to prevent
injurious friction or pressure. I added a thong of leather, stretching
from the casks across the breast and haunches of the animal, to
make the whole secure; and thus, in less than an hour, both my cow
and my ass were equipped for swimming.
It was next the turn of the smaller animals: of these, it was the sow
who gave us the most trouble; we were first obliged to put her on a
muzzle to prevent her biting; and this being done, we tied a large
piece of cork under her body. The sheep and goats were more
docile, and we had soon accoutred them for the expedition. And now
we had succeeded in assembling our whole company on the deck, in
readiness for the voyage: we tied a cord to either the horns or the
neck of each animal, and to the other end of the cord a piece of
wood similar to the mode used for marking nets, that it might be easy
for us to take hold of the ropes, and so draw the animal to us if it
should be necessary. We struck away some more of the shattered
pieces of wood from the side of the vessel, which only served to
encumber the cleft by which we had entered, and were again to pass
to put out to sea, when we should have completed our last work of
throwing the animals into it. We began our experiment with the ass,
by conducting him as near as possible to the brink of the vessel, and
then suddenly shoving him off. He fell into the water, and for a
moment disappeared; but we soon saw him rise, and in the action of
swimming between his two barrels, with a grace which really merited
our commendation.
Next came the cow’s turn; and as she was infinitely more valuable
than the ass, my fears increased in due proportion. The ass had
swum so courageously, that he was already at a considerable
distance from the vessel, so that there was sufficient room for our
experiment on the cow. We had more difficulty in pushing her
overboard, but she reached the water in as much safety as the ass
had done before; she did not sink so low in it, and was no less
perfectly sustained by the empty barrels; and she made her way on
the surface with gravity, and, if I may so express it, a sort of dignified
composure. According to this method we proceeded with our whole
troop, throwing them one by one into the water, where by and by
they appeared in a group floating at their ease, and seemingly well
content, at a short distance from the vessel. The sow was the only
exception; she became quite furious, set up a loud squalling, and
struggled with so much violence in the water, that she was carried to
a considerable distance, but fortunately in a direction towards the
landing-place we had in view for ourselves. We had now not a
moment to lose; our last act was to put on our cork-jackets; and then
we descended without accident through the cleft, took our station in
the boat, and were soon out to sea, surrounded by our troop of
quadrupeds. We carefully took up from the water, each of the floating
bits of wood which we had fastened to the ropes round the animals,
and thus drew them all after us by fastening the bits of timber to the
boat. When every thing was adjusted, and our company in order, we
hoisted our sail, which soon filling with a favourable wind conducted
us and our escort safe to the land.
We now perceived how impossible it would have been for us to
have executed our enterprise without the assistance of the sail; for
the weight of so many animals sunk the boat so low in the water, that
all our exertions to row to such a distance would have been
ineffectual; while by means of the sail, and the improvement I had
invented for the steering, she proceeded completely to our
satisfaction, bearing in her train our suite of animals; which produced
altogether the most singular effect. Proud of the success of so
extraordinary an enterprise, we were in high spirits, and seated
ourselves in the tubs, where we made an excellent dinner. Fritz
amused himself with the monkey, while I was wholly occupied in
thinking of those I had left on land, and of whom I now tried to take a
view through my telescope. My last act on board the vessel had
been to take one look more at them, and I perceived my wife and the
three boys all in motion, and seeming to be setting out on some
excursion; but it was in vain that I endeavoured, by any thing I saw,
to conjecture what their plan might be.
I therefore seized the first moment of quiet to make another trial
with my glass, when a sudden exclamation from Fritz filled me with
alarm. O heavens! cried he, we are lost! a fish of an enormous size
is coming up to the boat. And why lost? said I half angry, yet half
partaking of his fright. Be ready with your gun in an instant, and the
moment he is close upon us, let us both fire upon him at the same
instant. Our guns were each loaded with two balls, and we got up
from our tubs to give the intruder a hearty reception. He had nearly
reached the boat, and with the rapidity of lightning had seized the
foremost sheep: at this instant Fritz aimed his fire so skilfully, that the
balls were lodged in the head of the monster, which was an
enormous shark. The fish half turned himself round in the water and
hurried off to sea, leaving us to observe the lustrous smoothness of
his belly, and that as he proceeded, he stained the water red, which
convinced us he had been severely wounded. I determined to have
the best of our guns at hand the rest of the way, lest we should be
again attacked by the same fish, or another of his species.
Fritz had great reason to be proud of the achievement of having
forced the shark to retreat; whilst I on my part rather felt surprise; for
I had always understood that this kind of sea-monster was not easily
to be frightened from his purpose, and also that the heaviest load of
shot was rarely known to do him any injury, the creature being
extremely voracious of his prey, and his skin so hard, as to present
an extraordinary degree of resistance to all attempts of this kind. For
this time, however, the animal left us in tranquillity; I resumed the
rudder; and as the wind drove us straight towards the bay, I took
down the sail, and continued rowing till we reached a convenient
spot for our cattle to land. I then untied the end of the cords, which
had been fastened to the boat, and they stepped contentedly on
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