Cricket API for Flutter Apps — Live Scores in Android & iOS (2026)
Complete guide to integrating live cricket scores into your Flutter app using CricLive API. Includes Dart code, HTTP package setup, and real-time polling for Android and iOS.
Why Flutter is Perfect for Cricket Apps
Flutter lets you build one codebase that runs on Android, iOS, web, and desktop. Combined with CricLive API, you can build a fully-featured cricket live score app that works on every platform — in a fraction of the time it would take to build native apps separately.
This guide covers everything: setting up the HTTP client, creating a cricket service class, building a live score widget, and implementing real-time polling.
Setup — pubspec.yaml
dependencies:
flutter:
sdk: flutter
http: ^1.2.0
provider: ^6.1.0 # For state management
Run:
flutter pub get
Cricket API Service Class
// lib/services/cricket_api_service.dart
import 'dart:convert';
import 'package:http/http.dart' as http;
class CricketApiService {
static const String _baseUrl = 'https://cricketliveapi.com/api/v1';
static const String _apiKey = 'your_api_key_here';
static Map<String, String> get _headers => {
'Authorization': 'Bearer $_apiKey',
'Content-Type': 'application/json',
};
// Get all live matches
static Future<List<dynamic>> getLiveScores() async {
final response = await http.get(
Uri.parse('$_baseUrl/live-scores'),
headers: _headers,
);
if (response.statusCode == 200) {
final data = json.decode(response.body);
return data['data'] ?? [];
}
throw Exception('Failed to load live scores');
}
// Get match scorecard
static Future<Map<String, dynamic>> getScorecard(String matchId) async {
final response = await http.get(
Uri.parse('$_baseUrl/match/$matchId/scorecard'),
headers: _headers,
);
if (response.statusCode == 200) {
return json.decode(response.body);
}
throw Exception('Failed to load scorecard');
}
// Get fantasy points
static Future<List<dynamic>> getFantasyPoints(String matchId) async {
final response = await http.get(
Uri.parse('$_baseUrl/fantasy/points/$matchId'),
headers: _headers,
);
if (response.statusCode == 200) {
final data = json.decode(response.body);
return data['players'] ?? [];
}
throw Exception('Failed to load fantasy points');
}
// Get match schedule
static Future<List<dynamic>> getSchedule() async {
final response = await http.get(
Uri.parse('$_baseUrl/schedule'),
headers: _headers,
);
if (response.statusCode == 200) {
final data = json.decode(response.body);
return data['data'] ?? [];
}
throw Exception('Failed to load schedule');
}
}
Live Score Widget with Auto-Refresh
// lib/widgets/live_scores_widget.dart
import 'dart:async';
import 'package:flutter/material.dart';
import '../services/cricket_api_service.dart';
class LiveScoresWidget extends StatefulWidget {
const LiveScoresWidget({super.key});
@override
State<LiveScoresWidget> createState() => _LiveScoresWidgetState();
}
class _LiveScoresWidgetState extends State<LiveScoresWidget> {
List<dynamic> _matches = [];
bool _loading = true;
Timer? _timer;
@override
void initState() {
super.initState();
_fetchScores();
// Auto-refresh every 10 seconds
_timer = Timer.periodic(const Duration(seconds: 10), (_) => _fetchScores());
}
@override
void dispose() {
_timer?.cancel();
super.dispose();
}
Future<void> _fetchScores() async {
try {
final matches = await CricketApiService.getLiveScores();
if (mounted) {
setState(() {
_matches = matches;
_loading = false;
});
}
} catch (e) {
if (mounted) setState(() => _loading = false);
}
}
@override
Widget build(BuildContext context) {
if (_loading) {
return const Center(child: CircularProgressIndicator(color: Color(0xFF22c55e)));
}
if (_matches.isEmpty) {
return const Center(
child: Text('No live matches right now', style: TextStyle(color: Colors.grey)),
);
}
return ListView.builder(
itemCount: _matches.length,
itemBuilder: (context, index) => MatchCard(match: _matches[index]),
);
}
}
class MatchCard extends StatelessWidget {
final Map<String, dynamic> match;
const MatchCard({super.key, required this.match});
@override
Widget build(BuildContext context) {
final isLive = match['status'] == 'live';
return Card(
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
elevation: 2,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Text(
match['teams'] ?? '',
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 15),
),
),
Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
decoration: BoxDecoration(
color: isLive ? Colors.red.shade50 : Colors.grey.shade100,
borderRadius: BorderRadius.circular(20),
),
child: Text(
isLive ? '🔴 LIVE' : (match['status'] ?? ''),
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w600,
color: isLive ? Colors.red : Colors.grey,
),
),
),
],
),
const SizedBox(height: 8),
Text(
match['score'] ?? '',
style: const TextStyle(
color: Color(0xFF16a34a),
fontWeight: FontWeight.bold,
fontSize: 18,
),
),
const SizedBox(height: 4),
Text(
'${match['format'] ?? ''} · ${match['series'] ?? ''}',
style: const TextStyle(color: Colors.grey, fontSize: 12),
),
],
),
),
);
}
}
Main App Screen
// lib/main.dart
import 'package:flutter/material.dart';
import 'widgets/live_scores_widget.dart';
void main() => runApp(const CricketApp());
class CricketApp extends StatelessWidget {
const CricketApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Cricket Live Scores',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: const Color(0xFF22c55e)),
useMaterial3: true,
),
home: const HomeScreen(),
);
}
}
class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('🏏 Live Cricket Scores'),
backgroundColor: const Color(0xFF16a34a),
foregroundColor: Colors.white,
),
body: const LiveScoresWidget(),
);
}
}
Available CricLive API Endpoints for Flutter
GET /api/v1/live-scores — All live matches
GET /api/v1/match/{id}/scorecard — Full scorecard
GET /api/v1/match/{id}/commentary — Ball-by-ball commentary
GET /api/v1/fantasy/points/{id} — Fantasy points
GET /api/v1/player/{id}/stats — Player statistics
GET /api/v1/schedule — Upcoming matches
GET /api/v1/series/{id}/points-table — Series standings
Why CricLive API for Flutter in 2026
- ✅ Free tier — 500 calls/day, no credit card, no expiry
- ✅ Fast response — Under 200ms, Indian servers
- ✅ Fantasy points — Dream11-compatible, updated ball by ball
- ✅ Complete coverage — IPL, T20 WC, ODIs, Tests, domestic
- ✅ INR pricing — Starter at ₹999/month
- ✅ Works with Flutter — Standard REST JSON API, works with any HTTP client
Get Your Free API Key
Sign up at cricketliveapi.com/register — takes 2 minutes. Start building your Flutter cricket app today.