Skip to content

Instantly share code, notes, and snippets.

@kyl3r92
Created October 9, 2021 14:16
Show Gist options
  • Save kyl3r92/a8eb7fe2197b6f283e5e8b773f37a029 to your computer and use it in GitHub Desktop.
Save kyl3r92/a8eb7fe2197b6f283e5e8b773f37a029 to your computer and use it in GitHub Desktop.
Looping Stack
import 'package:flutter/material.dart';
import 'dart:math';
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 StatelessWidget {
final List<Color> colors = [
const Color(0xFF2f5283),
const Color(0xFF204b74),
const Color(0xFF245c83),
const Color(0xFF466a99),
const Color(0xFF5d759d),
const Color(0xFF52AFBF),
const Color(0xFF49AB9B),
const Color(0xFF419873),
const Color(0xFF398564),
const Color(0xFF317256),
const Color(0xff40b725),
const Color(0xff98e92e),
const Color(0xfffff534),
const Color(0xFFff9f34),
const Color(0xFFff7d27),
const Color(0xffe63a1f),
const Color(0xffe8607e),
const Color(0xffdf3caf),
const Color(0xffa95ad0),
const Color(0xffd567df),
const Color(0xFFAF86F0),
const Color(0xff4d59aa),
];
@override
Widget build(BuildContext context) {
return Stack(
children: [
for (var i = 0; i < colors.length; i++)
Transform.rotate(
angle: pi * (i / colors.length) * 1.68,
child: Transform.translate(
offset: const Offset(80, 0),
child: Material(
borderRadius: BorderRadius.circular(10),
color: colors[i],
child: const SizedBox(
width: 70,
height: 70 * 1.618,
),
),
),
),
],
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment