Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AlertDialog hidden by keyboard after adding flutter_native_splash: ^0.1.9 #39

Closed
zgramming opened this issue Dec 24, 2019 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@zgramming
Copy link

zgramming commented Dec 24, 2019

I know this issue so strange but it's happen to me, I don't know why after adding this package if i showing Alert Dialog , My dialog hidden by keyboard .
After running this command flutter pub pub run flutter_native_splash:create and running the app.

Using Flutter native splash Packages

alertdialog hidden by keyboard because using flutter native splash package

Source Code

import 'package:flutter/material.dart';

void main() {
  // WidgetsFlutterBinding.ensureInitialized();
  return runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(title: "Mateiral App", home: TestingPage());
  }
}

class TestingPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: FlatButton(
          color: Colors.red,
          onPressed: () => showDialog(
            context: context,
            builder: (ctxDialog) => SimpleDialog(),
          ),
          child: Text('Show Dialog'),
        ),
      ),
    );
  }
}

class SimpleDialog extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return AlertDialog(
      title: Text('Testing DIALOG'),
      content: TextFormField(
        decoration: InputDecoration(
          border: OutlineInputBorder(borderRadius: BorderRadius.circular(30)),
        ),
      ),
      actions: <Widget>[
        FlatButton.icon(
            onPressed: () => "", icon: Icon(Icons.add), label: Text('ttest')),
        FlatButton.icon(
            onPressed: () => "", icon: Icon(Icons.add), label: Text('ttest')),
      ],
    );
  }
}

Pubspec.yaml

name: flutter_native_splash_bug
description: A new Flutter application.
version: 1.0.0+1

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^0.1.2

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_native_splash: ^0.1.9
  flutter_launcher_icons: ^0.7.4

flutter_native_splash:
  image: assets/1.png
  color: "42a5f5"

flutter_icons:
  android: true
  ios: true
  image_path: "assets/1.png"
flutter:
  uses-material-design: true

Without Flutter Native Splash

alertdialog without flutter native splash

Source Code

import 'package:flutter/material.dart';

void main() {
  // WidgetsFlutterBinding.ensureInitialized();
  return runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(title: "Mateiral App", home: TestingPage());
  }
}

class TestingPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: FlatButton(
          color: Colors.red,
          onPressed: () => showDialog(
            context: context,
            builder: (ctxDialog) => SimpleDialog(),
          ),
          child: Text('Show Dialog'),
        ),
      ),
    );
  }
}

class SimpleDialog extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return AlertDialog(
      title: Text('Testing DIALOG'),
      content: TextFormField(
        decoration: InputDecoration(
          border: OutlineInputBorder(borderRadius: BorderRadius.circular(30)),
        ),
      ),
      actions: <Widget>[
        FlatButton.icon(
            onPressed: () => "", icon: Icon(Icons.add), label: Text('ttest')),
        FlatButton.icon(
            onPressed: () => "", icon: Icon(Icons.add), label: Text('ttest')),
      ],
    );
  }
}

Pubspec.yaml

name: without_flutter_native_splash
description: A new Flutter application.

version: 1.0.0+1

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^0.1.2

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_launcher_icons: ^0.7.4

flutter_icons:
  android: true
  ios: true
  image_path: "assets/1.png"
flutter:
  uses-material-design: true

@henriquearthur henriquearthur added the bug Something isn't working label Dec 25, 2019
@henriquearthur
Copy link
Collaborator

Thanks for the detailed report.

This package changes your app to full screen mode for better splash screen experience. When the splash screen finished, full screen mode is removed. That happens in MainActivity.kt.

The problem is that the latest version of Flutter changed the default MainActivity.kt file, which means this package can't find a reference line to insert code before and after it - and because of that full screen mode is not removed.

Since your app is still in full screen mode, keyboard overlaps the AlertDialog.

Even by changing the reference line on MainActivity.kt or manually adding it we get an Exception because flutterView is no longer present. So I need to find another way to remove the full screen mode or access flutterView in MainActivity.kt. Or even better, don't depend on this at all - because it is likely that everytime Flutter changes default MainActivity, this package will break.


For now, you can go to android/app/src/main/res/values/styles.xml and remove the line

<item name="android:windowFullscreen">true</item>

This way your app won't be in full screen mode but keyboard won't overlap AlertDialog.

Not being in full screen mode means during the splash screen the status bar will be visible.

I'll investigate more to fix this issue.

@maPer77
Copy link

maPer77 commented Dec 28, 2019

@henriquearthur Tem como mudar a cor da barra de status ?
Estou fazendo manualmente, sem usar seu plugin.
Consigo mudar a barra de navegação, mas a barra de status não muda de cor de forma alguma.

Existe este problema com a tela cheia, que além de eu não conseguir sair dela no flutter ainda esta aparecendo uma tela preta antes do aplicativo renderizar.
Então gostaria de deixar tudo branco... fundo, barra de status, barra de navegação... porém tudo que eu tento não funciona, a barra de status continua sempre cinza...
Obrigado

Can you change the color of the status bar?
I am doing it manually without using your plugin.
I can change the navigation bar, but the status bar doesn't change color at all.

There is this problem with the full screen, which besides not being able to exit it in the futter is still appearing a black screen before the application render.
So I would like to make everything white ... background, status bar, navigation bar ... but everything I try doesn't work, the status bar is always gray ...
Thanks

@pdivita
Copy link

pdivita commented Jun 26, 2020

Every widget (like TextFormField) is being hidden by the keyboard. I spent 3 hours to figure out the problem was this plugin.
Fixed thanks to the previous reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants