Last active
August 30, 2021 11:48
-
-
Save rydmike/d06401e9e15627ecddde8733cc666e00 to your computer and use it in GitHub Desktop.
None uniform borderside container hack example.
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( | |
| debugShowCheckedModeBanner: false, | |
| title: 'Border Fun', | |
| theme: ThemeData(primarySwatch: Colors.blue), | |
| home: const HomePage(), | |
| ); | |
| } | |
| } | |
| class HomePage extends StatelessWidget { | |
| const HomePage({Key? key}) : super(key: key); | |
| @override | |
| Widget build(BuildContext context) { | |
| const double width = 220; | |
| const double height = 150; | |
| const double borderWidth = 20; | |
| const double borderRadius = 40; | |
| return Scaffold( | |
| appBar: AppBar(title: const Text('Rounded Border Fun')), | |
| body: const Center( | |
| child: MikeVersion( | |
| width: width, | |
| height: height, | |
| borderWidth: borderWidth, | |
| borderRadius: borderRadius, | |
| ), | |
| ), | |
| ); | |
| } | |
| } | |
| // ***************************************************************************** | |
| class MikeVersion extends StatelessWidget { | |
| const MikeVersion({ | |
| Key? key, | |
| required this.width, | |
| required this.height, | |
| required this.borderWidth, | |
| required this.borderRadius, | |
| }) : super(key: key); | |
| final double width; | |
| final double height; | |
| final double borderWidth; | |
| final double borderRadius; | |
| @override | |
| Widget build(BuildContext context) { | |
| return Container( | |
| width: width, | |
| height: height, | |
| decoration: BoxDecoration( | |
| color: Colors.black, | |
| borderRadius: BorderRadius.only( | |
| topRight: Radius.circular(borderRadius), | |
| bottomRight: Radius.circular(borderRadius), | |
| ), | |
| ), | |
| child: Container( | |
| margin: EdgeInsets.only( | |
| top: borderWidth, | |
| right: borderWidth, | |
| bottom: borderWidth, | |
| ), | |
| decoration: BoxDecoration( | |
| color: Colors.blue, | |
| borderRadius: BorderRadius.only( | |
| topRight: Radius.circular(borderRadius - borderWidth), | |
| bottomRight: Radius.circular(borderRadius - borderWidth), | |
| ), | |
| ), | |
| ), | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment