Skip to content

Instantly share code, notes, and snippets.

@stephanedeluca
Last active April 22, 2023 20:13
Show Gist options
  • Save stephanedeluca/db58260305bd6080d514f8b736e4ccd3 to your computer and use it in GitHub Desktop.
Save stephanedeluca/db58260305bd6080d514f8b736e4ccd3 to your computer and use it in GitHub Desktop.
How to make child apparition smooth and animated?
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.dark().copyWith(
scaffoldBackgroundColor: darkBlue,
),
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: MyWidget(),
),
),
);
}
}
class MyWidget extends StatefulWidget {
@override State<MyWidget> createState()=>_MyWidgetState();
}
class _MyWidgetState extends State<MyWidget> {
/// Whether to show the additional container?
bool _showContainer = false;
@override
Widget build(BuildContext context) {
return Center(child:
ListView(
shrinkWrap:true,
children:[
Text(
'Hello, World!',
style: Theme.of(context).textTheme.headlineMedium,
),
if(_showContainer)
Container(
color: Colors.pink,
width: 100,
height: 300,
child: const Text("How to make the apparition smooth and animated"),
),
ElevatedButton(
onPressed: ()=>setState(()=>_showContainer=true),
child: const Text("SHOW CONTAINER"),
),
]),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment