flutterポップアップキーボードマスクキーボード高さ取得


キーボードの高さ:MediaQuery.of(context).viewInsets.bottom(この高さはキーボードが起動したときにbuildでのみ取得でき、ポップアップキーボードがbuildを実行します)
コードを見て:iimport'package:flutter/cupertino.dart’; import ‘package:flutter/material.dart’;
void main() => runApp(MyApp());
class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: ‘Flutter Demo’, theme: ThemeData( primarySwatch: Colors.blue, ), home: MyHomePage(title: ‘Flutter Demo Home Page’), ); } }
class MyHomePage extends StatefulWidget { MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override _MyHomePageState createState() => _MyHomePageState(); }
class _MyHomePageState extends State{String hint='入力してください.
@override Widget build(BuildContext context){returnScaffold(appBar:AppBar(backkgroundColor:Colors.red,centerTitle:true,title:Text('appBar'),)、body:Container(color:Colors.green,child:InkWell(child:Center(child:Text('クリックポップアップボックス',style:TextStyle(color:Colors.white),))),,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,),onTap:(){showDialog(barrierDismissible:true,context:context,builder:(BuildContext context){return Scaffold(backkgroundColor:Colors.transparent,body:Container(width:MediaQuery.of(context).size.width,child:Stack(children:[ Positioned(child:CupertinoAlertDialog( title:CupertinoAlertDialog( title:const Text(‘入力ボックス’)、content:Container(color:Colors.white,child:CupertinoTextField(placehocehoteted)lder:hint,style:TextStyle(fontSize:15,color:Colors.black), decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(2)), ), maxLines: 5, maxLength: 30, maxLengthEnforced: true, ), ), ), bottom: MediaQuery.of(context).viewInsets.bottom > 0 ? 0:300,//300キーボードの高さ値に変更すると、left:0,right:0,),),),);});},,))));}}
/* class _MyHomePageState extends State {
@override void initState() { super.initState(); }
String str = ‘’;
@override Widget build(BuildContext context){MediaQuery.of(context);print(‘build~~~~’);return Scaffold(appBar:AppBar(centerTitle:true,title:Text(‘appAのflutter’)),body:Center(child:TextField(),),
);

}*/iosスタイルコンポーネントの国際化については、前の記事を見て失礼します