add thumbnails to the books example to make memory leaks easier to test (#1353)

* add thumbnails to the books example to make memory leaks easier to test

* also add profile build

* migrate material 3 demo code to avoid warning

* Revert "migrate material 3 demo code to avoid warning"

This reverts commit 7df37d9f65.

* fix lints in various packages

* DoNothingAndStopPropagationIntent const conflicts between stable and beta, add lint ignore for now
pull/1389/head
xster 2 years ago committed by GitHub
parent dd7306bb5e
commit ce35e45702
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -17,9 +17,13 @@ android {
}
buildTypes {
profile {
initWith debug
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig debug.signingConfig
}
}
compileOptions {

@ -94,6 +94,9 @@ class MainActivity : AppCompatActivity() {
book.summary = volumeInfoJson.get("description").asString
book.publishDate = volumeInfoJson.get("publishedDate").asString
book.pageCount = volumeInfoJson.get("pageCount").asLong
val thumbnail = Api.Thumbnail()
thumbnail.url = volumeInfoJson.getAsJsonObject("imageLinks").get("thumbnail").asString
book.thumbnail = thumbnail
books.add(book)
} catch (e: Exception) {
println("Failed to parse book:")

@ -96,6 +96,9 @@ class _BookDetailState extends State<BookDetail> {
}));
}
// Not overriding didUpdateWidget because the Android program can't change
// the book given to Flutter on the Android side.
void clear() {
book = null;
// Keep focus if going to the home screen but unfocus if leaving
@ -209,21 +212,29 @@ class BookForm extends StatelessWidget {
),
const Divider(),
const SizedBox(height: 32),
const Center(
child: Text(
'BOOK DESCRIPTION',
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
decoration: TextDecoration.underline,
if (book.thumbnail?.url != null) ... [
Center(
child: Image.network(book.thumbnail!.url!),
),
const SizedBox(height: 32),
],
if (book.summary != null) ... [
const Center(
child: Text(
'BOOK DESCRIPTION',
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
decoration: TextDecoration.underline,
),
),
),
),
const SizedBox(height: 12),
Text(
book.summary ?? '',
style: TextStyle(color: Colors.grey.shade600, height: 1.24),
),
const SizedBox(height: 12),
Text(
book.summary ?? '',
style: TextStyle(color: Colors.grey.shade600, height: 1.24),
),
]
],
),
);

@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 51;
objectVersion = 50;
objects = {
/* Begin PBXBuildFile section */
@ -113,7 +113,7 @@
0DDE4C3325E0390700389930 /* Sources */,
0DDE4C3425E0390700389930 /* Frameworks */,
0DDE4C3525E0390700389930 /* Resources */,
F82F2089B06A5489DA98C8B9 /* [CP] Embed Pods Frameworks */,
CA4628050A0CDB5CBFD737AD /* [CP-User] Embed Flutter Build flutter_module_books Script */,
);
buildRules = (
);
@ -203,22 +203,15 @@
shellPath = /bin/sh;
shellScript = "set -e\nset -u\nsource \"${SRCROOT}/../flutter_module_books/.ios/Flutter/flutter_export_environment.sh\"\nexport VERBOSE_SCRIPT_LOGGING=1 && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/xcode_backend.sh build";
};
F82F2089B06A5489DA98C8B9 /* [CP] Embed Pods Frameworks */ = {
CA4628050A0CDB5CBFD737AD /* [CP-User] Embed Flutter Build flutter_module_books Script */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-IosBooks/Pods-IosBooks-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-IosBooks/Pods-IosBooks-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
name = "[CP-User] Embed Flutter Build flutter_module_books Script";
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-IosBooks/Pods-IosBooks-frameworks.sh\"\n";
showEnvVarsInLog = 0;
shellScript = "set -e\nset -u\nsource \"${SRCROOT}/../flutter_module_books/.ios/Flutter/flutter_export_environment.sh\"\nexport VERBOSE_SCRIPT_LOGGING=1 && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/xcode_backend.sh embed_and_thin";
};
/* End PBXShellScriptBuildPhase section */
@ -381,6 +374,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = IosBooks/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
@ -403,6 +397,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = IosBooks/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",

@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1320"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "0DDE4C3625E0390700389930"
BuildableName = "IosBooks.app"
BlueprintName = "IosBooks"
ReferencedContainer = "container:IosBooks.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "0DDE4C3625E0390700389930"
BuildableName = "IosBooks.app"
BlueprintName = "IosBooks"
ReferencedContainer = "container:IosBooks.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "0DDE4C3625E0390700389930"
BuildableName = "IosBooks.app"
BlueprintName = "IosBooks"
ReferencedContainer = "container:IosBooks.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

@ -47,7 +47,10 @@ class ViewController: UITableViewController, BKHostBookApi {
let authors = (volumeInfo["authors"] as! [String]).joined(separator: " & ")
let pageCount = volumeInfo["pageCount"] as! Int32
let publishedDate = volumeInfo["publishedDate"] as! String
let summary = volumeInfo["description"] as! String
let summary = volumeInfo["description"] as! String?
let imageLinks = volumeInfo["imageLinks"] as! [String: Any]
let thumbnail: BKThumbnail = BKThumbnail.init()
thumbnail.url = imageLinks["thumbnail"] as! String?
let book: BKBook = BKBook.init()
book.author = authors
book.title = title
@ -56,6 +59,7 @@ class ViewController: UITableViewController, BKHostBookApi {
book.pageCount = NSNumber.init(value: pageCount)
book.publishDate = publishedDate
book.summary = summary
book.thumbnail = thumbnail
newBooks.append(book)
}
DispatchQueue.main.async {

@ -34,7 +34,10 @@ class _HomePageState extends State<HomePage> {
Padding(
padding: const EdgeInsets.all(8.0),
child: TextButton(
style: TextButton.styleFrom(primary: Colors.white),
style: TextButton.styleFrom(
// ignore: deprecated_member_use
primary: Colors.white,
),
onPressed: () => _handleSignOut(),
child: const Text('Sign Out'),
),

@ -27,7 +27,10 @@ class _FormValidationDemoState extends State<FormValidationDemo> {
Padding(
padding: const EdgeInsets.all(8),
child: TextButton(
style: TextButton.styleFrom(primary: Colors.white),
style: TextButton.styleFrom(
// ignore: deprecated_member_use
primary: Colors.white,
),
child: const Text('Submit'),
onPressed: () {
// Validate the form by getting the FormState from the GlobalKey

@ -114,8 +114,10 @@ class ButtonsWithoutIcon extends StatelessWidget {
ElevatedButton(
style: ElevatedButton.styleFrom(
// Foreground color
// ignore: deprecated_member_use
onPrimary: Theme.of(context).colorScheme.onPrimary,
// Background color
// ignore: deprecated_member_use
primary: Theme.of(context).colorScheme.primary,
).copyWith(elevation: ButtonStyleButton.allOrNull(0.0)),
onPressed: handlePressed(context, isDisabled, "FilledButton"),
@ -125,8 +127,10 @@ class ButtonsWithoutIcon extends StatelessWidget {
ElevatedButton(
style: ElevatedButton.styleFrom(
// Foreground color
// ignore: deprecated_member_use
onPrimary: Theme.of(context).colorScheme.onSecondaryContainer,
// Background color
// ignore: deprecated_member_use
primary: Theme.of(context).colorScheme.secondaryContainer,
).copyWith(elevation: ButtonStyleButton.allOrNull(0.0)),
onPressed: handlePressed(context, isDisabled, "FilledTonalButton"),
@ -166,8 +170,10 @@ class ButtonsWithIcon extends StatelessWidget {
ElevatedButton.icon(
style: ElevatedButton.styleFrom(
// Foreground color
// ignore: deprecated_member_use
onPrimary: Theme.of(context).colorScheme.onPrimary,
// Background color
// ignore: deprecated_member_use
primary: Theme.of(context).colorScheme.primary,
).copyWith(elevation: ButtonStyleButton.allOrNull(0.0)),
onPressed: handlePressed(context, false, "FilledButton with Icon"),
@ -178,8 +184,10 @@ class ButtonsWithIcon extends StatelessWidget {
ElevatedButton.icon(
style: ElevatedButton.styleFrom(
// Foreground color
// ignore: deprecated_member_use
onPrimary: Theme.of(context).colorScheme.onSecondaryContainer,
// Background color
// ignore: deprecated_member_use
primary: Theme.of(context).colorScheme.secondaryContainer,
).copyWith(elevation: ButtonStyleButton.allOrNull(0.0)),
onPressed:

@ -469,7 +469,10 @@ class _AddPlaceButtonBar extends StatelessWidget {
alignment: MainAxisAlignment.center,
children: [
ElevatedButton(
style: ElevatedButton.styleFrom(primary: Colors.blue),
style: ElevatedButton.styleFrom(
// ignore: deprecated_member_use
primary: Colors.blue,
),
onPressed: onSavePressed,
child: const Text(
'Save',
@ -477,7 +480,10 @@ class _AddPlaceButtonBar extends StatelessWidget {
),
),
ElevatedButton(
style: ElevatedButton.styleFrom(primary: Colors.red),
style: ElevatedButton.styleFrom(
// ignore: deprecated_member_use
primary: Colors.red,
),
onPressed: onCancelPressed,
child: const Text(
'Cancel',
@ -514,9 +520,11 @@ class _CategoryButtonBar extends StatelessWidget {
children: [
ElevatedButton(
style: ElevatedButton.styleFrom(
primary: selectedPlaceCategory == PlaceCategory.favorite
? Colors.green[700]
: Colors.lightGreen),
// ignore: deprecated_member_use
primary: selectedPlaceCategory == PlaceCategory.favorite
? Colors.green[700]
: Colors.lightGreen,
),
child: const Text(
'Favorites',
style: TextStyle(color: Colors.white, fontSize: 14.0),
@ -525,9 +533,11 @@ class _CategoryButtonBar extends StatelessWidget {
),
ElevatedButton(
style: ElevatedButton.styleFrom(
primary: selectedPlaceCategory == PlaceCategory.visited
? Colors.green[700]
: Colors.lightGreen),
// ignore: deprecated_member_use
primary: selectedPlaceCategory == PlaceCategory.visited
? Colors.green[700]
: Colors.lightGreen,
),
child: const Text(
'Visited',
style: TextStyle(color: Colors.white, fontSize: 14.0),
@ -536,9 +546,11 @@ class _CategoryButtonBar extends StatelessWidget {
),
ElevatedButton(
style: ElevatedButton.styleFrom(
primary: selectedPlaceCategory == PlaceCategory.wantToGo
? Colors.green[700]
: Colors.lightGreen),
// ignore: deprecated_member_use
primary: selectedPlaceCategory == PlaceCategory.wantToGo
? Colors.green[700]
: Colors.lightGreen,
),
child: const Text(
'Want To Go',
style: TextStyle(color: Colors.white, fontSize: 14.0),

@ -90,7 +90,10 @@ class _CartTotal extends StatelessWidget {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Buying not supported yet.')));
},
style: TextButton.styleFrom(primary: Colors.white),
style: TextButton.styleFrom(
// ignore: deprecated_member_use
primary: Colors.white,
),
child: const Text('BUY'),
),
],

@ -39,6 +39,7 @@ class MyLogin extends StatelessWidget {
Navigator.pushReplacementNamed(context, '/catalog');
},
style: ElevatedButton.styleFrom(
// ignore: deprecated_member_use
primary: Colors.yellow,
),
child: const Text('ENTER'),

@ -697,16 +697,21 @@ class BasicTextInputClientState extends State<BasicTextInputClient>
<ShortcutActivator, Intent>{
// Activation
const SingleActivator(LogicalKeyboardKey.space):
// ignore: prefer_const_constructors
DoNothingAndStopPropagationIntent(),
// Scrolling
const SingleActivator(LogicalKeyboardKey.arrowUp):
// ignore: prefer_const_constructors
DoNothingAndStopPropagationIntent(),
const SingleActivator(LogicalKeyboardKey.arrowDown):
// ignore: prefer_const_constructors
DoNothingAndStopPropagationIntent(),
const SingleActivator(LogicalKeyboardKey.arrowLeft):
// ignore: prefer_const_constructors
DoNothingAndStopPropagationIntent(),
const SingleActivator(LogicalKeyboardKey.arrowRight):
// ignore: prefer_const_constructors
DoNothingAndStopPropagationIntent(),
};

Loading…
Cancel
Save