Skip to content

Instantly share code, notes, and snippets.

@ffpresents
Created February 7, 2025 04:44
Show Gist options
  • Save ffpresents/570547a74e5f827aec43057eb2454701 to your computer and use it in GitHub Desktop.
Save ffpresents/570547a74e5f827aec43057eb2454701 to your computer and use it in GitHub Desktop.
TextField problem
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
builder: (context, child) => const MyApp(),
));
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<StatefulWidget> createState() {
return _MyAppState();
}
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Container(
color: Colors.blueAccent,
child: Column(
children: [
const Spacer(),
Text(
'Media query inset vertical ${MediaQuery.of(context).viewInsets.vertical}',
style: const TextStyle(fontSize: 14, color: Colors.black),
),
Padding(
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).viewInsets.vertical),
child: Container(
padding: const EdgeInsets.all(16),
color: Colors.indigo,
child: TextField(
controller: TextEditingController(),
focusNode: FocusNode(),
style: const TextStyle(fontSize: 14, color: Colors.black),
cursorColor: Colors.white,
),
),
),
],
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment