Skip to content

Instantly share code, notes, and snippets.

@Abhilash-Chandran
Created March 21, 2020 11:28
Show Gist options
  • Save Abhilash-Chandran/050686f5295730a85ed32e104c9678db to your computer and use it in GitHub Desktop.
Save Abhilash-Chandran/050686f5295730a85ed32e104c9678db to your computer and use it in GitHub Desktop.
Adjust height on long press.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Text Field Focus',
home: ListView(
children:[
MeetingCard(),
MeetingCard(),
MeetingCard(),
MeetingCard(),
]
),
);
}
}
// Define a custom Form widget.
class MeetingCard extends StatefulWidget {
@override
_MeetingCardState createState() => _MeetingCardState();
}
// Define a corresponding State class.
// This class holds data related to the form.
class _MeetingCardState extends State<MeetingCard> {
double height = 130;
@override
Widget build(context) {
return GestureDetector(
onLongPress: (){
setState((){
height = height == 130 ? 150 : 130;
});
},
child: AnimatedContainer(
duration: new Duration(milliseconds: 500),
height: height,
child: Card(child: Center(child: Text('hello'),),),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment