dcc_toolkit 0.1.0 copy "dcc_toolkit: ^0.1.0" to clipboard
dcc_toolkit: ^0.1.0 copied to clipboard

Internal toolkit package used by the DCC team.

example/lib/main.dart

import 'package:dcc_toolkit/ui/annotated_text/annotated_text.dart';
import 'package:dcc_toolkit/ui/native_dialog.dart';
import 'package:example/core/injectable/injectable.dart';
import 'package:example/profile/presentation/cubit/user_cubit.dart';
import 'package:example/profile/presentation/user_page.dart';
import 'package:material_ui/material_ui.dart';

Future<void> main() async {
  await configureDependencies();
  runApp(const MyApp());
}

class const MyApp({super.key}) extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(),
    );
  }
}

class const MyHomePage({super.key}) extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: Column(
          children: [
            Padding(
              padding: const EdgeInsets.all(16),
              child: AnnotatedText(
                text: '[Flutter](onFlutterTap) example of using a Rich Text with annotations with multiple [tap](onTap) actions.\nThis tap [action](action) does nothing. And [action] without () does nothing as well',
                defaultStyle: const TextStyle(color: Colors.black),
                annotationStyle: const TextStyle(color: Colors.blue),
                actions: {
                  'onFlutterTap': () => ScaffoldMessenger.of(context)
                    ..hideCurrentSnackBar()
                    ..showSnackBar(const SnackBar(content: Text('Flutter'))),
                  'onTap': () => ScaffoldMessenger.of(context)
                    ..hideCurrentSnackBar()
                    ..showSnackBar(const SnackBar(content: Text('Tap'))),
                },
              ),
            ),
            ElevatedButton(
              onPressed: () => Navigator.of(context).push(
                MaterialPageRoute(
                  builder: (context) => UserPage(
                    onCreateCubit: (context) =>
                        getIt<UserCubit>()..getRandomUser(),
                  ),
                ),
              ),
              child: const Text('Get user succesfully'),
            ),
            ElevatedButton(
              onPressed: () => Navigator.of(context).push(
                MaterialPageRoute(
                  builder: (context) => UserPage(
                    onCreateCubit: (context) =>
                        getIt<UserCubit>()..getRandomUserFails(),
                  ),
                ),
              ),
              child: const Text('Get user fails'),
            ),
            ElevatedButton(
              onPressed: () => showNativeDialog(
                context,
                title: 'Title',
                content: 'Content',
                actions: [
                  DialogAction(
                    text: 'Action',
                    onTap: () {},
                    textStyle: const TextStyle(color: Colors.green),
                  ),
                  DialogAction(
                    text: 'Action',
                    onTap: () {},
                    textStyle: const TextStyle(color: Colors.red),
                  ),
                ],
              ),
              child: const Text('Show native dialog'),
            ),
          ],
        ),
      ),
    );
  }
}