From 673889bc0df5766d035325a302b3b7e4fdd4c912 Mon Sep 17 00:00:00 2001 From: Tom <85431690+zTomz@users.noreply.github.com> Date: Tue, 14 May 2024 14:19:48 +0200 Subject: [PATCH] Improve example ui and routing (#1) --- .../lib/core/config/router/app_router.dart | 178 +++++ .../lib/core/config/router/app_router.gr.dart | 639 ++++++++++++++++++ example/lib/core/utils/constants/sizes.dart | 9 + example/lib/features/bar_plot/bar_plot.dart | 24 +- example/lib/features/bar_plot/example.dart | 26 + .../all_space_basic_bar_plot_screen.dart | 2 + .../screens/basic_bar_plot_screen.dart | 2 + .../screens/stacked_bar_plot_screen.dart | 2 + .../bubble_chart/bubble_chart_screen.dart | 10 +- .../lib/features/bubble_chart/example.dart | 34 + .../screens/basic_bubble_chart_screen.dart | 6 +- .../contour_plot/contour_plot_screen.dart | 10 +- .../lib/features/contour_plot/example.dart | 28 + .../screens/basic_contour_plot_screen.dart | 2 + .../dependency_wheel_screen.dart | 17 +- .../features/dependency_wheel/example.dart | 18 + ...rcial_balance_dependency_wheel_screen.dart | 2 + ...import_export_dependency_wheel_screen.dart | 2 + .../features/dot_plot/dot_plot_screen.dart | 8 +- example/lib/features/dot_plot/example.dart | 26 + .../screens/basic_dot_plot_screen.dart | 2 + example/lib/features/line_plot/example.dart | 25 + .../features/line_plot/line_plot_screen.dart | 44 +- .../screens/animated_line_plot_screen.dart | 52 +- .../screens/basic_line_plot_screen.dart | 55 ++ .../screens/dashed_line_plot_screen.dart | 60 +- .../screens/multiple_line_plots_screen.dart | 70 +- example/lib/features/pie_plot/example.dart | 30 + .../features/pie_plot/pie_plot_screen.dart | 30 +- .../screens/basic_pie_plot_screen.dart | 2 + .../country_population_pie_plot_screen.dart | 2 + .../lib/features/scatter_plot/example.dart | 31 + .../scatter_plot/scatter_plot_screen.dart | 17 +- .../screens/basic_scatter_plot.dart | 6 +- .../screens/massive_scatter_plot.dart | 6 +- .../features/skeleton/skeleton_screen.dart | 154 +++++ .../lib/features/ternary_plot/example.dart | 60 ++ .../screens/basic_ternary_plot_screen.dart | 2 + .../screens/soil_ternay_plot_screen.dart | 2 + .../features/ternary_plot/ternary_plot.dart | 17 +- .../lib/features/treemap_chart/example.dart | 19 + .../screens/basic_treemap_chart_screen.dart | 2 + .../category_treemap_chart_screen.dart | 2 + .../treemap_chart/treemap_chart_screen.dart | 17 +- example/lib/main.dart | 13 +- example/pubspec.lock | 377 ++++++++++- example/pubspec.yaml | 12 +- 47 files changed, 1913 insertions(+), 241 deletions(-) create mode 100644 example/lib/core/config/router/app_router.dart create mode 100644 example/lib/core/config/router/app_router.gr.dart create mode 100644 example/lib/core/utils/constants/sizes.dart create mode 100644 example/lib/features/bar_plot/example.dart create mode 100644 example/lib/features/bubble_chart/example.dart create mode 100644 example/lib/features/contour_plot/example.dart create mode 100644 example/lib/features/dependency_wheel/example.dart create mode 100644 example/lib/features/dot_plot/example.dart create mode 100644 example/lib/features/line_plot/example.dart create mode 100644 example/lib/features/line_plot/screens/basic_line_plot_screen.dart create mode 100644 example/lib/features/pie_plot/example.dart create mode 100644 example/lib/features/scatter_plot/example.dart create mode 100644 example/lib/features/skeleton/skeleton_screen.dart create mode 100644 example/lib/features/ternary_plot/example.dart create mode 100644 example/lib/features/treemap_chart/example.dart diff --git a/example/lib/core/config/router/app_router.dart b/example/lib/core/config/router/app_router.dart new file mode 100644 index 0000000..212fe4a --- /dev/null +++ b/example/lib/core/config/router/app_router.dart @@ -0,0 +1,178 @@ +import 'package:auto_route/auto_route.dart'; +import 'package:example/features/bar_plot/bar_plot.dart'; +import 'package:example/features/bar_plot/screens/all_space_basic_bar_plot_screen.dart'; +import 'package:example/features/bar_plot/screens/basic_bar_plot_screen.dart'; +import 'package:example/features/bar_plot/screens/stacked_bar_plot_screen.dart'; +import 'package:example/features/bubble_chart/bubble_chart_screen.dart'; +import 'package:example/features/bubble_chart/screens/basic_bubble_chart_screen.dart'; +import 'package:example/features/contour_plot/contour_plot_screen.dart'; +import 'package:example/features/contour_plot/screens/basic_contour_plot_screen.dart'; +import 'package:example/features/dependency_wheel/dependency_wheel_screen.dart'; +import 'package:example/features/dependency_wheel/screens/commercial_balance_dependency_wheel_screen.dart'; +import 'package:example/features/dependency_wheel/screens/import_export_dependency_wheel_screen.dart'; +import 'package:example/features/dot_plot/dot_plot_screen.dart'; +import 'package:example/features/dot_plot/screens/basic_dot_plot_screen.dart'; +import 'package:example/features/line_plot/line_plot_screen.dart'; +import 'package:example/features/line_plot/screens/animated_line_plot_screen.dart'; +import 'package:example/features/line_plot/screens/dashed_line_plot_screen.dart'; +import 'package:example/features/line_plot/screens/multiple_line_plots_screen.dart'; +import 'package:example/features/line_plot/screens/basic_line_plot_screen.dart'; +import 'package:example/features/pie_plot/pie_plot_screen.dart'; +import 'package:example/features/pie_plot/screens/basic_pie_plot_screen.dart'; +import 'package:example/features/pie_plot/screens/country_population_pie_plot_screen.dart'; +import 'package:example/features/scatter_plot/scatter_plot_screen.dart'; +import 'package:example/features/scatter_plot/screens/basic_scatter_plot.dart'; +import 'package:example/features/scatter_plot/screens/massive_scatter_plot.dart'; +import 'package:example/features/ternary_plot/screens/basic_ternary_plot_screen.dart'; +import 'package:example/features/ternary_plot/screens/soil_ternay_plot_screen.dart'; +import 'package:example/features/ternary_plot/ternary_plot.dart'; +import 'package:example/features/treemap_chart/screens/basic_treemap_chart_screen.dart'; +import 'package:example/features/treemap_chart/screens/category_treemap_chart_screen.dart'; +import 'package:example/features/treemap_chart/treemap_chart_screen.dart'; +import 'package:example/features/skeleton/skeleton_screen.dart'; + +part 'app_router.gr.dart'; + +@AutoRouterConfig() +class AppRouter extends _$AppRouter { + @override + List get routes => [ + AutoRoute( + path: '/', + page: SkeletonRoute.page, + initial: true, + ), + // Bar plot routes + AutoRoute( + path: '/bar_plot', + page: BarPlotRoute.page, + ), + AutoRoute( + path: '/bar_plot/full_space', + page: FullSpaceBasicBarPlotRoute.page, + ), + AutoRoute( + path: '/bar_plot/basic', + page: BasicBarPlotRoute.page, + ), + AutoRoute( + path: '/bar_plot/stacked', + page: StackedBarPlotRoute.page, + ), + // Bubble chart routes + AutoRoute( + path: '/bubble_chart', + page: BubbleChartRoute.page, + ), + AutoRoute( + path: '/bubble_chart/basic', + page: BasicBubbleChartRoute.page, + ), + // Contour plot routes + AutoRoute( + path: '/contour_plot', + page: ContourPlotRoute.page, + ), + AutoRoute( + path: '/contour_plot/basic', + page: BasicContourPlotRoute.page, + ), + // Dependency wheel routes + AutoRoute( + path: '/dependency_wheel', + page: DependencyWheelRoute.page, + ), + AutoRoute( + path: '/dependency_wheel/commercial_balance', + page: AndroidIphoneDependencyWheelRoute.page, + ), + AutoRoute( + path: '/dependency_wheel/import_export', + page: ImportExportDependencyWheelRoute.page, + ), + // Dot plot routes + AutoRoute( + path: '/dot_plot', + page: DotPlotRoute.page, + ), + AutoRoute( + path: '/dot_plot/basic', + page: BasicDotPlotRoute.page, + ), + // Line plot routes + AutoRoute( + path: '/line_plot', + page: LinePlotRoute.page, + ), + AutoRoute( + path: '/line_plot/basic', + page: BasicLinePlotRoute.page, + ), + AutoRoute( + path: '/line_plot/dashed_pointed', + page: DashedPointedLinePlotRoute.page, + ), + AutoRoute( + path: '/line_plot/animated', + page: AnimatedLinePlotRoute.page, + ), + AutoRoute( + path: '/line_plot/multiple', + page: MultipleLinePlotsRoute.page, + ), + // Pie plot routes + AutoRoute( + path: '/pie_plot', + page: PiePlotRoute.page, + ), + AutoRoute( + path: '/pie_plot/basic', + page: BasicPiePlotRoute.page, + ), + AutoRoute( + path: '/pie_plot/country_population', + page: CountryPopulationPiePlotRoute.page, + ), + // Scatter plot routes + AutoRoute( + path: '/scatter_plot', + page: ScatterPlotRoute.page, + ), + AutoRoute( + path: '/scatter_plot/basic', + page: BasicScatterPlotRoute.page, + ), + AutoRoute( + path: '/scatter_plot/masive', + page: MassiveScatterPlotRoute.page, + ), + // Ternary plot routes + AutoRoute( + path: '/ternary_plot', + page: TernaryPlotRoute.page, + ), + AutoRoute( + path: '/ternary_plot/basic', + page: BasicTernaryPlotRoute.page, + ), + AutoRoute( + path: '/ternary_plot/soil', + page: SoilTernaryPlotRoute.page, + ), + // Treemap chart routes + AutoRoute( + path: '/treemap_chart', + page: TreeMapChartRoute.page, + ), + AutoRoute( + path: '/treemap_chart/basic', + page: BasicTreeMapChartRoute.page, + ), + AutoRoute( + path: '/treemap_chart/category', + page: CategoryTreeMapChartRoute.page, + ), + ]; +} + +final appRouter = AppRouter(); diff --git a/example/lib/core/config/router/app_router.gr.dart b/example/lib/core/config/router/app_router.gr.dart new file mode 100644 index 0000000..ee28abb --- /dev/null +++ b/example/lib/core/config/router/app_router.gr.dart @@ -0,0 +1,639 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +// ************************************************************************** +// AutoRouterGenerator +// ************************************************************************** + +// ignore_for_file: type=lint +// coverage:ignore-file + +part of 'app_router.dart'; + +abstract class _$AppRouter extends RootStackRouter { + // ignore: unused_element + _$AppRouter({super.navigatorKey}); + + @override + final Map pagesMap = { + AndroidIphoneDependencyWheelRoute.name: (routeData) { + return AutoRoutePage( + routeData: routeData, + child: const AndroidIphoneDependencyWheelScreen(), + ); + }, + AnimatedLinePlotRoute.name: (routeData) { + return AutoRoutePage( + routeData: routeData, + child: const AnimatedLinePlotScreen(), + ); + }, + BarPlotRoute.name: (routeData) { + return AutoRoutePage( + routeData: routeData, + child: const BarPlotScreen(), + ); + }, + BasicBarPlotRoute.name: (routeData) { + return AutoRoutePage( + routeData: routeData, + child: const BasicBarPlotScreen(), + ); + }, + BasicBubbleChartRoute.name: (routeData) { + return AutoRoutePage( + routeData: routeData, + child: const BasicBubbleChartScreen(), + ); + }, + BasicContourPlotRoute.name: (routeData) { + return AutoRoutePage( + routeData: routeData, + child: const BasicContourPlotScreen(), + ); + }, + BasicDotPlotRoute.name: (routeData) { + return AutoRoutePage( + routeData: routeData, + child: const BasicDotPlotScreen(), + ); + }, + BasicLinePlotRoute.name: (routeData) { + return AutoRoutePage( + routeData: routeData, + child: const BasicLinePlotScreen(), + ); + }, + BasicPiePlotRoute.name: (routeData) { + return AutoRoutePage( + routeData: routeData, + child: const BasicPiePlotScreen(), + ); + }, + BasicScatterPlotRoute.name: (routeData) { + return AutoRoutePage( + routeData: routeData, + child: const BasicScatterPlotScreen(), + ); + }, + BasicTernaryPlotRoute.name: (routeData) { + return AutoRoutePage( + routeData: routeData, + child: const BasicTernaryPlotScreen(), + ); + }, + BasicTreeMapChartRoute.name: (routeData) { + return AutoRoutePage( + routeData: routeData, + child: const BasicTreeMapChartScreen(), + ); + }, + BubbleChartRoute.name: (routeData) { + return AutoRoutePage( + routeData: routeData, + child: const BubbleChartScreen(), + ); + }, + CategoryTreeMapChartRoute.name: (routeData) { + return AutoRoutePage( + routeData: routeData, + child: const CategoryTreeMapChartScreen(), + ); + }, + ContourPlotRoute.name: (routeData) { + return AutoRoutePage( + routeData: routeData, + child: const ContourPlotScreen(), + ); + }, + CountryPopulationPiePlotRoute.name: (routeData) { + return AutoRoutePage( + routeData: routeData, + child: const CountryPopulationPiePlotScreen(), + ); + }, + DashedPointedLinePlotRoute.name: (routeData) { + return AutoRoutePage( + routeData: routeData, + child: const DashedPointedLinePlotScreen(), + ); + }, + DependencyWheelRoute.name: (routeData) { + return AutoRoutePage( + routeData: routeData, + child: const DependencyWheelScreen(), + ); + }, + DotPlotRoute.name: (routeData) { + return AutoRoutePage( + routeData: routeData, + child: const DotPlotScreen(), + ); + }, + FullSpaceBasicBarPlotRoute.name: (routeData) { + return AutoRoutePage( + routeData: routeData, + child: const FullSpaceBasicBarPlotScreen(), + ); + }, + ImportExportDependencyWheelRoute.name: (routeData) { + return AutoRoutePage( + routeData: routeData, + child: const ImportExportDependencyWheelScreen(), + ); + }, + LinePlotRoute.name: (routeData) { + return AutoRoutePage( + routeData: routeData, + child: const LinePlotScreen(), + ); + }, + MassiveScatterPlotRoute.name: (routeData) { + return AutoRoutePage( + routeData: routeData, + child: const MassiveScatterPlotScreen(), + ); + }, + MultipleLinePlotsRoute.name: (routeData) { + return AutoRoutePage( + routeData: routeData, + child: const MultipleLinePlotsScreen(), + ); + }, + PiePlotRoute.name: (routeData) { + return AutoRoutePage( + routeData: routeData, + child: const PiePlotScreen(), + ); + }, + ScatterPlotRoute.name: (routeData) { + return AutoRoutePage( + routeData: routeData, + child: const ScatterPlotScreen(), + ); + }, + SkeletonRoute.name: (routeData) { + return AutoRoutePage( + routeData: routeData, + child: const SkeletonScreen(), + ); + }, + SoilTernaryPlotRoute.name: (routeData) { + return AutoRoutePage( + routeData: routeData, + child: const SoilTernaryPlotScreen(), + ); + }, + StackedBarPlotRoute.name: (routeData) { + return AutoRoutePage( + routeData: routeData, + child: const StackedBarPlotScreen(), + ); + }, + TernaryPlotRoute.name: (routeData) { + return AutoRoutePage( + routeData: routeData, + child: const TernaryPlotScreen(), + ); + }, + TreeMapChartRoute.name: (routeData) { + return AutoRoutePage( + routeData: routeData, + child: const TreeMapChartScreen(), + ); + }, + }; +} + +/// generated route for +/// [AndroidIphoneDependencyWheelScreen] +class AndroidIphoneDependencyWheelRoute extends PageRouteInfo { + const AndroidIphoneDependencyWheelRoute({List? children}) + : super( + AndroidIphoneDependencyWheelRoute.name, + initialChildren: children, + ); + + static const String name = 'AndroidIphoneDependencyWheelRoute'; + + static const PageInfo page = PageInfo(name); +} + +/// generated route for +/// [AnimatedLinePlotScreen] +class AnimatedLinePlotRoute extends PageRouteInfo { + const AnimatedLinePlotRoute({List? children}) + : super( + AnimatedLinePlotRoute.name, + initialChildren: children, + ); + + static const String name = 'AnimatedLinePlotRoute'; + + static const PageInfo page = PageInfo(name); +} + +/// generated route for +/// [BarPlotScreen] +class BarPlotRoute extends PageRouteInfo { + const BarPlotRoute({List? children}) + : super( + BarPlotRoute.name, + initialChildren: children, + ); + + static const String name = 'BarPlotRoute'; + + static const PageInfo page = PageInfo(name); +} + +/// generated route for +/// [BasicBarPlotScreen] +class BasicBarPlotRoute extends PageRouteInfo { + const BasicBarPlotRoute({List? children}) + : super( + BasicBarPlotRoute.name, + initialChildren: children, + ); + + static const String name = 'BasicBarPlotRoute'; + + static const PageInfo page = PageInfo(name); +} + +/// generated route for +/// [BasicBubbleChartScreen] +class BasicBubbleChartRoute extends PageRouteInfo { + const BasicBubbleChartRoute({List? children}) + : super( + BasicBubbleChartRoute.name, + initialChildren: children, + ); + + static const String name = 'BasicBubbleChartRoute'; + + static const PageInfo page = PageInfo(name); +} + +/// generated route for +/// [BasicContourPlotScreen] +class BasicContourPlotRoute extends PageRouteInfo { + const BasicContourPlotRoute({List? children}) + : super( + BasicContourPlotRoute.name, + initialChildren: children, + ); + + static const String name = 'BasicContourPlotRoute'; + + static const PageInfo page = PageInfo(name); +} + +/// generated route for +/// [BasicDotPlotScreen] +class BasicDotPlotRoute extends PageRouteInfo { + const BasicDotPlotRoute({List? children}) + : super( + BasicDotPlotRoute.name, + initialChildren: children, + ); + + static const String name = 'BasicDotPlotRoute'; + + static const PageInfo page = PageInfo(name); +} + +/// generated route for +/// [BasicLinePlotScreen] +class BasicLinePlotRoute extends PageRouteInfo { + const BasicLinePlotRoute({List? children}) + : super( + BasicLinePlotRoute.name, + initialChildren: children, + ); + + static const String name = 'BasicLinePlotRoute'; + + static const PageInfo page = PageInfo(name); +} + +/// generated route for +/// [BasicPiePlotScreen] +class BasicPiePlotRoute extends PageRouteInfo { + const BasicPiePlotRoute({List? children}) + : super( + BasicPiePlotRoute.name, + initialChildren: children, + ); + + static const String name = 'BasicPiePlotRoute'; + + static const PageInfo page = PageInfo(name); +} + +/// generated route for +/// [BasicScatterPlotScreen] +class BasicScatterPlotRoute extends PageRouteInfo { + const BasicScatterPlotRoute({List? children}) + : super( + BasicScatterPlotRoute.name, + initialChildren: children, + ); + + static const String name = 'BasicScatterPlotRoute'; + + static const PageInfo page = PageInfo(name); +} + +/// generated route for +/// [BasicTernaryPlotScreen] +class BasicTernaryPlotRoute extends PageRouteInfo { + const BasicTernaryPlotRoute({List? children}) + : super( + BasicTernaryPlotRoute.name, + initialChildren: children, + ); + + static const String name = 'BasicTernaryPlotRoute'; + + static const PageInfo page = PageInfo(name); +} + +/// generated route for +/// [BasicTreeMapChartScreen] +class BasicTreeMapChartRoute extends PageRouteInfo { + const BasicTreeMapChartRoute({List? children}) + : super( + BasicTreeMapChartRoute.name, + initialChildren: children, + ); + + static const String name = 'BasicTreeMapChartRoute'; + + static const PageInfo page = PageInfo(name); +} + +/// generated route for +/// [BubbleChartScreen] +class BubbleChartRoute extends PageRouteInfo { + const BubbleChartRoute({List? children}) + : super( + BubbleChartRoute.name, + initialChildren: children, + ); + + static const String name = 'BubbleChartRoute'; + + static const PageInfo page = PageInfo(name); +} + +/// generated route for +/// [CategoryTreeMapChartScreen] +class CategoryTreeMapChartRoute extends PageRouteInfo { + const CategoryTreeMapChartRoute({List? children}) + : super( + CategoryTreeMapChartRoute.name, + initialChildren: children, + ); + + static const String name = 'CategoryTreeMapChartRoute'; + + static const PageInfo page = PageInfo(name); +} + +/// generated route for +/// [ContourPlotScreen] +class ContourPlotRoute extends PageRouteInfo { + const ContourPlotRoute({List? children}) + : super( + ContourPlotRoute.name, + initialChildren: children, + ); + + static const String name = 'ContourPlotRoute'; + + static const PageInfo page = PageInfo(name); +} + +/// generated route for +/// [CountryPopulationPiePlotScreen] +class CountryPopulationPiePlotRoute extends PageRouteInfo { + const CountryPopulationPiePlotRoute({List? children}) + : super( + CountryPopulationPiePlotRoute.name, + initialChildren: children, + ); + + static const String name = 'CountryPopulationPiePlotRoute'; + + static const PageInfo page = PageInfo(name); +} + +/// generated route for +/// [DashedPointedLinePlotScreen] +class DashedPointedLinePlotRoute extends PageRouteInfo { + const DashedPointedLinePlotRoute({List? children}) + : super( + DashedPointedLinePlotRoute.name, + initialChildren: children, + ); + + static const String name = 'DashedPointedLinePlotRoute'; + + static const PageInfo page = PageInfo(name); +} + +/// generated route for +/// [DependencyWheelScreen] +class DependencyWheelRoute extends PageRouteInfo { + const DependencyWheelRoute({List? children}) + : super( + DependencyWheelRoute.name, + initialChildren: children, + ); + + static const String name = 'DependencyWheelRoute'; + + static const PageInfo page = PageInfo(name); +} + +/// generated route for +/// [DotPlotScreen] +class DotPlotRoute extends PageRouteInfo { + const DotPlotRoute({List? children}) + : super( + DotPlotRoute.name, + initialChildren: children, + ); + + static const String name = 'DotPlotRoute'; + + static const PageInfo page = PageInfo(name); +} + +/// generated route for +/// [FullSpaceBasicBarPlotScreen] +class FullSpaceBasicBarPlotRoute extends PageRouteInfo { + const FullSpaceBasicBarPlotRoute({List? children}) + : super( + FullSpaceBasicBarPlotRoute.name, + initialChildren: children, + ); + + static const String name = 'FullSpaceBasicBarPlotRoute'; + + static const PageInfo page = PageInfo(name); +} + +/// generated route for +/// [ImportExportDependencyWheelScreen] +class ImportExportDependencyWheelRoute extends PageRouteInfo { + const ImportExportDependencyWheelRoute({List? children}) + : super( + ImportExportDependencyWheelRoute.name, + initialChildren: children, + ); + + static const String name = 'ImportExportDependencyWheelRoute'; + + static const PageInfo page = PageInfo(name); +} + +/// generated route for +/// [LinePlotScreen] +class LinePlotRoute extends PageRouteInfo { + const LinePlotRoute({List? children}) + : super( + LinePlotRoute.name, + initialChildren: children, + ); + + static const String name = 'LinePlotRoute'; + + static const PageInfo page = PageInfo(name); +} + +/// generated route for +/// [MassiveScatterPlotScreen] +class MassiveScatterPlotRoute extends PageRouteInfo { + const MassiveScatterPlotRoute({List? children}) + : super( + MassiveScatterPlotRoute.name, + initialChildren: children, + ); + + static const String name = 'MassiveScatterPlotRoute'; + + static const PageInfo page = PageInfo(name); +} + +/// generated route for +/// [MultipleLinePlotsScreen] +class MultipleLinePlotsRoute extends PageRouteInfo { + const MultipleLinePlotsRoute({List? children}) + : super( + MultipleLinePlotsRoute.name, + initialChildren: children, + ); + + static const String name = 'MultipleLinePlotsRoute'; + + static const PageInfo page = PageInfo(name); +} + +/// generated route for +/// [PiePlotScreen] +class PiePlotRoute extends PageRouteInfo { + const PiePlotRoute({List? children}) + : super( + PiePlotRoute.name, + initialChildren: children, + ); + + static const String name = 'PiePlotRoute'; + + static const PageInfo page = PageInfo(name); +} + +/// generated route for +/// [ScatterPlotScreen] +class ScatterPlotRoute extends PageRouteInfo { + const ScatterPlotRoute({List? children}) + : super( + ScatterPlotRoute.name, + initialChildren: children, + ); + + static const String name = 'ScatterPlotRoute'; + + static const PageInfo page = PageInfo(name); +} + +/// generated route for +/// [SkeletonScreen] +class SkeletonRoute extends PageRouteInfo { + const SkeletonRoute({List? children}) + : super( + SkeletonRoute.name, + initialChildren: children, + ); + + static const String name = 'SkeletonRoute'; + + static const PageInfo page = PageInfo(name); +} + +/// generated route for +/// [SoilTernaryPlotScreen] +class SoilTernaryPlotRoute extends PageRouteInfo { + const SoilTernaryPlotRoute({List? children}) + : super( + SoilTernaryPlotRoute.name, + initialChildren: children, + ); + + static const String name = 'SoilTernaryPlotRoute'; + + static const PageInfo page = PageInfo(name); +} + +/// generated route for +/// [StackedBarPlotScreen] +class StackedBarPlotRoute extends PageRouteInfo { + const StackedBarPlotRoute({List? children}) + : super( + StackedBarPlotRoute.name, + initialChildren: children, + ); + + static const String name = 'StackedBarPlotRoute'; + + static const PageInfo page = PageInfo(name); +} + +/// generated route for +/// [TernaryPlotScreen] +class TernaryPlotRoute extends PageRouteInfo { + const TernaryPlotRoute({List? children}) + : super( + TernaryPlotRoute.name, + initialChildren: children, + ); + + static const String name = 'TernaryPlotRoute'; + + static const PageInfo page = PageInfo(name); +} + +/// generated route for +/// [TreeMapChartScreen] +class TreeMapChartRoute extends PageRouteInfo { + const TreeMapChartRoute({List? children}) + : super( + TreeMapChartRoute.name, + initialChildren: children, + ); + + static const String name = 'TreeMapChartRoute'; + + static const PageInfo page = PageInfo(name); +} diff --git a/example/lib/core/utils/constants/sizes.dart b/example/lib/core/utils/constants/sizes.dart new file mode 100644 index 0000000..6016609 --- /dev/null +++ b/example/lib/core/utils/constants/sizes.dart @@ -0,0 +1,9 @@ +abstract class Sizes { + static const double kPaddingSmall = 8.0; + static const double kPaddingMedium = 16.0; + static const double kPaddingLarge = 24.0; + + static const double kBorderRadius = 16.0; + + static const double kDefaultSpacing = 32.0; +} \ No newline at end of file diff --git a/example/lib/features/bar_plot/bar_plot.dart b/example/lib/features/bar_plot/bar_plot.dart index eddf0b3..440a989 100644 --- a/example/lib/features/bar_plot/bar_plot.dart +++ b/example/lib/features/bar_plot/bar_plot.dart @@ -1,8 +1,8 @@ -import 'package:example/features/bar_plot/screens/all_space_basic_bar_plot_screen.dart'; -import 'package:example/features/bar_plot/screens/basic_bar_plot_screen.dart'; -import 'package:example/features/bar_plot/screens/stacked_bar_plot_screen.dart'; +import 'package:auto_route/auto_route.dart'; +import 'package:example/core/config/router/app_router.dart'; import 'package:flutter/material.dart'; +@RoutePage() class BarPlotScreen extends StatelessWidget { const BarPlotScreen({super.key}); @@ -16,10 +16,8 @@ class BarPlotScreen extends StatelessWidget { title: const Text("Simple Bar Plot"), subtitle: const Text("A simple bar chart"), onTap: () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => const BasicBarPlotScreen(), - ), + context.pushRoute( + const BasicBarPlotRoute(), ); }, ), @@ -28,10 +26,8 @@ class BarPlotScreen extends StatelessWidget { title: const Text("Full Space Simple Bar Plot"), subtitle: const Text("Use all the available space"), onTap: () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => const FullSpaceBasicBarPlotScreen(), - ), + context.pushRoute( + const FullSpaceBasicBarPlotRoute(), ); }, ), @@ -40,10 +36,8 @@ class BarPlotScreen extends StatelessWidget { title: const Text("Stacked Bar Plots"), subtitle: const Text("Several bar plots"), onTap: () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => const StackedBarPlotScreen(), - ), + context.pushRoute( + const StackedBarPlotRoute(), ); }, ), diff --git a/example/lib/features/bar_plot/example.dart b/example/lib/features/bar_plot/example.dart new file mode 100644 index 0000000..8911908 --- /dev/null +++ b/example/lib/features/bar_plot/example.dart @@ -0,0 +1,26 @@ +import 'package:flutter/material.dart'; +import 'package:pretty_charts/pretty_charts.dart'; + +class BarPlotExample extends StatelessWidget { + const BarPlotExample({super.key}); + + @override + Widget build(BuildContext context) { + return BarPlot( + axes: CartesianAxes( + showGrid: true, + xLimits: AxesLimit(0, 5), + yLimits: AxesLimit(0, 5), + numberOfTicksOnX: 3, + numberOfTicksOnY: 3, + bordersToDisplay: [AxesBorder.left, AxesBorder.bottom], + ), + data: [ + BarPlotData( + x: [0, 1, 2], + y: [3, 4, 1], + ), + ], + ); + } +} diff --git a/example/lib/features/bar_plot/screens/all_space_basic_bar_plot_screen.dart b/example/lib/features/bar_plot/screens/all_space_basic_bar_plot_screen.dart index d45e933..ec78bfc 100644 --- a/example/lib/features/bar_plot/screens/all_space_basic_bar_plot_screen.dart +++ b/example/lib/features/bar_plot/screens/all_space_basic_bar_plot_screen.dart @@ -1,6 +1,8 @@ +import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:pretty_charts/pretty_charts.dart'; +@RoutePage() class FullSpaceBasicBarPlotScreen extends StatelessWidget { const FullSpaceBasicBarPlotScreen({super.key}); diff --git a/example/lib/features/bar_plot/screens/basic_bar_plot_screen.dart b/example/lib/features/bar_plot/screens/basic_bar_plot_screen.dart index 9018972..00b2373 100644 --- a/example/lib/features/bar_plot/screens/basic_bar_plot_screen.dart +++ b/example/lib/features/bar_plot/screens/basic_bar_plot_screen.dart @@ -1,6 +1,8 @@ +import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:pretty_charts/pretty_charts.dart'; +@RoutePage() class BasicBarPlotScreen extends StatelessWidget { const BasicBarPlotScreen({super.key}); diff --git a/example/lib/features/bar_plot/screens/stacked_bar_plot_screen.dart b/example/lib/features/bar_plot/screens/stacked_bar_plot_screen.dart index 8c93efc..d22cc89 100644 --- a/example/lib/features/bar_plot/screens/stacked_bar_plot_screen.dart +++ b/example/lib/features/bar_plot/screens/stacked_bar_plot_screen.dart @@ -1,6 +1,8 @@ +import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:pretty_charts/pretty_charts.dart'; +@RoutePage() class StackedBarPlotScreen extends StatelessWidget { const StackedBarPlotScreen({super.key}); diff --git a/example/lib/features/bubble_chart/bubble_chart_screen.dart b/example/lib/features/bubble_chart/bubble_chart_screen.dart index 80c5df7..c03d1fe 100644 --- a/example/lib/features/bubble_chart/bubble_chart_screen.dart +++ b/example/lib/features/bubble_chart/bubble_chart_screen.dart @@ -1,6 +1,8 @@ -import 'package:example/features/bubble_chart/screens/basic_bubble_chart_screen.dart'; +import 'package:auto_route/auto_route.dart'; +import 'package:example/core/config/router/app_router.dart'; import 'package:flutter/material.dart'; +@RoutePage() class BubbleChartScreen extends StatelessWidget { const BubbleChartScreen({super.key}); @@ -16,10 +18,8 @@ class BubbleChartScreen extends StatelessWidget { title: const Text("Basic bubble charts"), subtitle: const Text(""), onTap: () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => const BasicBubbleChart(), - ), + context.pushRoute( + const BasicBubbleChartRoute(), ); }, ), diff --git a/example/lib/features/bubble_chart/example.dart b/example/lib/features/bubble_chart/example.dart new file mode 100644 index 0000000..0114c5a --- /dev/null +++ b/example/lib/features/bubble_chart/example.dart @@ -0,0 +1,34 @@ +import 'package:flutter/material.dart'; +import 'package:pretty_charts/pretty_charts.dart'; + +class BubbleChartExample extends StatelessWidget { + const BubbleChartExample({super.key}); + + @override + Widget build(BuildContext context) { + return BubbleChart( + colorMap: pastel2, + data: [ + BubbleChartData( + x: [0, 1, 2, 3, 4, 5], + y: [3, 2, 5, 4, 4.3, 2.3], + z: [4, 3, 8, 1, 9, 2], + name: "", + ), + BubbleChartData( + x: [2.2, 3.3, 4.4, 0.3, 2.9, 4], + y: [0.5, 0.7, 2.9, 3.9, 4.4, 1.1], + z: [3, 3, 3, 2.8, 1.2, 5.4], + name: "", + ), + ], + axes: CartesianAxes( + xLimits: AxesLimit(0, 5), + yLimits: AxesLimit(0, 5), + numberOfTicksOnX: 3, + numberOfTicksOnY: 3, + showGrid: true, + ), + ); + } +} diff --git a/example/lib/features/bubble_chart/screens/basic_bubble_chart_screen.dart b/example/lib/features/bubble_chart/screens/basic_bubble_chart_screen.dart index feac6cb..1104536 100644 --- a/example/lib/features/bubble_chart/screens/basic_bubble_chart_screen.dart +++ b/example/lib/features/bubble_chart/screens/basic_bubble_chart_screen.dart @@ -1,8 +1,10 @@ +import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:pretty_charts/pretty_charts.dart'; -class BasicBubbleChart extends StatelessWidget { - const BasicBubbleChart({super.key}); +@RoutePage() +class BasicBubbleChartScreen extends StatelessWidget { + const BasicBubbleChartScreen({super.key}); @override Widget build(BuildContext context) { diff --git a/example/lib/features/contour_plot/contour_plot_screen.dart b/example/lib/features/contour_plot/contour_plot_screen.dart index 601072b..2f0c997 100644 --- a/example/lib/features/contour_plot/contour_plot_screen.dart +++ b/example/lib/features/contour_plot/contour_plot_screen.dart @@ -1,6 +1,8 @@ -import 'package:example/features/contour_plot/screens/basic_contour_plot_screen.dart'; +import 'package:auto_route/auto_route.dart'; +import 'package:example/core/config/router/app_router.dart'; import 'package:flutter/material.dart'; +@RoutePage() class ContourPlotScreen extends StatelessWidget { const ContourPlotScreen({super.key}); @@ -14,10 +16,8 @@ class ContourPlotScreen extends StatelessWidget { title: const Text("Contour Line Plot"), subtitle: const Text("A simple contour chart"), onTap: () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => const BasicContourPlotScreen(), - ), + context.pushRoute( + const BasicContourPlotRoute(), ); }, ), diff --git a/example/lib/features/contour_plot/example.dart b/example/lib/features/contour_plot/example.dart new file mode 100644 index 0000000..4f333f1 --- /dev/null +++ b/example/lib/features/contour_plot/example.dart @@ -0,0 +1,28 @@ +import 'dart:math'; + +import 'package:flutter/material.dart'; +import 'package:pretty_charts/pretty_charts.dart'; + +class ContourPlotExample extends StatelessWidget { + const ContourPlotExample({super.key}); + + @override + Widget build(BuildContext context) { + return ContourPlot( + axes: CartesianAxes( + xLimits: AxesLimit(0, 5), + yLimits: AxesLimit(0, 5), + numberOfTicksOnX: 3, + numberOfTicksOnY: 3, + ), + data: [ + ContourPlotData( + onGenerate: (x, y) { + return sin(x) + sin(y); + }, + nbLines: 20, + ), + ], + ); + } +} diff --git a/example/lib/features/contour_plot/screens/basic_contour_plot_screen.dart b/example/lib/features/contour_plot/screens/basic_contour_plot_screen.dart index a9270a6..e805c9c 100644 --- a/example/lib/features/contour_plot/screens/basic_contour_plot_screen.dart +++ b/example/lib/features/contour_plot/screens/basic_contour_plot_screen.dart @@ -1,8 +1,10 @@ import 'dart:math'; +import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:pretty_charts/pretty_charts.dart'; +@RoutePage() class BasicContourPlotScreen extends StatelessWidget { const BasicContourPlotScreen({super.key}); diff --git a/example/lib/features/dependency_wheel/dependency_wheel_screen.dart b/example/lib/features/dependency_wheel/dependency_wheel_screen.dart index 3b99a63..ccb4d67 100644 --- a/example/lib/features/dependency_wheel/dependency_wheel_screen.dart +++ b/example/lib/features/dependency_wheel/dependency_wheel_screen.dart @@ -1,7 +1,8 @@ -import 'package:example/features/dependency_wheel/screens/commercial_balance_dependency_wheel_screen.dart'; -import 'package:example/features/dependency_wheel/screens/import_export_dependency_wheel_screen.dart'; +import 'package:auto_route/auto_route.dart'; +import 'package:example/core/config/router/app_router.dart'; import 'package:flutter/material.dart'; +@RoutePage() class DependencyWheelScreen extends StatelessWidget { const DependencyWheelScreen({super.key}); @@ -15,11 +16,7 @@ class DependencyWheelScreen extends StatelessWidget { title: const Text("Sells of iPhones and Androids"), subtitle: const Text(""), onTap: () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => const AndroidIphoneDependencyWheelScreen(), - ), - ); + context.pushRoute(const AndroidIphoneDependencyWheelRoute()); }, ), const Divider(), @@ -27,11 +24,7 @@ class DependencyWheelScreen extends StatelessWidget { title: const Text("Commercial Balande between different countries"), subtitle: const Text(""), onTap: () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => const ImportExportDependencyWheelScreen(), - ), - ); + context.pushRoute(const ImportExportDependencyWheelRoute()); }, ), const Divider(), diff --git a/example/lib/features/dependency_wheel/example.dart b/example/lib/features/dependency_wheel/example.dart new file mode 100644 index 0000000..b6773e7 --- /dev/null +++ b/example/lib/features/dependency_wheel/example.dart @@ -0,0 +1,18 @@ +import 'package:flutter/material.dart'; +import 'package:pretty_charts/pretty_charts.dart'; + +class DependencyWheelExample extends StatelessWidget { + const DependencyWheelExample({super.key}); + + @override + Widget build(BuildContext context) { + return DependencyWheelChart( + sectionSpacing: 0.2, + data: [ + DependencyWheelChartData(from: "A", to: "B", value: 2), + DependencyWheelChartData(from: "A", to: "C", value: 1), + DependencyWheelChartData(from: "C", to: "B", value: 4), + ], + ); + } +} diff --git a/example/lib/features/dependency_wheel/screens/commercial_balance_dependency_wheel_screen.dart b/example/lib/features/dependency_wheel/screens/commercial_balance_dependency_wheel_screen.dart index fd7df61..5ee3783 100644 --- a/example/lib/features/dependency_wheel/screens/commercial_balance_dependency_wheel_screen.dart +++ b/example/lib/features/dependency_wheel/screens/commercial_balance_dependency_wheel_screen.dart @@ -1,8 +1,10 @@ import 'dart:math' as math; +import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:pretty_charts/pretty_charts.dart'; +@RoutePage() class AndroidIphoneDependencyWheelScreen extends StatelessWidget { const AndroidIphoneDependencyWheelScreen({super.key}); diff --git a/example/lib/features/dependency_wheel/screens/import_export_dependency_wheel_screen.dart b/example/lib/features/dependency_wheel/screens/import_export_dependency_wheel_screen.dart index 8954fa9..71148c5 100644 --- a/example/lib/features/dependency_wheel/screens/import_export_dependency_wheel_screen.dart +++ b/example/lib/features/dependency_wheel/screens/import_export_dependency_wheel_screen.dart @@ -1,8 +1,10 @@ import 'dart:math' as math; +import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:pretty_charts/pretty_charts.dart'; +@RoutePage() class ImportExportDependencyWheelScreen extends StatelessWidget { const ImportExportDependencyWheelScreen({super.key}); diff --git a/example/lib/features/dot_plot/dot_plot_screen.dart b/example/lib/features/dot_plot/dot_plot_screen.dart index f92dd8c..d000753 100644 --- a/example/lib/features/dot_plot/dot_plot_screen.dart +++ b/example/lib/features/dot_plot/dot_plot_screen.dart @@ -1,6 +1,8 @@ -import 'package:example/features/dot_plot/screens/basic_dot_plot_screen.dart'; +import 'package:auto_route/auto_route.dart'; +import 'package:example/core/config/router/app_router.dart'; import 'package:flutter/material.dart'; +@RoutePage() class DotPlotScreen extends StatelessWidget { const DotPlotScreen({super.key}); @@ -14,9 +16,7 @@ class DotPlotScreen extends StatelessWidget { title: const Text("Basic dot plot"), subtitle: const Text(""), onTap: () { - Navigator.of(context).push(MaterialPageRoute( - builder: (context) => const BasicDotPlotScreen(), - )); + context.pushRoute(const BasicDotPlotRoute()); }, ), const Divider(), diff --git a/example/lib/features/dot_plot/example.dart b/example/lib/features/dot_plot/example.dart new file mode 100644 index 0000000..d9097a2 --- /dev/null +++ b/example/lib/features/dot_plot/example.dart @@ -0,0 +1,26 @@ +import 'package:flutter/material.dart'; +import 'package:pretty_charts/pretty_charts.dart'; + +class DotPlotExample extends StatelessWidget { + const DotPlotExample({super.key}); + + @override + Widget build(BuildContext context) { + return DotPlot( + axes: CartesianAxes( + xLimits: AxesLimit(20, 100), + yLimits: AxesLimit(20, 100), + numberOfTicksOnX: 3, + numberOfTicksOnY: 3, + xLabelsBuilder: (x) { + return x.toStringAsFixed(0); + }, + ), + data: [ + DotPlotData(data: [20, 80], name: "Flutter"), + DotPlotData(data: [56, 67], name: "Python"), + DotPlotData(data: [89, 32], name: "PHP"), + ], + ); + } +} diff --git a/example/lib/features/dot_plot/screens/basic_dot_plot_screen.dart b/example/lib/features/dot_plot/screens/basic_dot_plot_screen.dart index 34666c0..743476a 100644 --- a/example/lib/features/dot_plot/screens/basic_dot_plot_screen.dart +++ b/example/lib/features/dot_plot/screens/basic_dot_plot_screen.dart @@ -1,6 +1,8 @@ +import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:pretty_charts/pretty_charts.dart'; +@RoutePage() class BasicDotPlotScreen extends StatelessWidget { const BasicDotPlotScreen({super.key}); diff --git a/example/lib/features/line_plot/example.dart b/example/lib/features/line_plot/example.dart new file mode 100644 index 0000000..fcca0f5 --- /dev/null +++ b/example/lib/features/line_plot/example.dart @@ -0,0 +1,25 @@ +import 'package:flutter/material.dart'; +import 'package:pretty_charts/pretty_charts.dart'; + +class LinePlotExample extends StatelessWidget { + const LinePlotExample({super.key}); + + @override + Widget build(BuildContext context) { + return LinePlot( + axes: CartesianAxes( + showGrid: true, + xLimits: AxesLimit(0, 5), + yLimits: AxesLimit(0, 5), + numberOfTicksOnX: 3, + numberOfTicksOnY: 3, + bordersToDisplay: [AxesBorder.left, AxesBorder.bottom], + ), + data: [ + LinePlotData( + onGenerateY: (x) => x * x, + ), + ], + ); + } +} diff --git a/example/lib/features/line_plot/line_plot_screen.dart b/example/lib/features/line_plot/line_plot_screen.dart index 273f222..7541e98 100644 --- a/example/lib/features/line_plot/line_plot_screen.dart +++ b/example/lib/features/line_plot/line_plot_screen.dart @@ -1,10 +1,8 @@ -import 'package:example/features/line_plot/screens/animated_line_plot_screen.dart'; -import 'package:example/features/line_plot/screens/dashed_line_plot_screen.dart'; -import 'package:example/features/line_plot/screens/life_expentancy_america_screen.dart'; -import 'package:example/features/line_plot/screens/multiple_line_plots_screen.dart'; -import 'package:example/features/line_plot/screens/simple_line_plot_screen.dart'; +import 'package:auto_route/auto_route.dart'; +import 'package:example/core/config/router/app_router.dart'; import 'package:flutter/material.dart'; +@RoutePage() class LinePlotScreen extends StatelessWidget { const LinePlotScreen({super.key}); @@ -18,11 +16,7 @@ class LinePlotScreen extends StatelessWidget { title: const Text("Simple Line Plot"), subtitle: const Text("A simple line chart with legends"), onTap: () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => const SimpleLinePlotScreen(), - ), - ); + context.pushRoute(const BasicLinePlotRoute()); }, ), const Divider(), @@ -31,11 +25,7 @@ class LinePlotScreen extends StatelessWidget { subtitle: const Text("Display different line plots on the same canvas"), onTap: () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => const MultipleLinePlotsScreen(), - ), - ); + context.pushRoute(const MultipleLinePlotsRoute()); }, ), const Divider(), @@ -43,11 +33,7 @@ class LinePlotScreen extends StatelessWidget { title: const Text("Dashed & Pointed Line Plot"), subtitle: const Text("Use dashed & pointed lines"), onTap: () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => const DashedPointedLinePlotScreen(), - ), - ); + context.pushRoute(const DashedPointedLinePlotRoute()); }, ), const Divider(), @@ -55,23 +41,7 @@ class LinePlotScreen extends StatelessWidget { title: const Text("Animated Line Plot"), subtitle: const Text("Different curve and duration"), onTap: () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => const AnimatedLinePlotScreen(), - ), - ); - }, - ), - const Divider(), - ListTile( - title: const Text("Life expentancy in America"), - subtitle: const Text("Multiple line curves"), - onTap: () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => const LifeExpentancyAmericaScreen(), - ), - ); + context.pushRoute(const AnimatedLinePlotRoute()); }, ), const Divider(), diff --git a/example/lib/features/line_plot/screens/animated_line_plot_screen.dart b/example/lib/features/line_plot/screens/animated_line_plot_screen.dart index 811e6ae..8319610 100644 --- a/example/lib/features/line_plot/screens/animated_line_plot_screen.dart +++ b/example/lib/features/line_plot/screens/animated_line_plot_screen.dart @@ -1,8 +1,10 @@ import 'dart:math'; +import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:pretty_charts/pretty_charts.dart'; +@RoutePage() class AnimatedLinePlotScreen extends StatelessWidget { const AnimatedLinePlotScreen({super.key}); @@ -15,31 +17,35 @@ class AnimatedLinePlotScreen extends StatelessWidget { body: Center( child: Padding( padding: const EdgeInsets.all(32.0), - child: LinePlot( - animationCurve: Curves.bounceInOut, - animationDuration: const Duration(milliseconds: 3400), - axes: CartesianAxes( - xLimits: AxesLimit(-1, 1), - yLimits: AxesLimit(-1, 1), - numberOfTicksOnX: 5, - numberOfTicksOnY: 5, - showGrid: true, - bordersToDisplay: [AxesBorder.left, AxesBorder.bottom], - arrowsToDisplay: [AxesBorder.top, AxesBorder.right], - xLabelsBuilder: (x) { - return x.toStringAsFixed(2); - }, - yLabelsBuilder: (x) { - return x.toStringAsFixed(3); - }, - ), - data: [ - LinePlotData( - onGenerateY: (x) { - return pow(x, 3).toDouble(); + child: SizedBox( + width: 400, + height: 400, + child: LinePlot( + animationCurve: Curves.bounceInOut, + animationDuration: const Duration(milliseconds: 3400), + axes: CartesianAxes( + xLimits: AxesLimit(-1, 1), + yLimits: AxesLimit(-1, 1), + numberOfTicksOnX: 5, + numberOfTicksOnY: 5, + showGrid: true, + bordersToDisplay: [AxesBorder.left, AxesBorder.bottom], + arrowsToDisplay: [AxesBorder.top, AxesBorder.right], + xLabelsBuilder: (x) { + return x.toStringAsFixed(2); + }, + yLabelsBuilder: (x) { + return x.toStringAsFixed(3); }, ), - ], + data: [ + LinePlotData( + onGenerateY: (x) { + return pow(x, 3).toDouble(); + }, + ), + ], + ), ), ), ), diff --git a/example/lib/features/line_plot/screens/basic_line_plot_screen.dart b/example/lib/features/line_plot/screens/basic_line_plot_screen.dart new file mode 100644 index 0000000..cc18fd1 --- /dev/null +++ b/example/lib/features/line_plot/screens/basic_line_plot_screen.dart @@ -0,0 +1,55 @@ +import 'dart:math'; + +import 'package:auto_route/auto_route.dart'; +import 'package:flutter/material.dart'; +import 'package:pretty_charts/pretty_charts.dart'; + +@RoutePage() +class BasicLinePlotScreen extends StatelessWidget { + const BasicLinePlotScreen({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text("Line plot"), + ), + body: Center( + child: Padding( + padding: const EdgeInsets.all(32.0), + child: SizedBox( + width: 400, + height: 400, + child: LinePlot( + axes: CartesianAxes( + xLimits: AxesLimit(-1, 1), + yLimits: AxesLimit(-1, 1), + numberOfTicksOnX: 5, + numberOfTicksOnY: 5, + showGrid: true, + title: "A great line plot", + xTitle: "times(s)", + yTitle: "voltage (mV)", + bordersToDisplay: [AxesBorder.left, AxesBorder.bottom], + arrowsToDisplay: [AxesBorder.top, AxesBorder.right], + xLabelsBuilder: (x) { + return x.toStringAsFixed(2); + }, + yLabelsBuilder: (x) { + return x.toStringAsFixed(3); + }, + ), + data: [ + LinePlotData( + onGenerateY: (x) { + return pow(x, 3).toDouble(); + }, + ), + ], + ), + ), + ), + ), + ); + } +} diff --git a/example/lib/features/line_plot/screens/dashed_line_plot_screen.dart b/example/lib/features/line_plot/screens/dashed_line_plot_screen.dart index 366a914..44a3c98 100644 --- a/example/lib/features/line_plot/screens/dashed_line_plot_screen.dart +++ b/example/lib/features/line_plot/screens/dashed_line_plot_screen.dart @@ -1,8 +1,10 @@ import 'dart:math'; +import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:pretty_charts/pretty_charts.dart'; +@RoutePage() class DashedPointedLinePlotScreen extends StatelessWidget { const DashedPointedLinePlotScreen({super.key}); @@ -15,36 +17,40 @@ class DashedPointedLinePlotScreen extends StatelessWidget { body: Center( child: Padding( padding: const EdgeInsets.all(32.0), - child: LinePlot( - axes: CartesianAxes( - xLimits: AxesLimit(-1, 1), - yLimits: AxesLimit(-1, 1), - numberOfTicksOnX: 5, - numberOfTicksOnY: 5, - showGrid: true, - bordersToDisplay: [AxesBorder.left, AxesBorder.bottom], - arrowsToDisplay: [AxesBorder.top, AxesBorder.right], - xLabelsBuilder: (x) { - return x.toStringAsFixed(2); - }, - yLabelsBuilder: (x) { - return x.toStringAsFixed(3); - }, - ), - data: [ - LinePlotData( - onGenerateY: (x) { - return pow(x, 3).toDouble(); + child: SizedBox( + width: 400, + height: 400, + child: LinePlot( + axes: CartesianAxes( + xLimits: AxesLimit(-1, 1), + yLimits: AxesLimit(-1, 1), + numberOfTicksOnX: 5, + numberOfTicksOnY: 5, + showGrid: true, + bordersToDisplay: [AxesBorder.left, AxesBorder.bottom], + arrowsToDisplay: [AxesBorder.top, AxesBorder.right], + xLabelsBuilder: (x) { + return x.toStringAsFixed(2); }, - lineStyle: LineStyle.dashed, - ), - LinePlotData( - onGenerateY: (x) { - return pow(x, 2).toDouble(); + yLabelsBuilder: (x) { + return x.toStringAsFixed(3); }, - lineStyle: LineStyle.point, ), - ], + data: [ + LinePlotData( + onGenerateY: (x) { + return pow(x, 3).toDouble(); + }, + lineStyle: LineStyle.dashed, + ), + LinePlotData( + onGenerateY: (x) { + return pow(x, 2).toDouble(); + }, + lineStyle: LineStyle.point, + ), + ], + ), ), ), ), diff --git a/example/lib/features/line_plot/screens/multiple_line_plots_screen.dart b/example/lib/features/line_plot/screens/multiple_line_plots_screen.dart index d493e30..2e3c557 100644 --- a/example/lib/features/line_plot/screens/multiple_line_plots_screen.dart +++ b/example/lib/features/line_plot/screens/multiple_line_plots_screen.dart @@ -1,8 +1,10 @@ import 'dart:math'; +import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:pretty_charts/pretty_charts.dart'; +@RoutePage() class MultipleLinePlotsScreen extends StatelessWidget { const MultipleLinePlotsScreen({super.key}); @@ -15,41 +17,45 @@ class MultipleLinePlotsScreen extends StatelessWidget { body: Center( child: Padding( padding: const EdgeInsets.all(32.0), - child: LinePlot( - animationDuration: const Duration(milliseconds: 1250), - axes: CartesianAxes( - xLimits: AxesLimit(-1, 1), - yLimits: AxesLimit(-1, 1), - numberOfTicksOnX: 5, - numberOfTicksOnY: 5, - showGrid: true, - title: "A great line plot", - bordersToDisplay: [AxesBorder.left, AxesBorder.bottom], - arrowsToDisplay: [AxesBorder.top, AxesBorder.right], - xLabelsBuilder: (x) { - return x.toStringAsFixed(2); - }, - yLabelsBuilder: (x) { - return x.toStringAsFixed(3); - }, - ), - data: [ - LinePlotData( - onGenerateY: (x) { - return pow(x, 3).toDouble(); + child: SizedBox( + width: 400, + height: 400, + child: LinePlot( + animationDuration: const Duration(milliseconds: 1250), + axes: CartesianAxes( + xLimits: AxesLimit(-1, 1), + yLimits: AxesLimit(-1, 1), + numberOfTicksOnX: 5, + numberOfTicksOnY: 5, + showGrid: true, + title: "A great line plot", + bordersToDisplay: [AxesBorder.left, AxesBorder.bottom], + arrowsToDisplay: [AxesBorder.top, AxesBorder.right], + xLabelsBuilder: (x) { + return x.toStringAsFixed(2); }, - ), - LinePlotData( - onGenerateY: (x) { - return pow(x, 2).toDouble(); + yLabelsBuilder: (x) { + return x.toStringAsFixed(3); }, ), - LinePlotData( - onGenerateY: (x) { - return pow(x, 1).toDouble(); - }, - ), - ], + data: [ + LinePlotData( + onGenerateY: (x) { + return pow(x, 3).toDouble(); + }, + ), + LinePlotData( + onGenerateY: (x) { + return pow(x, 2).toDouble(); + }, + ), + LinePlotData( + onGenerateY: (x) { + return pow(x, 1).toDouble(); + }, + ), + ], + ), ), ), ), diff --git a/example/lib/features/pie_plot/example.dart b/example/lib/features/pie_plot/example.dart new file mode 100644 index 0000000..a64ff55 --- /dev/null +++ b/example/lib/features/pie_plot/example.dart @@ -0,0 +1,30 @@ +import 'package:flutter/material.dart'; +import 'package:pretty_charts/pretty_charts.dart'; + +class PiePlotExample extends StatelessWidget { + const PiePlotExample({super.key}); + + @override + Widget build(BuildContext context) { + return PiePlot( + data: [ + PiePlotData( + name: '', + value: 22.3, + ), + PiePlotData( + name: '', + value: 42.3, + ), + PiePlotData( + name: '', + value: 4.3, + ), + PiePlotData( + name: '', + value: 6.3, + ), + ], + ); + } +} diff --git a/example/lib/features/pie_plot/pie_plot_screen.dart b/example/lib/features/pie_plot/pie_plot_screen.dart index 8da8344..50ee151 100644 --- a/example/lib/features/pie_plot/pie_plot_screen.dart +++ b/example/lib/features/pie_plot/pie_plot_screen.dart @@ -1,8 +1,8 @@ -import 'package:example/features/pie_plot/screens/basic_pie_plot_screen.dart'; -import 'package:example/features/pie_plot/screens/country_population_pie_plot_screen.dart'; -import 'package:example/features/pie_plot/screens/donut_plot_screen.dart'; +import 'package:auto_route/auto_route.dart'; +import 'package:example/core/config/router/app_router.dart'; import 'package:flutter/material.dart'; +@RoutePage() class PiePlotScreen extends StatelessWidget { const PiePlotScreen({super.key}); @@ -16,11 +16,7 @@ class PiePlotScreen extends StatelessWidget { title: const Text("Simple Bar Plot"), subtitle: const Text("A simple bar chart"), onTap: () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => const BasicPiePlotScreen(), - ), - ); + context.pushRoute(const BasicPiePlotRoute()); }, ), const Divider(), @@ -28,23 +24,7 @@ class PiePlotScreen extends StatelessWidget { title: const Text("Country population"), subtitle: const Text("Countries with the biggest population"), onTap: () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => const CountryPopulationPiePlotScreen(), - ), - ); - }, - ), - const Divider(), - ListTile( - title: const Text("Donut plot"), - subtitle: const Text("With a hole"), - onTap: () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => const DonutPlotScreen(), - ), - ); + context.pushRoute(const CountryPopulationPiePlotRoute()); }, ), const Divider(), diff --git a/example/lib/features/pie_plot/screens/basic_pie_plot_screen.dart b/example/lib/features/pie_plot/screens/basic_pie_plot_screen.dart index 9bbadd9..d8f82d3 100644 --- a/example/lib/features/pie_plot/screens/basic_pie_plot_screen.dart +++ b/example/lib/features/pie_plot/screens/basic_pie_plot_screen.dart @@ -1,6 +1,8 @@ +import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:pretty_charts/pretty_charts.dart'; +@RoutePage() class BasicPiePlotScreen extends StatelessWidget { const BasicPiePlotScreen({super.key}); diff --git a/example/lib/features/pie_plot/screens/country_population_pie_plot_screen.dart b/example/lib/features/pie_plot/screens/country_population_pie_plot_screen.dart index 4cf6cfe..268539f 100644 --- a/example/lib/features/pie_plot/screens/country_population_pie_plot_screen.dart +++ b/example/lib/features/pie_plot/screens/country_population_pie_plot_screen.dart @@ -1,6 +1,8 @@ +import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:pretty_charts/pretty_charts.dart'; +@RoutePage() class CountryPopulationPiePlotScreen extends StatelessWidget { const CountryPopulationPiePlotScreen({super.key}); diff --git a/example/lib/features/scatter_plot/example.dart b/example/lib/features/scatter_plot/example.dart new file mode 100644 index 0000000..1ced3b9 --- /dev/null +++ b/example/lib/features/scatter_plot/example.dart @@ -0,0 +1,31 @@ +import 'package:flutter/material.dart'; +import 'package:pretty_charts/pretty_charts.dart'; + +class ScatterPlotExample extends StatelessWidget { + const ScatterPlotExample({super.key}); + + @override + Widget build(BuildContext context) { + return ScatterPlot( + data: [ + ScatterPlotData( + x: [0, 1, 2, 3, 4, 5, 4, 3], + y: [0, 1, 2, 3, 4, 5, 3, 1], + name: "", + ), + ScatterPlotData( + x: [0, 1, 2, 3, 4], + y: [3, 4, 1, 1.2, 5], + name: "", + ) + ], + axes: CartesianAxes( + xLimits: AxesLimit(0, 5), + yLimits: AxesLimit(0, 5), + numberOfTicksOnX: 3, + numberOfTicksOnY: 3, + showGrid: true, + ), + ); + } +} diff --git a/example/lib/features/scatter_plot/scatter_plot_screen.dart b/example/lib/features/scatter_plot/scatter_plot_screen.dart index 0f80282..59d90a4 100644 --- a/example/lib/features/scatter_plot/scatter_plot_screen.dart +++ b/example/lib/features/scatter_plot/scatter_plot_screen.dart @@ -1,7 +1,8 @@ -import 'package:example/features/scatter_plot/screens/basic_scatter_plot.dart'; -import 'package:example/features/scatter_plot/screens/massive_scatter_plot.dart'; +import 'package:auto_route/auto_route.dart'; +import 'package:example/core/config/router/app_router.dart'; import 'package:flutter/material.dart'; +@RoutePage() class ScatterPlotScreen extends StatelessWidget { const ScatterPlotScreen({super.key}); @@ -17,11 +18,7 @@ class ScatterPlotScreen extends StatelessWidget { title: const Text("Basic scatter plot"), subtitle: const Text(""), onTap: () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => const BasicScatterPlot(), - ), - ); + context.pushRoute(const BasicScatterPlotRoute()); }, ), const Divider(), @@ -29,11 +26,7 @@ class ScatterPlotScreen extends StatelessWidget { title: const Text("Massive Scatter plot"), subtitle: const Text("Lot of points (>100 000)"), onTap: () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => const MassiveScatterPlot(), - ), - ); + context.pushRoute(const MassiveScatterPlotRoute()); }, ), const Divider(), diff --git a/example/lib/features/scatter_plot/screens/basic_scatter_plot.dart b/example/lib/features/scatter_plot/screens/basic_scatter_plot.dart index 5b6e592..8b2311d 100644 --- a/example/lib/features/scatter_plot/screens/basic_scatter_plot.dart +++ b/example/lib/features/scatter_plot/screens/basic_scatter_plot.dart @@ -1,9 +1,11 @@ +import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:pretty_charts/pretty_charts.dart'; -class BasicScatterPlot extends StatelessWidget { - const BasicScatterPlot({super.key}); +@RoutePage() +class BasicScatterPlotScreen extends StatelessWidget { + const BasicScatterPlotScreen({super.key}); @override Widget build(BuildContext context) { diff --git a/example/lib/features/scatter_plot/screens/massive_scatter_plot.dart b/example/lib/features/scatter_plot/screens/massive_scatter_plot.dart index c014ce6..8d58ca9 100644 --- a/example/lib/features/scatter_plot/screens/massive_scatter_plot.dart +++ b/example/lib/features/scatter_plot/screens/massive_scatter_plot.dart @@ -1,10 +1,12 @@ import 'dart:math'; +import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:pretty_charts/pretty_charts.dart'; -class MassiveScatterPlot extends StatelessWidget { - const MassiveScatterPlot({super.key}); +@RoutePage() +class MassiveScatterPlotScreen extends StatelessWidget { + const MassiveScatterPlotScreen({super.key}); @override Widget build(BuildContext context) { diff --git a/example/lib/features/skeleton/skeleton_screen.dart b/example/lib/features/skeleton/skeleton_screen.dart new file mode 100644 index 0000000..eb4ad0f --- /dev/null +++ b/example/lib/features/skeleton/skeleton_screen.dart @@ -0,0 +1,154 @@ +import 'package:flutter/material.dart'; +import 'package:auto_route/auto_route.dart'; +import 'package:example/core/config/router/app_router.dart'; +import 'package:example/core/utils/constants/sizes.dart'; +import 'package:example/features/bar_plot/example.dart'; +import 'package:example/features/bubble_chart/example.dart'; +import 'package:example/features/contour_plot/example.dart'; +import 'package:example/features/dependency_wheel/example.dart'; +import 'package:example/features/dot_plot/example.dart'; +import 'package:example/features/line_plot/example.dart'; +import 'package:example/features/pie_plot/example.dart'; +import 'package:example/features/scatter_plot/example.dart'; +import 'package:example/features/ternary_plot/example.dart'; +import 'package:example/features/treemap_chart/example.dart'; + +@RoutePage() +class SkeletonScreen extends StatelessWidget { + const SkeletonScreen({super.key}); + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Padding( + padding: const EdgeInsets.all(Sizes.kPaddingMedium), + child: ListView( + children: [ + Padding( + padding: const EdgeInsets.all(Sizes.kPaddingMedium), + child: Text( + "Basic plots", + style: Theme.of(context).textTheme.headlineLarge, + ), + ), + const Wrap( + alignment: WrapAlignment.center, + spacing: Sizes.kDefaultSpacing, + runSpacing: Sizes.kDefaultSpacing, + children: [ + PlotCard( + name: "Line Plot", + plot: LinePlotExample(), + destinationPage: LinePlotRoute(), + ), + PlotCard( + name: "Bar Plot", + plot: BarPlotExample(), + destinationPage: BarPlotRoute(), + ), + PlotCard( + name: "Pie Plot", + plot: PiePlotExample(), + destinationPage: PiePlotRoute(), + ), + PlotCard( + name: "Scatter Plot", + plot: ScatterPlotExample(), + destinationPage: ScatterPlotRoute(), + ), + PlotCard( + name: "Bubble Chart", + plot: BubbleChartExample(), + destinationPage: ScatterPlotRoute(), + ), + ], + ), + Padding( + padding: const EdgeInsets.all(Sizes.kPaddingMedium), + child: Text("Other plots", + style: Theme.of(context).textTheme.headlineLarge), + ), + const Wrap( + alignment: WrapAlignment.center, + spacing: Sizes.kDefaultSpacing, + runSpacing: Sizes.kDefaultSpacing, + children: [ + PlotCard( + name: "Dependency Wheel", + plot: DependencyWheelExample(), + destinationPage: DependencyWheelRoute(), + ), + PlotCard( + name: "Ternary Plot", + plot: TernaryPlotExample(), + destinationPage: TernaryPlotRoute(), + ), + PlotCard( + name: "Treemap Chart", + plot: TreemapChartExample(), + destinationPage: TreeMapChartRoute(), + ), + PlotCard( + name: "Dot Plot", + plot: DotPlotExample(), + destinationPage: DotPlotRoute(), + ), + PlotCard( + name: "Contour Plot", + plot: ContourPlotExample(), + destinationPage: ContourPlotRoute(), + ), + ], + ), + ], + ), + ), + ); + } +} + +class PlotCard extends StatelessWidget { + const PlotCard({ + super.key, + required this.name, + required this.plot, + required this.destinationPage, + }); + + final String name; + final Widget plot; + final PageRouteInfo destinationPage; + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: () { + context.pushRoute(destinationPage); + }, + borderRadius: BorderRadius.circular(Sizes.kBorderRadius), + child: Container( + width: 250, + height: 300, + padding: const EdgeInsets.all(Sizes.kPaddingSmall), + decoration: BoxDecoration( + border: Border.all(color: Theme.of(context).colorScheme.primary), + borderRadius: BorderRadius.circular(Sizes.kBorderRadius), + ), + child: Column( + children: [ + Text( + name, + style: Theme.of(context).textTheme.headlineSmall, + ), + Expanded( + child: Padding( + padding: const EdgeInsets.all(Sizes.kPaddingSmall), + child: IgnorePointer(child: plot), + ), + ), + ], + ), + ), + ); + } +} diff --git a/example/lib/features/ternary_plot/example.dart b/example/lib/features/ternary_plot/example.dart new file mode 100644 index 0000000..5f4c44d --- /dev/null +++ b/example/lib/features/ternary_plot/example.dart @@ -0,0 +1,60 @@ +import 'package:flutter/material.dart'; +import 'package:pretty_charts/pretty_charts.dart'; + +class TernaryPlotExample extends StatelessWidget { + const TernaryPlotExample({super.key}); + + @override + Widget build(BuildContext context) { + return TernaryPlot( + colorMap: pastel2, + data: [ + TernaryPlotData( + name: "", + data: [ + TernaryPosition( + leftAxesValue: 0, + rightAxesValue: 0, + bottomAxesValue: 100, + ), + TernaryPosition( + leftAxesValue: 30, + rightAxesValue: 0, + bottomAxesValue: 90, + ), + TernaryPosition( + leftAxesValue: 0, + rightAxesValue: 30, + bottomAxesValue: 90, + ), + ], + ), + TernaryPlotData( + name: "", + data: [ + TernaryPosition( + leftAxesValue: 100, + bottomAxesValue: 0, + rightAxesValue: 0, + ), + TernaryPosition( + leftAxesValue: 80, + bottomAxesValue: 40, + rightAxesValue: 0, + ), + TernaryPosition( + leftAxesValue: 40, + bottomAxesValue: 40, + rightAxesValue: 40, + ), + ], + ), + ], + axes: TernaryPlotAxes( + leftAxesTitle: "Water", + rightAxesTitle: "Salt", + bottomAxesTitle: "Sugar", + ), + ); + } +} diff --git a/example/lib/features/ternary_plot/screens/basic_ternary_plot_screen.dart b/example/lib/features/ternary_plot/screens/basic_ternary_plot_screen.dart index 428c1bf..5c03546 100644 --- a/example/lib/features/ternary_plot/screens/basic_ternary_plot_screen.dart +++ b/example/lib/features/ternary_plot/screens/basic_ternary_plot_screen.dart @@ -1,6 +1,8 @@ +import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:pretty_charts/pretty_charts.dart'; +@RoutePage() class BasicTernaryPlotScreen extends StatelessWidget { const BasicTernaryPlotScreen({super.key}); diff --git a/example/lib/features/ternary_plot/screens/soil_ternay_plot_screen.dart b/example/lib/features/ternary_plot/screens/soil_ternay_plot_screen.dart index ac94d9c..30a41e0 100644 --- a/example/lib/features/ternary_plot/screens/soil_ternay_plot_screen.dart +++ b/example/lib/features/ternary_plot/screens/soil_ternay_plot_screen.dart @@ -1,7 +1,9 @@ +import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:pretty_charts/pretty_charts.dart'; // https://gist.github.com/davenquinn/988167471993bc2ece29 +@RoutePage() class SoilTernaryPlotScreen extends StatelessWidget { const SoilTernaryPlotScreen({super.key}); diff --git a/example/lib/features/ternary_plot/ternary_plot.dart b/example/lib/features/ternary_plot/ternary_plot.dart index 36f0b96..e775195 100644 --- a/example/lib/features/ternary_plot/ternary_plot.dart +++ b/example/lib/features/ternary_plot/ternary_plot.dart @@ -1,7 +1,8 @@ -import 'package:example/features/ternary_plot/screens/basic_ternary_plot_screen.dart'; -import 'package:example/features/ternary_plot/screens/soil_ternay_plot_screen.dart'; import 'package:flutter/material.dart'; +import 'package:auto_route/auto_route.dart'; +import 'package:example/core/config/router/app_router.dart'; +@RoutePage() class TernaryPlotScreen extends StatelessWidget { const TernaryPlotScreen({super.key}); @@ -15,11 +16,7 @@ class TernaryPlotScreen extends StatelessWidget { title: const Text("Simple Ternary Plot"), subtitle: const Text("A simple Ternary chart"), onTap: () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => const BasicTernaryPlotScreen(), - ), - ); + context.pushRoute(const BasicTernaryPlotRoute()); }, ), const Divider(), @@ -27,11 +24,7 @@ class TernaryPlotScreen extends StatelessWidget { title: const Text("Soil Ternary Plot"), subtitle: const Text("An example using soil data"), onTap: () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => const SoilTernaryPlotScreen(), - ), - ); + context.pushRoute(const SoilTernaryPlotRoute()); }, ), const Divider(), diff --git a/example/lib/features/treemap_chart/example.dart b/example/lib/features/treemap_chart/example.dart new file mode 100644 index 0000000..30e31a8 --- /dev/null +++ b/example/lib/features/treemap_chart/example.dart @@ -0,0 +1,19 @@ +import 'package:flutter/material.dart'; +import 'package:pretty_charts/pretty_charts.dart'; + +class TreemapChartExample extends StatelessWidget { + const TreemapChartExample({super.key}); + + @override + Widget build(BuildContext context) { + return TreeMapChart( + data: [ + TreeMapChartData(name: "France", value: 54), + TreeMapChartData(name: "Italy", value: 22), + TreeMapChartData(name: "Spain", value: 10), + TreeMapChartData(name: "Portugal", value: 5), + TreeMapChartData(name: "UK", value: 2), + ], + ); + } +} diff --git a/example/lib/features/treemap_chart/screens/basic_treemap_chart_screen.dart b/example/lib/features/treemap_chart/screens/basic_treemap_chart_screen.dart index b90671e..281fcb5 100644 --- a/example/lib/features/treemap_chart/screens/basic_treemap_chart_screen.dart +++ b/example/lib/features/treemap_chart/screens/basic_treemap_chart_screen.dart @@ -1,7 +1,9 @@ +import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; import 'package:pretty_charts/pretty_charts.dart'; +@RoutePage() class BasicTreeMapChartScreen extends StatelessWidget { const BasicTreeMapChartScreen({super.key}); diff --git a/example/lib/features/treemap_chart/screens/category_treemap_chart_screen.dart b/example/lib/features/treemap_chart/screens/category_treemap_chart_screen.dart index 01d0cca..7b7e1bf 100644 --- a/example/lib/features/treemap_chart/screens/category_treemap_chart_screen.dart +++ b/example/lib/features/treemap_chart/screens/category_treemap_chart_screen.dart @@ -1,7 +1,9 @@ +import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; import 'package:pretty_charts/pretty_charts.dart'; +@RoutePage() class CategoryTreeMapChartScreen extends StatelessWidget { const CategoryTreeMapChartScreen({super.key}); diff --git a/example/lib/features/treemap_chart/treemap_chart_screen.dart b/example/lib/features/treemap_chart/treemap_chart_screen.dart index ba81929..cdc32b6 100644 --- a/example/lib/features/treemap_chart/treemap_chart_screen.dart +++ b/example/lib/features/treemap_chart/treemap_chart_screen.dart @@ -1,7 +1,8 @@ -import 'package:example/features/treemap_chart/screens/basic_treemap_chart_screen.dart'; -import 'package:example/features/treemap_chart/screens/category_treemap_chart_screen.dart'; import 'package:flutter/material.dart'; +import 'package:auto_route/auto_route.dart'; +import 'package:example/core/config/router/app_router.dart'; +@RoutePage() class TreeMapChartScreen extends StatelessWidget { const TreeMapChartScreen({super.key}); @@ -15,11 +16,7 @@ class TreeMapChartScreen extends StatelessWidget { title: const Text("Basic Treemap chart"), subtitle: const Text(""), onTap: () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => const BasicTreeMapChartScreen(), - ), - ); + context.pushRoute(const BasicTreeMapChartRoute()); }, ), const Divider(), @@ -27,11 +24,7 @@ class TreeMapChartScreen extends StatelessWidget { title: const Text("Category Treemap chart"), subtitle: const Text(""), onTap: () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => const CategoryTreeMapChartScreen(), - ), - ); + context.pushRoute(const CategoryTreeMapChartRoute()); }, ), const Divider(), diff --git a/example/lib/main.dart b/example/lib/main.dart index 0db03f1..1c413bd 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,7 +1,13 @@ -import 'package:example/home_screen.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_web_plugins/url_strategy.dart'; +import 'package:example/core/config/router/app_router.dart'; void main() { + if (kIsWeb) { + usePathUrlStrategy(); + } + runApp(const MyApp()); } @@ -11,14 +17,13 @@ class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { - return MaterialApp( + return MaterialApp.router( title: 'Pretty Charts', - debugShowCheckedModeBanner: false, theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), useMaterial3: true, ), - home: const HomeScreen(), + routerConfig: appRouter.config(), ); } } diff --git a/example/pubspec.lock b/example/pubspec.lock index f087bc6..26c39d2 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -1,6 +1,30 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + sha256: "0b2f2bd91ba804e53a61d757b986f89f1f9eaed5b11e4b2f5a2468d86d6c9fc7" + url: "https://pub.dev" + source: hosted + version: "67.0.0" + analyzer: + dependency: transitive + description: + name: analyzer + sha256: "37577842a27e4338429a1cbc32679d508836510b056f1eedf0c8d20e39c1383d" + url: "https://pub.dev" + source: hosted + version: "6.4.1" + args: + dependency: transitive + description: + name: args + sha256: "7cf60b9f0cc88203c5a190b4cd62a99feea42759a7fa695010eb5de1c0b2252a" + url: "https://pub.dev" + source: hosted + version: "2.5.0" async: dependency: transitive description: @@ -9,6 +33,22 @@ packages: url: "https://pub.dev" source: hosted version: "2.11.0" + auto_route: + dependency: "direct main" + description: + name: auto_route + sha256: "6cad3f408863ffff2b5757967c802b18415dac4acb1b40c5cdd45d0a26e5080f" + url: "https://pub.dev" + source: hosted + version: "8.1.3" + auto_route_generator: + dependency: "direct dev" + description: + name: auto_route_generator + sha256: ba28133d3a3bf0a66772bcc98dade5843753cd9f1a8fb4802b842895515b67d3 + url: "https://pub.dev" + source: hosted + version: "8.0.0" boolean_selector: dependency: transitive description: @@ -17,6 +57,70 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.1" + build: + dependency: transitive + description: + name: build + sha256: "80184af8b6cb3e5c1c4ec6d8544d27711700bc3e6d2efad04238c7b5290889f0" + url: "https://pub.dev" + source: hosted + version: "2.4.1" + build_config: + dependency: transitive + description: + name: build_config + sha256: bf80fcfb46a29945b423bd9aad884590fb1dc69b330a4d4700cac476af1708d1 + url: "https://pub.dev" + source: hosted + version: "1.1.1" + build_daemon: + dependency: transitive + description: + name: build_daemon + sha256: "0343061a33da9c5810b2d6cee51945127d8f4c060b7fbdd9d54917f0a3feaaa1" + url: "https://pub.dev" + source: hosted + version: "4.0.1" + build_resolvers: + dependency: transitive + description: + name: build_resolvers + sha256: "339086358431fa15d7eca8b6a36e5d783728cf025e559b834f4609a1fcfb7b0a" + url: "https://pub.dev" + source: hosted + version: "2.4.2" + build_runner: + dependency: "direct dev" + description: + name: build_runner + sha256: "3ac61a79bfb6f6cc11f693591063a7f19a7af628dc52f141743edac5c16e8c22" + url: "https://pub.dev" + source: hosted + version: "2.4.9" + build_runner_core: + dependency: transitive + description: + name: build_runner_core + sha256: "4ae8ffe5ac758da294ecf1802f2aff01558d8b1b00616aa7538ea9a8a5d50799" + url: "https://pub.dev" + source: hosted + version: "7.3.0" + built_collection: + dependency: transitive + description: + name: built_collection + sha256: "376e3dd27b51ea877c28d525560790aee2e6fbb5f20e2f85d5081027d94e2100" + url: "https://pub.dev" + source: hosted + version: "5.1.1" + built_value: + dependency: transitive + description: + name: built_value + sha256: c7913a9737ee4007efedaffc968c049fd0f3d0e49109e778edc10de9426005cb + url: "https://pub.dev" + source: hosted + version: "8.9.2" characters: dependency: transitive description: @@ -25,6 +129,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.0" + checked_yaml: + dependency: transitive + description: + name: checked_yaml + sha256: feb6bed21949061731a7a75fc5d2aa727cf160b91af9a3e464c5e3a32e28b5ff + url: "https://pub.dev" + source: hosted + version: "2.0.3" clock: dependency: transitive description: @@ -33,6 +145,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.1" + code_builder: + dependency: transitive + description: + name: code_builder + sha256: f692079e25e7869c14132d39f223f8eec9830eb76131925143b2129c4bb01b37 + url: "https://pub.dev" + source: hosted + version: "4.10.0" collection: dependency: transitive description: @@ -41,14 +161,30 @@ packages: url: "https://pub.dev" source: hosted version: "1.18.0" - cupertino_icons: - dependency: "direct main" + convert: + dependency: transitive + description: + name: convert + sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" + url: "https://pub.dev" + source: hosted + version: "3.1.1" + crypto: + dependency: transitive + description: + name: crypto + sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab + url: "https://pub.dev" + source: hosted + version: "3.0.3" + dart_style: + dependency: transitive description: - name: cupertino_icons - sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6 + name: dart_style + sha256: "99e066ce75c89d6b29903d788a7bb9369cf754f7b24bf70bf4b6d6d6b26853b9" url: "https://pub.dev" source: hosted - version: "1.0.8" + version: "2.3.6" fake_async: dependency: transitive description: @@ -57,6 +193,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.1" + file: + dependency: transitive + description: + name: file + sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c" + url: "https://pub.dev" + source: hosted + version: "7.0.0" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" + url: "https://pub.dev" + source: hosted + version: "1.1.0" flutter: dependency: "direct main" description: flutter @@ -75,6 +227,51 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_web_plugins: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + frontend_server_client: + dependency: transitive + description: + name: frontend_server_client + sha256: f64a0333a82f30b0cca061bc3d143813a486dc086b574bfb233b7c1372427694 + url: "https://pub.dev" + source: hosted + version: "4.0.0" + glob: + dependency: transitive + description: + name: glob + sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + graphs: + dependency: transitive + description: + name: graphs + sha256: aedc5a15e78fc65a6e23bcd927f24c64dd995062bcd1ca6eda65a3cff92a4d19 + url: "https://pub.dev" + source: hosted + version: "2.3.1" + http_multi_server: + dependency: transitive + description: + name: http_multi_server + sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b" + url: "https://pub.dev" + source: hosted + version: "3.2.1" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" + url: "https://pub.dev" + source: hosted + version: "4.0.2" intl: dependency: "direct main" description: @@ -83,6 +280,30 @@ packages: url: "https://pub.dev" source: hosted version: "0.19.0" + io: + dependency: transitive + description: + name: io + sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e" + url: "https://pub.dev" + source: hosted + version: "1.0.4" + js: + dependency: transitive + description: + name: js + sha256: c1b2e9b5ea78c45e1a0788d29606ba27dc5f71f019f32ca5140f61ef071838cf + url: "https://pub.dev" + source: hosted + version: "0.7.1" + json_annotation: + dependency: transitive + description: + name: json_annotation + sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1" + url: "https://pub.dev" + source: hosted + version: "4.9.0" leak_tracker: dependency: transitive description: @@ -115,6 +336,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.0" + logging: + dependency: transitive + description: + name: logging + sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" + url: "https://pub.dev" + source: hosted + version: "1.2.0" matcher: dependency: transitive description: @@ -139,6 +368,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.11.0" + mime: + dependency: transitive + description: + name: mime + sha256: "2e123074287cc9fd6c09de8336dae606d1ddb88d9ac47358826db698c176a1f2" + url: "https://pub.dev" + source: hosted + version: "1.0.5" + package_config: + dependency: transitive + description: + name: package_config + sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" + url: "https://pub.dev" + source: hosted + version: "2.1.0" path: dependency: transitive description: @@ -147,6 +392,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.0" + petitparser: + dependency: transitive + description: + name: petitparser + sha256: c15605cd28af66339f8eb6fbe0e541bfe2d1b72d5825efc6598f3e0a31b9ad27 + url: "https://pub.dev" + source: hosted + version: "6.0.2" + pool: + dependency: transitive + description: + name: pool + sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" + url: "https://pub.dev" + source: hosted + version: "1.5.1" pretty_charts: dependency: "direct main" description: @@ -154,11 +415,51 @@ packages: relative: true source: path version: "0.0.1-dev.1" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + pubspec_parse: + dependency: transitive + description: + name: pubspec_parse + sha256: c63b2876e58e194e4b0828fcb080ad0e06d051cb607a6be51a9e084f47cb9367 + url: "https://pub.dev" + source: hosted + version: "1.2.3" + shelf: + dependency: transitive + description: + name: shelf + sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4 + url: "https://pub.dev" + source: hosted + version: "1.4.1" + shelf_web_socket: + dependency: transitive + description: + name: shelf_web_socket + sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1" + url: "https://pub.dev" + source: hosted + version: "1.0.4" sky_engine: dependency: transitive description: flutter source: sdk version: "0.0.99" + source_gen: + dependency: transitive + description: + name: source_gen + sha256: "14658ba5f669685cd3d63701d01b31ea748310f7ab854e471962670abcf57832" + url: "https://pub.dev" + source: hosted + version: "1.5.0" source_span: dependency: transitive description: @@ -183,6 +484,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.2" + stream_transform: + dependency: transitive + description: + name: stream_transform + sha256: "14a00e794c7c11aa145a170587321aedce29769c08d7f58b1d141da75e3b1c6f" + url: "https://pub.dev" + source: hosted + version: "2.1.0" string_scanner: dependency: transitive description: @@ -207,6 +516,22 @@ packages: url: "https://pub.dev" source: hosted version: "0.6.1" + timing: + dependency: transitive + description: + name: timing + sha256: "70a3b636575d4163c477e6de42f247a23b315ae20e86442bebe32d3cabf61c32" + url: "https://pub.dev" + source: hosted + version: "1.0.1" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c + url: "https://pub.dev" + source: hosted + version: "1.3.2" vector_math: dependency: transitive description: @@ -223,6 +548,46 @@ packages: url: "https://pub.dev" source: hosted version: "13.0.0" + watcher: + dependency: transitive + description: + name: watcher + sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + web: + dependency: transitive + description: + name: web + sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27" + url: "https://pub.dev" + source: hosted + version: "0.5.1" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + sha256: "58c6666b342a38816b2e7e50ed0f1e261959630becd4c879c4f26bfa14aa5a42" + url: "https://pub.dev" + source: hosted + version: "2.4.5" + xml: + dependency: transitive + description: + name: xml + sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226 + url: "https://pub.dev" + source: hosted + version: "6.5.0" + yaml: + dependency: transitive + description: + name: yaml + sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" + url: "https://pub.dev" + source: hosted + version: "3.1.2" sdks: dart: ">=3.3.3 <4.0.0" - flutter: ">=1.17.0" + flutter: ">=3.16.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 37e7c43..da967fe 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -30,13 +30,15 @@ environment: dependencies: flutter: sdk: flutter + + flutter_web_plugins: + sdk: flutter + pretty_charts: path: ".." - intl: 0.19.0 - # The following adds the Cupertino Icons font to your application. - # Use with the CupertinoIcons class for iOS style icons. - cupertino_icons: ^1.0.6 + auto_route: ^8.1.3 + intl: ^0.19.0 dev_dependencies: flutter_test: @@ -48,6 +50,8 @@ dev_dependencies: # package. See that file for information about deactivating specific lint # rules and activating additional ones. flutter_lints: ^3.0.0 + auto_route_generator: ^8.0.0 + build_runner: ^2.4.9 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec