Created
February 17, 2023 23:17
-
-
Save Piinks/5098d3e97930bfb9d5396fda479e3ea6 to your computer and use it in GitHub Desktop.
TextField in a ListView comes into focus ✅
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'; | |
void main() => runApp(Demo()); | |
class Demo extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: Scaffold( | |
body: ListView.builder( | |
itemCount: 3, | |
itemBuilder: (context, index) { | |
if (index.isEven) { | |
return Container( | |
height: 500, | |
color: Colors.amber | |
); | |
} | |
return const SizedBox( | |
height: 150, | |
child: Center( | |
child: TextField(), | |
), | |
); | |
} | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment