Skip to content

Instantly share code, notes, and snippets.

@Blasanka
Created August 18, 2020 15:20
Show Gist options
  • Save Blasanka/512da0b44df9be65fcfb7b4f55b09bbf to your computer and use it in GitHub Desktop.
Save Blasanka/512da0b44df9be65fcfb7b4f55b09bbf to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
List nums = [1, 2, 3];
void _incrementCounter() {
if (_counter <= 1) {
setState(() {
_counter++;
});
} else {
setState(() {
_counter = 0;
});
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
children: [
SizedBox(
width: 100,
child: LinearProgressIndicator(
minHeight: 18,
backgroundColor: Colors.redAccent,
valueColor: AlwaysStoppedAnimation(Colors.red)),
),
Text('${nums[_counter]}'),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
child: Icon(Icons.add),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment