Skip to content

Instantly share code, notes, and snippets.

@Piinks
Created February 17, 2023 23:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Piinks/5098d3e97930bfb9d5396fda479e3ea6 to your computer and use it in GitHub Desktop.
Save Piinks/5098d3e97930bfb9d5396fda479e3ea6 to your computer and use it in GitHub Desktop.
TextField in a ListView comes into focus ✅
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