static_licenses 1.0.0
static_licenses: ^1.0.0 copied to clipboard
A CLI tool to statically extract and compile open-source licenses into a zero-dependency Dart file for zero runtime overhead.
import 'package:flutter/material.dart';
import 'licenses.g.dart'; // This is the file generated by our package
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Static Licenses Example',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const LicenseListPage(),
);
}
}
class LicenseListPage extends StatelessWidget {
const LicenseListPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Open Source Licenses'),
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
),
body: ListView.separated(
itemCount: allLicenses.length,
separatorBuilder: (context, index) => const Divider(height: 1),
itemBuilder: (context, index) {
final license = allLicenses[index];
return ListTile(
title: Text(
license.packageName,
style: const TextStyle(fontWeight: FontWeight.bold),
),
subtitle: Text('Version: ${license.version}'),
trailing: const Icon(Icons.chevron_right),
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => LicenseDetailPage(license: license),
),
);
},
);
},
),
);
}
}
class LicenseDetailPage extends StatelessWidget {
final PackageLicenseInfo license;
const LicenseDetailPage({super.key, required this.license});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
),
body: SingleChildScrollView(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
license.packageName,
style: Theme.of(context).textTheme.titleLarge,
),
Text(
'Version: ${license.version}',
style: Theme.of(context).textTheme.titleMedium,
),
const SizedBox(height: 16),
Text(
license.licenseText,
style: const TextStyle(fontFamily: 'monospace', fontSize: 13),
),
],
),
),
);
}
}