Created
August 18, 2020 15:20
-
-
Save Blasanka/512da0b44df9be65fcfb7b4f55b09bbf to your computer and use it in GitHub Desktop.
This file contains 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( | |
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