dependencies:
flutter:
sdk: flutter
like_button: ^1.0.1
flutter pub get
import 'package:like_button/like_button.dart';
LikeButton(
circleColor:
CircleColor(start: Color(0xFFF44336), end: Color(0xFFF44336)),
likeBuilder: (bool isLiked) {
return Icon(
Icons.favorite,
size: 30,
color: isLiked ? Colors.red : Colors.grey,
);
},
),
import 'package:flutter/material.dart';
import 'package:like_button/like_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(
debugShowCheckedModeBanner: false,
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
// TODO: implement build
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text('ListTile Widget'),
backgroundColor: Colors.black,
),
body: Column(
children: <Widget>[
Container(
child: Image.asset(
'assets/images/img.jpg',
width: 350,
height: 250,
fit:BoxFit.fill
),
),
SizedBox(height: 10.0,),
LikeButton(
circleColor:
CircleColor(start: Color(0xFFF44336), end: Color(0xFFF44336)),
likeBuilder: (bool isLiked) {
return Icon(
Icons.favorite,
size: 30,
color: isLiked ? Colors.red : Colors.grey,
);
},
),
],
)
);
}
}