rounded_loading_button 1.0.3 rounded_loading_button: ^1.0.3 copied to clipboard
A simple implementation of an animated loading button widget for Flutter
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:rounded_loading_button/rounded_loading_button.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Rounded Loading Button Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Rounded Loading Button Demo'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final RoundedLoadingButtonController _btnController = new RoundedLoadingButtonController();
void _doSomething() async {
Timer(Duration(seconds: 3), () {
_btnController.success();
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
RoundedLoadingButton(
child: Text('Tap me!', style: TextStyle(color: Colors.white)),
controller: _btnController,
onPressed: _doSomething,
)
],
),
)
);
}
}