Skip to content

Instantly share code, notes, and snippets.

@KrzysztofLen
Last active December 3, 2022 11:27
Show Gist options
  • Save KrzysztofLen/becb3951309bd69bdd531cbc1da5af5b to your computer and use it in GitHub Desktop.
Save KrzysztofLen/becb3951309bd69bdd531cbc1da5af5b to your computer and use it in GitHub Desktop.
This is the source code of the Flutter Challenges series post: https://fun4code.com/10flutterchallanges-part1/
class CandyCaneProgressBar extends StatelessWidget {
const CandyCaneProgressBar({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
Container(
width: MediaQuery.of(context).size.width,
height: 20,
decoration: BoxDecoration(
border: Border.all(
color: Colors.grey.shade200,
),
color: Colors.white70,
),
),
Container(
width: MediaQuery.of(context).size.width - 100,
height: 20,
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment(-0.75, -1.1),
end: Alignment(-0.6, 0),
stops: [0.0, 0.5, 0.5, 1],
colors: [
Colors.red,
Colors.red,
Colors.white,
Colors.white,
],
tileMode: TileMode.mirror,
),
),
),
const Positioned.fill(
child: Align(
alignment: Alignment.center,
child: Text(
'200/1000',
style: TextStyle(
color: Colors.black,
fontSize: 10,
fontFamily: 'RetroGaming',
fontWeight: FontWeight.bold,
),
),
),
),
],
);
}
}
class CustomProgressBar extends StatelessWidget {
const CustomProgressBar({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
SizedBox(
width: MediaQuery.of(context).size.width,
height: 20,
child: const LinearProgressIndicator(
backgroundColor: Color(0xff323232),
valueColor: AlwaysStoppedAnimation<Color>(
Color(0xFF21bf73),
),
value: 0.5,
),
),
const Positioned.fill(
child: Align(
alignment: Alignment.center,
child: Text(
'200/1000',
style: TextStyle(
color: Colors.white,
fontSize: 10,
fontFamily: 'RetroGaming',
fontWeight: FontWeight.bold,
),
),
),
)
],
);
}
}
import 'package:flutter/material.dart';
import 'package:samples/progress_bar/progress_bar.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: Scaffold(
body: SafeArea(
child: CandyCaneProgressBar(),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment