Last active
November 11, 2022 08:52
-
-
Save SamiAlsubhi/46765b328c3ac8c8be7409dc26d4ead6 to your computer and use it in GitHub Desktop.
overflowing widget
This file contains 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'; | |
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: ContainerWidget(), | |
), | |
), | |
); | |
} | |
} | |
class ContainerWidget extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Container( | |
color: Colors.red, | |
height: 100, | |
width: 50, | |
child: Column( | |
mainAxisSize: MainAxisSize.max, | |
children: [ | |
Expanded( | |
child: ClipRect( | |
child: AnimatedSwitcher( | |
duration: const Duration(milliseconds: 300), | |
child: OverflowingWidget(), | |
layoutBuilder: (currentChild, previousChildren) => Stack( | |
children: [ | |
...previousChildren, | |
if (currentChild != null) currentChild, | |
], | |
)), | |
), | |
), | |
], | |
)); | |
} | |
} | |
class OverflowingWidget extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Column( | |
children: [Container(color: Colors.blue, height: 150, width: 50)]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment