2024-04-05 09:12:49 +02:00
|
|
|
import "package:flutter/material.dart";
|
|
|
|
import "package:flutter_nested_categories/flutter_nested_categories.dart";
|
2024-04-03 16:16:46 +02:00
|
|
|
|
|
|
|
void main() {
|
|
|
|
runApp(const MyApp());
|
|
|
|
}
|
|
|
|
|
|
|
|
class MyApp extends StatelessWidget {
|
|
|
|
const MyApp({super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
var theme = Theme.of(context);
|
|
|
|
|
|
|
|
return MaterialApp(
|
|
|
|
home: Scaffold(
|
|
|
|
appBar: AppBar(
|
|
|
|
title: const Text("Nested Categories Example"),
|
|
|
|
),
|
|
|
|
body: CategoryList(
|
|
|
|
title: "This is the title of the list",
|
|
|
|
titleCentered: true,
|
|
|
|
headerCentered: false,
|
|
|
|
isCategoryCollapsible: true,
|
|
|
|
headerStyling: CategoryHeaderStyling(
|
|
|
|
headerStyles: {
|
|
|
|
0: theme.textTheme.titleLarge?.copyWith(color: Colors.red),
|
|
|
|
2: theme.textTheme.titleLarge?.copyWith(color: Colors.blue),
|
|
|
|
},
|
|
|
|
defaultStyle:
|
2024-04-04 09:32:20 +02:00
|
|
|
theme.textTheme.titleLarge!.copyWith(color: Colors.green),
|
2024-04-04 10:13:30 +02:00
|
|
|
capitalization: CategoryHeaderCapitalization.uppercase,
|
2024-04-03 16:16:46 +02:00
|
|
|
),
|
|
|
|
content: [
|
|
|
|
Category(
|
2024-04-04 10:13:30 +02:00
|
|
|
name: "category 1",
|
2024-04-03 16:16:46 +02:00
|
|
|
content: [
|
|
|
|
const Text("Content 1"),
|
|
|
|
Image.network(
|
2024-04-05 09:12:49 +02:00
|
|
|
"https://via.placeholder.com/150?text=Content+2+Image",
|
|
|
|
),
|
2024-04-03 16:16:46 +02:00
|
|
|
],
|
|
|
|
nestedCategories: [
|
|
|
|
const Category(
|
|
|
|
name: "Category 1.1",
|
|
|
|
content: [
|
|
|
|
Text("Content 1.1"),
|
|
|
|
Text("Content 1.2"),
|
|
|
|
],
|
|
|
|
nestedCategories: [
|
|
|
|
Category(
|
|
|
|
name: "Category 1.1.1",
|
|
|
|
content: [
|
|
|
|
Text("Content 1.1.1"),
|
|
|
|
Text("Content 1.1.2"),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
Category(
|
|
|
|
name: "Category 1.1.2",
|
|
|
|
content: [
|
|
|
|
Text("Content 1.1.2"),
|
|
|
|
Text("Content 1.1.2"),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
const Category(
|
|
|
|
name: "Category 1.2",
|
|
|
|
content: [
|
|
|
|
Text("Content 1.2"),
|
|
|
|
Text("Content 1.2"),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
const Category(
|
|
|
|
name: "Category 2",
|
|
|
|
content: [
|
|
|
|
Text("Content 2"),
|
|
|
|
Text("Content 2"),
|
|
|
|
],
|
|
|
|
nestedCategories: [
|
|
|
|
Category(
|
|
|
|
name: "Category 2.1",
|
|
|
|
content: [
|
|
|
|
Text("Content 2.1"),
|
|
|
|
Text("Content 2.2"),
|
|
|
|
],
|
|
|
|
nestedCategories: [
|
|
|
|
Category(
|
|
|
|
name: "Category 2.1.1",
|
|
|
|
content: [
|
|
|
|
Text("Content 2.1.1"),
|
|
|
|
Text("Content 2.1.2"),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|