Created
October 12, 2025 12:36
-
-
Save kekland/5897c4c08bb9561c849fff912e15dbba to your computer and use it in GitHub Desktop.
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 'dart:async'; | |
| import 'package:flutter/material.dart'; | |
| void main() { | |
| runApp(App()); | |
| } | |
| class App extends StatelessWidget { | |
| const App({super.key}); | |
| @override | |
| Widget build(BuildContext context) { | |
| return MaterialApp(theme: ThemeData.dark(), home: Demo()); | |
| } | |
| } | |
| class Demo extends StatefulWidget { | |
| const Demo({super.key}); | |
| @override | |
| State<Demo> createState() => _DemoState(); | |
| } | |
| class _DemoState extends State<Demo> { | |
| late BorderRadius _borderRadius; | |
| var _isCircular = false; | |
| @override | |
| void initState() { | |
| super.initState(); | |
| _borderRadius = BorderRadius.vertical(top: Radius.circular(64.0)); | |
| Timer.periodic(const Duration(milliseconds: 200), (_) => _toggleBorderRadius()); | |
| } | |
| void _toggleBorderRadius() { | |
| if (_isCircular) { | |
| _borderRadius = BorderRadius.vertical(top: Radius.circular(64.0)); | |
| } else { | |
| _borderRadius = BorderRadius.all(Radius.circular(64.0)); | |
| } | |
| _isCircular = !_isCircular; | |
| setState(() {}); | |
| } | |
| @override | |
| Widget build(BuildContext context) { | |
| return Scaffold( | |
| floatingActionButton: FloatingActionButton( | |
| onPressed: _toggleBorderRadius, | |
| child: Icon(Icons.refresh), | |
| ), | |
| body: Align( | |
| alignment: Alignment.center, | |
| child: AnimatedContainer( | |
| duration: Duration(milliseconds: 200), | |
| curve: Cubic(0.34, 0.80, 0.34, 1.00), | |
| width: double.infinity, | |
| height: 200.0, | |
| decoration: ShapeDecoration( | |
| color: Colors.red, | |
| shape: RoundedSuperellipseBorder(borderRadius: _borderRadius), | |
| ), | |
| ), | |
| ), | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment