Skip to content

Assertion gets thrown when app runs when screen of mobile is turned off using power button #129611

@abhineetchandan

Description

@abhineetchandan

Is there an existing issue for this?

Steps to reproduce

Not tested on iOS, because the application is android only.

  1. Created a sample app using flutter create bug.
  2. After running the sample application modify the main.dart file with the code given in code sample section.
  3. Before running it on a real android device, "Make sure the screen of mobile is turned off and locked, by pressing the power button."
  4. Run the app and see the crash. If the screen of mobile is turned on, it doesn't crash.
  5. Also, before doing another test, the app must be uninstalled or it doesn't crash.

Expected results

It should build successfully and run without any errors.

Actual results

When the screen of mobile device is turned off and the app is run, it throws many errors.

Code sample

Code sample
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: SafeArea(
          child: LayoutBuilder(builder: (context, constraints) {
            if (constraints.maxWidth > 500) {
              return SingleChildScrollView();
            }
            return SingleChildScrollView(
              child: Column(
                children: [
                  Padding(
                    padding: const EdgeInsets.only(top: 32),
                    child: Text("My Home Page",
                        style:
                        Theme.of(context).textTheme.displayLarge?.copyWith(
                          fontSize: 60,
                        )),
                  ),
                  Padding(
                    padding: const EdgeInsets.all(32),
                    child: Text(
                      "Name",
                      style: Theme.of(context).textTheme.titleLarge,
                    ),
                  ),
                  Padding(
                    padding: const EdgeInsets.fromLTRB(16.0,16.0,16.0, 0),
                    child: Form(
                      child: Container(
                        constraints: BoxConstraints(
                          minWidth: 0.0,
                          maxWidth: MediaQuery.of(context).size.width,
                        ),
                        child: TextFormField(
                            maxLength: 20,
                            initialValue: "",
                            onChanged: (value) {
                              //Handle name change
                            },
                            decoration: const InputDecoration(
                              disabledBorder: OutlineInputBorder(
                                borderSide: BorderSide(
                                  color: Color(0xFF6200EE),
                                ),
                              ),
                              prefixIcon: Icon(Icons.person),
                              labelText: "Name",
                              helperText: "Enter Name",
                              enabledBorder: OutlineInputBorder(
                                borderSide: BorderSide(
                                  color: Color(0xFF6200EE),
                                ),
                              ),
                            ),
                            validator: (value) {
                              if (value!.isEmpty) {
                                return "nameMustNotBeEmpty";
                              } else if (value.length < 3) {
                                return "nameMustHave3OrMoreCharacters";
                              } else {
                                return null;
                              }
                            }),
                      ),
                    ),
                  ),
                  const SizedBox(
                    height: 30,
                  ),
                  ElevatedButton(
                      onPressed: () {
                        //Handle button press
                      },
                      child: const Icon(Icons.done_outlined)),
                ],
              ),
            );
          }),
        ),
      ),
    );
  }
}

Screenshots or Video

No response

Logs

Logs https://pastebin.com/UsReMKV0

Flutter Doctor output

Doctor output
C:\Users\lenovo>flutter doctor -v
[√] Flutter (Channel stable, 3.10.1, on Microsoft Windows [Version 10.0.22621.1778], locale en-US)
• Flutter version 3.10.1 on channel stable at C:\Users\lenovo\AppData\Local\Flutter\flutter_windows_2.10.3-stable\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision https://github.com/flutter/flutter/commit/d3d8effc686d73e0114d71abdcccef63fa1f25d2 (6 weeks ago), 2023-05-16 17:59:05 -0700
• Engine revision b4fb11214d
• Dart version 3.0.1
• DevTools version 2.23.1

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0-rc4)
• Android SDK at G:\Android\Sdk
• Platform android-UpsideDownCake, build-tools 34.0.0-rc4
• ANDROID_HOME = G:\Android\Sdk
• Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)
• All Android licenses accepted.

[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.11.2)
• Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
• Visual Studio Community 2019 version 16.11.31624.102
• Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 2022.2)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)

[√] VS Code (version 1.79.2)
• VS Code at C:\Users\lenovo\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.66.0

[√] VS Code (version 1.79.0-insider)
• VS Code at C:\Users\lenovo\AppData\Local\Programs\Microsoft VS Code Insiders
• Flutter extension version 3.64.0

[√] Connected device (1 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22621.1778]

[√] Network resources
• All expected network resources are available.

• No issues found!

Metadata

Metadata

Labels

P3Issues that are less important to the Flutter projecta: error messageError messages from the Flutter frameworka: text inputEntering text in a text field or keyboard related problemsc: crashStack traces logged to the consolefound in release: 3.10Found to occur in 3.10found in release: 3.12Found to occur in 3.12frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-androidOwned by Android platform teamtriaged-androidTriaged by Android platform team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions