based_list 1.0.4 copy "based_list: ^1.0.4" to clipboard
based_list: ^1.0.4 copied to clipboard

A Based Sequence Of Widgets About List

example/lib/main.dart

import 'package:example/index.dart';

void main() => runApp(const MyApp());

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  late bool _isDark = false;

  void changeThemeMode() => setState(() => _isDark = !_isDark);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(
          seedColor: Colors.deepPurple,
        ),
        useMaterial3: true,
      ),
      darkTheme: ThemeData(
        colorScheme: ColorScheme.fromSeed(
          brightness: Brightness.dark,
          seedColor: Colors.deepPurple,
        ),
        useMaterial3: true,
      ),
      themeMode: _isDark ? ThemeMode.dark : ThemeMode.light,
      home: HomePage(
        changeThemeMode: changeThemeMode,
      ),
    );
  }
}

class HomePage extends StatelessWidget {
  const HomePage({super.key, required this.changeThemeMode});

  final VoidCallback changeThemeMode;

  static const List<Widget> examples = [
    BasedListSectionExample(),
    BasedListTileExample(),
    BasedListSwitchTileExample(),
    BasedListRadioTileExample(),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('BasedList'),
        actions: [
          IconButton(
            onPressed: changeThemeMode,
            icon: const Icon(Icons.color_lens_rounded),
          )
        ],
      ),
      body: BasedListView(
        children: [
          BasedListSection(
            titleText: 'Examples',
            children: [
              for (final example in examples)
                BasedListTile(
                  leadingIcon: Icons.code_rounded,
                  titleText: '$example',
                  onTap: () => Navigator.push(
                    context,
                    CupertinoPageRoute(
                      builder: (context) => Scaffold(
                        appBar: AppBar(title: Text('$example')),
                        body: example,
                      ),
                    ),
                  ),
                )
            ],
          )
        ],
      ),
    );
  }
}
2
likes
0
pub points
33%
popularity

Publisher

verified publishernote-of-me.top

A Based Sequence Of Widgets About List

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on based_list