Created
March 21, 2020 11:28
-
-
Save Abhilash-Chandran/050686f5295730a85ed32e104c9678db to your computer and use it in GitHub Desktop.
Adjust height on long press.
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(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