Skip to content

Instantly share code, notes, and snippets.

@wisnuwiry
Created August 17, 2022 13:55
Show Gist options
  • Save wisnuwiry/b0c399fdda9ca67a199d5e03113b229f to your computer and use it in GitHub Desktop.
Save wisnuwiry/b0c399fdda9ca67a199d5e03113b229f to your computer and use it in GitHub Desktop.
Counter example
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'Independence Day',
debugShowCheckedModeBanner: false,
home: Content(),
);
}
}
class Content extends StatelessWidget {
const Content({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(children: [
Column(
children: const [
FlagElement(
background: Colors.red,
foreground: Colors.white,
text: 'Recover Faster',
),
FlagElement(
background: Colors.white,
foreground: Colors.red,
text: 'Rise Stronger',
),
],
),
const Logo(),
]),
);
}
}
class Logo extends StatelessWidget {
const Logo({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final size = MediaQuery.of(context).size;
return Center(
child: Image.network('', width: size.width*.3, height: size.height*.3,),
);
}
}
class FlagElement extends StatelessWidget {
const FlagElement({
Key? key,
required this.background,
required this.foreground,
required this.text,
}) : super(key: key);
final Color background;
final Color foreground;
final String text;
@override
Widget build(BuildContext context) {
return Expanded(
child: Container(
width: double.infinity,
color: background,
padding: const EdgeInsets.all(50),
child: FittedBox(
child: Text(
text,
style: TextStyle(
color: foreground,
fontWeight: FontWeight.bold,
),
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment