Created
March 31, 2019 11:34
-
-
Save joseph-montanez/be852a92fab92ee40da4e8b368419a36 to your computer and use it in GitHub Desktop.
Flutter Keyboard Issues
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:flutter/services.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
// This widget is the root of your application. | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter Demo', | |
theme: ThemeData( | |
primarySwatch: Colors.green, | |
), | |
debugShowCheckedModeBanner: false, | |
home: MyHomePage(title: 'Flutter Keyboard Issues'), | |
); | |
} | |
} | |
class MyHomePage extends StatefulWidget { | |
MyHomePage({Key key, this.title}) : super(key: key); | |
final String title; | |
@override | |
_MyHomePageState createState() => _MyHomePageState(); | |
} | |
class _MyHomePageState extends State<MyHomePage> { | |
var focusNode = new FocusNode(); | |
@override | |
Widget build(BuildContext context) { | |
var _blankFocusNode = new FocusNode(); | |
return Scaffold( | |
appBar: AppBar( | |
title: Text(widget.title), | |
), | |
body: GestureDetector( | |
behavior: HitTestBehavior.opaque, | |
onTap: () { | |
// SystemChannels.textInput.invokeMethod('TextInput.hide'); | |
FocusScope.of(context).requestFocus(_blankFocusNode); | |
}, | |
child: Column( | |
crossAxisAlignment: CrossAxisAlignment.stretch, | |
children: <Widget>[ | |
SingleChildScrollView( | |
child: Container( | |
child: Column( | |
crossAxisAlignment: CrossAxisAlignment.stretch, | |
children: <Widget>[ | |
Text( | |
'How to dismiss the keyboard!', | |
style: Theme.of(context).textTheme.display1, | |
textAlign: TextAlign.center, | |
), | |
Row( | |
mainAxisSize: MainAxisSize.max, | |
children: <Widget>[ | |
Text( | |
'Username', | |
style: Theme.of(context).textTheme.body1, | |
), | |
Flexible( | |
child: TextField( | |
decoration: InputDecoration( | |
contentPadding: const EdgeInsets.all(10.0), | |
hintText: "john_doe"), | |
), | |
) | |
], | |
), | |
// Container(padding: const EdgeInsets.only(top: 300.0),), | |
// Text('Hello', style: Theme.of(context).textTheme.display1,) | |
], | |
), | |
), | |
) | |
], | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment