diff --git a/Flutter/DateRangePicker/Callbacks.md b/Flutter/DateRangePicker/Callbacks.md index ef95a828a..03a992b1f 100644 --- a/Flutter/DateRangePicker/Callbacks.md +++ b/Flutter/DateRangePicker/Callbacks.md @@ -7,9 +7,9 @@ control: SfDateRangePicker documentation: ug --- -# Callbacks in Flutter DateRangePicker (SfDateRangePicker) +# Callbacks in Flutter Date Range Picker (SfDateRangePicker) -Calendar supports the [ViewChangedCallback](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerViewChangedCallback.html) and [SelectionChangedCallback](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionChangedCallback.html) to interact with the Flutter date range picker. +Calendar supports the [ViewChangedCallback](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerViewChangedCallback.html) and [SelectionChangedCallback](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionChangedCallback.html) to interact with the Flutter Date Range Picker. ## View changed callback @@ -40,7 +40,7 @@ The [onViewChanged](https://pub.dev/documentation/syncfusion_flutter_datepicker/ ## Selection changed callback -The [onSelectionChanged](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/onSelectionChanged.html) callback triggers when selecting the dates from the date picker. +The [onSelectionChanged](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/onSelectionChanged.html) callback triggers when selecting the dates from the Flutter Date Range Picker. * `args.value` - returns the dates based on the selection mode. diff --git a/Flutter/DateRangePicker/accessibility.md b/Flutter/DateRangePicker/accessibility.md index 04eb8453e..1886f05e8 100644 --- a/Flutter/DateRangePicker/accessibility.md +++ b/Flutter/DateRangePicker/accessibility.md @@ -75,7 +75,7 @@ The following APIs allows you to customize the colors of the following elements. ## Large fonts -The [SfDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker-class.html) font size can be adjusted automatically based on device settings and the font size scaled based on the [MediaQueryData.textScaleFactor](https://api.flutter.dev/flutter/widgets/MediaQueryData/textScaleFactor.html). It also allows you to change the font size of all elements in date range picker. +The [SfDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker-class.html) font size can be adjusted automatically based on device settings and the font size scaled based on the [MediaQueryData.textScaleFactor](https://api.flutter.dev/flutter/widgets/MediaQueryData/textScaleFactor.html). It also allows you to change the font size of all elements in Flutter Date Range Picker. * [todayTextStyle](https://help.syncfusion.com/flutter/daterangepicker/customizations) * [leadingDatesTextStyle](https://help.syncfusion.com/flutter/daterangepicker/customizations) * [trailingDatesTextStyle](https://help.syncfusion.com/flutter/daterangepicker/customizations) diff --git a/Flutter/DateRangePicker/builders.md b/Flutter/DateRangePicker/builders.md index d06ca9447..14c01935a 100644 --- a/Flutter/DateRangePicker/builders.md +++ b/Flutter/DateRangePicker/builders.md @@ -8,11 +8,11 @@ documentation: ug --- # Builders in Flutter DateRangePicker (SfDateRangePicker) -The date range picker allows you to create a responsive UI with the conditions based on a widget’s details, and to design and create your custom view to the month cells and year cells in the date range picker. +The Flutter Date Range Picker allows you to create a responsive UI with the conditions based on a widget’s details, and to design and create your custom view to the month cells and year cells. ## Cell builder -The [DateRangePickerCellBuilder](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerCellBuilder.html) allows you to design your custom view and assign the view to the month and year view cells of the date range picker by returning an appropriate widget in the [cellBuilder](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/cellBuilder.html) of [SfDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker-class.html). +The [DateRangePickerCellBuilder](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerCellBuilder.html) allows you to design your custom view and assign the view to the month and year view cells of the Flutter Date Range Picker by returning an appropriate widget in the [cellBuilder](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/cellBuilder.html) of [SfDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker-class.html). [DateRangePickerCellDetails](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerCellDetails-class.html): Returns the details of the cell. diff --git a/Flutter/DateRangePicker/customizations.md b/Flutter/DateRangePicker/customizations.md index 6ca14ebc7..e1a40f296 100644 --- a/Flutter/DateRangePicker/customizations.md +++ b/Flutter/DateRangePicker/customizations.md @@ -107,7 +107,7 @@ You can customize the month format of the [SfDateRangePicker](https://pub.dev/do ## Selection cell customization -You can also customize the date range picker section by using the [monthCellStyle](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/monthCellStyle.html) of [SfDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker-class.html). +You can also customize the Flutter Date Range Picker section by using the [monthCellStyle](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/monthCellStyle.html) of [SfDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker-class.html). * **Selection date text style** – Selected date text style can be customized using the [selectionTextStyle](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/selectionTextStyle.html) property of [SfDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker-class.html) that is applicable for [selectionMode](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/selectionMode.html) is [single](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionMode.html#single) and [multiple](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionMode.html#multiple), it is also applicable to start and end of the selected range text style in the [single](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionMode.html#single) and [multiRange](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionMode.html#multiRange) selection. diff --git a/Flutter/DateRangePicker/date-navigations.md b/Flutter/DateRangePicker/date-navigations.md index a589745b5..22bcc4b4f 100644 --- a/Flutter/DateRangePicker/date-navigations.md +++ b/Flutter/DateRangePicker/date-navigations.md @@ -7,7 +7,7 @@ control: SfDateRangePicker documentation: ug --- -# Date Navigation in Flutter DateRangePicker (SfDateRangePicker) +# Date Navigation in Flutter Date Range Picker (SfDateRangePicker) ## Programmatic date navigation @@ -392,7 +392,7 @@ You can customize the navigation mode of the date range picker by using the [nav >**NOTE** When the navigation mode is set to [DateRangePickerNavigationMode.scroll](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerNavigationMode.html#scroll). * Swipe selection is not supported when the range and multi-range are the selection modes. -* The [onViewChanged](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/onViewChanged.html) will be called when the view reaches the starting position of the date range picker view. +* The [onViewChanged](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/onViewChanged.html) will be called when the view reaches the starting position of the Date Range Picker view. * [forward](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerController/forward.html), [backward](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerController/backward.html) and [showNavigationArrow](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/showNavigationArrow.html) is not supported. diff --git a/Flutter/DateRangePicker/date-restrictions.md b/Flutter/DateRangePicker/date-restrictions.md index 9182fc1aa..f0d13cb4d 100644 --- a/Flutter/DateRangePicker/date-restrictions.md +++ b/Flutter/DateRangePicker/date-restrictions.md @@ -7,7 +7,7 @@ control: SfDateRangePicker documentation: ug --- -# Date Restrictions in Flutter DateRangePicker (SfDateRangePicker) +# Date Restrictions in Flutter Date Range Picker (SfDateRangePicker) ## Minimum display date @@ -97,7 +97,7 @@ In [SfDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepick ## SelectableDayPredicate -[selectableDayPredicate](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/selectableDayPredicate.html) callback allows certain days for selection. Only the days that [selectableDayPredicate](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/selectableDayPredicate.html) returns `true` will be selectable in the date range picker. +[selectableDayPredicate](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/selectableDayPredicate.html) callback allows certain days for selection. Only the days that [selectableDayPredicate](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/selectableDayPredicate.html) returns `true` will be selectable in the Flutter Date Range Picker. {% tabs %} {% highlight dart hl_lines="4 5 6 7 8 9" %} diff --git a/Flutter/DateRangePicker/getting-started.md b/Flutter/DateRangePicker/getting-started.md index 3f440361d..e02d32566 100644 --- a/Flutter/DateRangePicker/getting-started.md +++ b/Flutter/DateRangePicker/getting-started.md @@ -7,11 +7,11 @@ control: SfDateRangePicker documentation: ug --- -# Getting Started with Flutter DateRangePicker (SfDateRangePicker) +# Getting Started with Flutter Date Range Picker (SfDateRangePicker) -This section explains the steps required to add the [date range picker](https://www.syncfusion.com/flutter-widgets/flutter-daterangepicker) widget. This section covers only basic features needed to get started with Syncfusion® date range picker widget. +This section explains the steps required to add the [Flutter Date Range Picker](https://www.syncfusion.com/flutter-widgets/flutter-daterangepicker) widget. This section covers only basic features needed to get started with Syncfusion® Flutter DateRangePicker widget. -To get start quickly with our Flutter date range picker widget, you can check on this video. +To get start quickly with our Flutter Date Range Picker widget, you can check on this video. @@ -22,7 +22,7 @@ Create a simple project using the instructions given in the [Getting Started wit **Add dependency** -Add the Syncfusion® Flutter date range picker dependency to your `pubspec.yaml` file. +Add the Syncfusion® Flutter Date Range Picker dependency to your `pubspec.yaml` file. {% highlight dart %} @@ -32,7 +32,7 @@ syncfusion_flutter_datepicker: ^xx.x.xx {% endhighlight %} -N> Here **xx.x.xx** denotes the current version of [`Syncfusion Flutter Date Picker`](https://pub.dev/packages/syncfusion_flutter_datepicker/versions) package. +N> Here **xx.x.xx** denotes the current version of [`Syncfusion Flutter Date Range Picker`](https://pub.dev/packages/syncfusion_flutter_datepicker/versions) package. **Get packages** @@ -56,9 +56,9 @@ import 'package:syncfusion_flutter_datepicker/datepicker.dart'; {% endhighlight %} {% endtabs %} -## Initialize date range picker +## Initialize Date Range Picker -After importing the package, initialize the date range picker widget as a child of any widget. Here, the date range picker widget is added as a child of the scaffold widget. +After importing the package, initialize the Flutter Date Range Picker widget as a child of any widget. Here, the date range picker widget is added as a child of the scaffold widget. {% tabs %} {% highlight dart hl_lines="5" %} @@ -79,7 +79,7 @@ After importing the package, initialize the date range picker widget as a child ## Multiple picker views -The [SfDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker-class.html) widget provides four different types of views to display. It can be assigned to the widget constructor by using the [view](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/view.html) property. Default view of the widget is month view. By default the current date will be displayed initially for all the date range picker views. + The [SfDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker-class.html) widget provides four different types of views to display. It can be assigned to the widget constructor by using the [view](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/view.html) property. Default view of the widget is month view. By default the current date will be displayed initially for all the Date Range Picker views. {% tabs %} {% highlight dart hl_lines="5" %} @@ -124,7 +124,7 @@ The [SfDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepic The [SfDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker-class.html) supports selecting single, multiple, and range of dates. It also supports programmatic selection. -The selected date or range details can be obtained using the [onSelectionChanged](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/onSelectionChanged.html) callback of date range picker. The callback will return the [DateRangePickerSelectionChangedArgs](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionChangedArgs-class.html) which contains the selected date or range details. +The selected date or range details can be obtained using the [onSelectionChanged](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/onSelectionChanged.html) callback of the Flutter Date Range Picker. The callback will return the [DateRangePickerSelectionChangedArgs](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionChangedArgs-class.html) which contains the selected date or range details. {% tabs %} {% highlight dart hl_lines="1 2 3 11" %} @@ -154,7 +154,7 @@ The selected date or range details can be obtained using the [onSelectionChanged ## Today highlight color -You can highlight the today’s date by customizing its color in the date range picker by using the [todayHighlightColor](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/todayHighlightColor.html) property. This allows you to make today’s date stand out in all views such as month, year, decade, and century. +You can highlight the today’s date by customizing its color in the Flutter Date Range Picker by using the [todayHighlightColor](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/todayHighlightColor.html) property. This allows you to make today’s date stand out in all views such as month, year, decade, and century. {% tabs %} @@ -175,7 +175,7 @@ You can highlight the today’s date by customizing its color in the date range ## Action buttons -You can display action buttons at the bottom of the date range picker by using the [showActionButtons](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/showActionButtons.html) property of [SfDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker-class.html). +You can display action buttons at the bottom of the Flutter Date Range Picker by using the [showActionButtons](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/showActionButtons.html) property of [SfDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker-class.html). * [confirmText](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/confirmText.html) - Customizes the text that display on the confirm button. @@ -183,7 +183,7 @@ You can display action buttons at the bottom of the date range picker by using t * [onCancel](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/onCancel.html) - Callback function that is triggered when the cancel button is tapped within a date range picker. -* [onSubmit](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/onSubmit.html) - Callback function that is triggered when the confirm button is tapped within a date range picker. +* [onSubmit](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/onSubmit.html) - Callback function that is triggered when the confirm button is tapped within a Flutter Date Range Picker. {% tabs %} {% highlight dart hl_lines="11" %} @@ -220,7 +220,7 @@ You can display action buttons at the bottom of the date range picker by using t ## Today button -The today button can be displayed at the bottom of the date range picker by using the [showTodayButton](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/showTodayButton.html) property of the [SfDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker-class.html). It easily moves to the current date of the picker view. +The today button can be displayed at the bottom of the Flutter Date Range Picker by using the [showTodayButton](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/showTodayButton.html) property of the [SfDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker-class.html). It easily moves to the current date of the picker view. {% tabs %} {% highlight dart hl_lines="6" %} diff --git a/Flutter/DateRangePicker/headers.md b/Flutter/DateRangePicker/headers.md index ccc87a339..9d2dc4ffe 100644 --- a/Flutter/DateRangePicker/headers.md +++ b/Flutter/DateRangePicker/headers.md @@ -7,9 +7,9 @@ control: SfDateRangePicker documentation: ug --- -# Headers in Flutter DateRangePicker (SfDateRangePicker) +# Headers in Flutter Date Range Picker (SfDateRangePicker) -You can customize the header of the date range picker using the [headerStyle](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/headerStyle.html) and [headerHeight](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/headerHeight.html) properties in date range picker. +You can customize the header of the Flutter Date Range Picker using the [headerStyle](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/headerStyle.html) and [headerHeight](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/headerHeight.html) properties in date range picker. ## Customize the header height diff --git a/Flutter/DateRangePicker/hijri-date-picker.md b/Flutter/DateRangePicker/hijri-date-picker.md index 1ce4ae145..d6c0843cf 100644 --- a/Flutter/DateRangePicker/hijri-date-picker.md +++ b/Flutter/DateRangePicker/hijri-date-picker.md @@ -7,13 +7,13 @@ control: SfDateRangePicker documentation: ug --- -# About Flutter Hijri DateRangePicker Control (SfHijriDateRangePicker) +# About Flutter Hijri Date Range Picker Control (SfHijriDateRangePicker) Along with the Gregorian calendar, the picker package contains a Hijri date picker to display the Islamic calendar. Islamic calendar or Hijri calendar is a lunar calendar consisting of 12 months in a year of 354 or 355 days. To know more about the Islamic calendar, kindly refer to [Wikipedia](https://en.wikipedia.org/wiki/Islamic_calendar). It consists of all the Gregorian calendar functionalities like min and max date, the first day of the week, different selection modes, RTL, and customization for special dates. -To display the Hijri date picker, initialize the [HijriDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfHijriDateRangePicker-class.html) widget as a child of any widget. Here, the Hijri date range picker added as a child of the scaffold widget. +To display the Hijri Date Range Picker, initialize the [HijriDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfHijriDateRangePicker-class.html) widget as a child of any widget. Here, the Hijri date range picker added as a child of the scaffold widget. {% tabs %} {% highlight dart hl_lines="4" %} @@ -30,7 +30,7 @@ To display the Hijri date picker, initialize the [HijriDateRangePicker](https:// {% endhighlight %} {% endtabs %} -![Hijri date range picker](images/hijri-picker/hijri_programattic_view_navigation.jpg) +![Hijri Date Range Picker](images/hijri-picker/hijri_programattic_view_navigation.jpg) >**NOTE** * Most of the properties type and classes were same from [SfDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker-class.html) except the followings [HijriDatePickerController](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/HijriDatePickerController-class.html), [HijriDatePickerMonthCellStyle](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/HijriDatePickerMonthCellStyle-class.html), [HijriDatePickerMonthViewSettings](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/HijriDatePickerMonthViewSettings-class.html), [HijriDatePickerViewChangedArgs](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/HijriDatePickerViewChangedArgs-class.html), [HijriDatePickerYearCellStyle](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/HijriDatePickerYearCellStyle-class.html), [HijriDateRange](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/HijriDateRange-class.html) and [HijriDatePickerView](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/HijriDatePickerView.html). @@ -38,7 +38,7 @@ To display the Hijri date picker, initialize the [HijriDateRangePicker](https:// ## Multiple picker views -The [SfHijriDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfHijriDateRangePicker-class.html) widget provides three different types of views to display. It can be assigned to the widget constructor by using the [view](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfHijriDateRangePicker/view.html) property. The default view of the widget is the month view. By default, the current date will be displayed initially for all the date range picker views. +The [SfHijriDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfHijriDateRangePicker-class.html) widget provides three different types of views to display. It can be assigned to the widget constructor by using the [view](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfHijriDateRangePicker/view.html) property. The default view of the widget is the month view. By default, the current date will be displayed initially for all the Date Range Picker views. {% tabs %} {% highlight dart hl_lines="6" %} @@ -144,7 +144,7 @@ Customize the Week number style by using the [textStyle](https://pub.dev/documen The [SfHijriDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfHijriDateRangePicker-class.html) supports selecting single, multiple, and range of dates. It also supports the programmatic selection. -The selected date or range details can be obtained using the [onSelectionChanged](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfHijriDateRangePicker/onSelectionChanged.html) callback of Hijri date range picker. The callback will return the [DateRangePickerSelectionChangedArgs](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionChangedArgs-class.html), which contains the selected date or range details. +The selected date or range details can be obtained using the [onSelectionChanged](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfHijriDateRangePicker/onSelectionChanged.html) callback of Hijri Date Range Picker. The callback will return the [DateRangePickerSelectionChangedArgs](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionChangedArgs-class.html), which contains the selected date or range details. {% tabs %} @@ -173,7 +173,7 @@ The selected date or range details can be obtained using the [onSelectionChanged ## Programmatic date navigation -You can programmatically navigate date in the Hijri date picker widget by using the [displayDate](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/HijriDatePickerController/displayDate.html) property from [HijriDatePickerController](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/HijriDatePickerController-class.html). +You can programmatically navigate date in the Hijri Date Range Picker widget by using the [displayDate](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/HijriDatePickerController/displayDate.html) property from [HijriDatePickerController](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/HijriDatePickerController-class.html). {% tabs %} {% highlight dart hl_lines="2 6 15" %} @@ -206,7 +206,7 @@ class MyAppState extends State { ## Programmatic view navigation -You can programmatically navigate to any view in the Hijri date picker widget by using the [view](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/HijriDatePickerController/view.html) property of [HijriDatePickerController](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/HijriDatePickerController-class.html). +You can programmatically navigate to any view in the Hijri Date Range Picker widget by using the [view](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/HijriDatePickerController/view.html) property of [HijriDatePickerController](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/HijriDatePickerController-class.html). {% tabs %} {% highlight dart hl_lines="2 6 15" %} @@ -238,7 +238,7 @@ class MyAppState extends State { ## Programmatic date selection -You can select dates programmatically on the Hijri date picker widget by using the [HijriDatePickerController](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/HijriDatePickerController-class.html). +You can select dates programmatically on the Hijri Date Range Picker widget by using the [HijriDatePickerController](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/HijriDatePickerController-class.html). For selection [refer](https://help.syncfusion.com/flutter/daterangepicker/selections). @@ -321,7 +321,7 @@ class MyAppState extends State { You can select the single date range programmatically by using the [selectedRange](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerController/selectedRange.html) property of [HijriDatePickerController](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/HijriDatePickerController-class.html). It is only applicable when the [selectionMode](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfHijriDateRangePicker/selectionMode.html) is set to [DateRangePickerSelectionMode.range](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionMode.html#range). -Use the [HijriDateRange](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/HijriDateRange-class.html) to define the date range for the Hijri date picker. +Use the [HijriDateRange](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/HijriDateRange-class.html) to define the date range for the Hijri Date Range Picker. {% tabs %} {% highlight dart hl_lines="2 7 8 17 18" %} @@ -398,7 +398,7 @@ class MyAppState extends State { ### Extendable range selection -Extend the selected range with the new selected date in any date range picker view by setting the [DateRangePickerSelectionMode](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionMode.html) to [extendableRange](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionMode.html#extendableRange). +Extend the selected range with the new selected date in any Date Range Picker view by setting the [DateRangePickerSelectionMode](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionMode.html) to [extendableRange](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionMode.html#extendableRange). {% tabs %} {% highlight dart hl_lines="2 7 8 17 18" %} @@ -467,7 +467,7 @@ You can set the extendable range selection direction as forward, backward, both ## Month cell customization -Customize the Hijri date picker month view by using the [monthCellStyle](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfHijriDateRangePicker/monthCellStyle.html) property of [SfHijriDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfHijriDateRangePicker-class.html). +Customize the Hijri Date Range Picker month view by using the [monthCellStyle](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfHijriDateRangePicker/monthCellStyle.html) property of [SfHijriDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfHijriDateRangePicker-class.html). * **Current month dates**: You can customize the text style and background of the current month dates in the [SfHijriDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfHijriDateRangePicker-class.html) by using the [textStyle](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/HijriDatePickerMonthCellStyle/textStyle.html) and [cellDecoration](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/HijriDatePickerMonthCellStyle/cellDecoration.html) properties of [HijriDatePickerMonthCellStyle](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/HijriDatePickerMonthCellStyle-class.html). * **Today date**: You can customize the text style and background of the today's date in the [SfHijriDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfHijriDateRangePicker-class.html) by using the [todayTextStyle](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/HijriDatePickerMonthCellStyle/todayTextStyle.html) and [todayCellDecoration](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/HijriDatePickerMonthCellStyle/todayCellDecoration.html). diff --git a/Flutter/DateRangePicker/how-to/custom-widget-on-flutterflow.md b/Flutter/DateRangePicker/how-to/custom-widget-on-flutterflow.md index 9f2ce742d..373186722 100644 --- a/Flutter/DateRangePicker/how-to/custom-widget-on-flutterflow.md +++ b/Flutter/DateRangePicker/how-to/custom-widget-on-flutterflow.md @@ -7,7 +7,7 @@ control: SfDateRangePicker documentation: ug --- -# How to Add DateRangePicker in FlutterFlow (SfDateRangePicker) +# How to Add Date Range Picker in FlutterFlow (SfDateRangePicker) ## Overview @@ -28,31 +28,31 @@ Navigate to the [FlutterFlow dashboard](https://app.flutterflow.io/dashboard) an ![Custom Widget](how-to-section-images/custom-widget.png) -### Add DateRangePicker widget as a dependency +### Add Date Range Picker widget as a dependency 1. Click on `+ Add Dependency`, a text editor will appear. -2. Navigate to [Syncfusion® Flutter DatePicker](https://pub.dev/packages/syncfusion_flutter_datepicker) in [pub.dev](https://pub.dev/) and copy the dependency name and version using the `Copy to Clipboard` option. +2. Navigate to [Syncfusion® Flutter DateRangePicker](https://pub.dev/packages/syncfusion_flutter_datepicker) in [pub.dev](https://pub.dev/) and copy the dependency name and version using the `Copy to Clipboard` option. ![Version](how-to-section-images/copy-version.png) 3. Paste the copied dependency into the text editor, then click `Refresh` and `Save` it. ->**Note**: The live version of [Syncfusion® Flutter DatePicker](https://pub.dev/packages/syncfusion_flutter_datepicker) has been migrated to the latest version of Flutter SDK. To ensure compatibility, check [FlutterFlow](https://app.flutterflow.io/dashboard)'s current Flutter version and obtain the corresponding version of [Syncfusion® Flutter DatePicker](https://pub.dev/packages/syncfusion_flutter_datepicker) by referring to the [SDK compatibility](https://help.syncfusion.com/flutter/system-requirements#sdk-version-compatibility). +>**Note**: The live version of [Syncfusion® Flutter DateRangePicker](https://pub.dev/packages/syncfusion_flutter_datepicker) has been migrated to the latest version of Flutter SDK. To ensure compatibility, check [FlutterFlow](https://app.flutterflow.io/dashboard)'s current Flutter version and obtain the corresponding version of [Syncfusion® Flutter DateRangePicker](https://pub.dev/packages/syncfusion_flutter_datepicker) by referring to the [SDK compatibility](https://help.syncfusion.com/flutter/system-requirements#sdk-version-compatibility). ![Dependency](how-to-section-images/dependency.png) >**Note**: If you are using an older version of a dependency instead of the latest one, remove the caret symbol (^) prefix in the version number after pasting the dependency. For example, change `^21.3.0` to `21.3.0`. ->**Note**: Since [Syncfusion® Flutter DatePicker](https://pub.dev/packages/syncfusion_flutter_datepicker) depends on the [Syncfusion® Flutter Core](https://pub.dev/packages/syncfusion_flutter_core) package, make sure to add it as a dependency following the same steps mentioned above. +>**Note**: Since [Syncfusion® Flutter DateRangePicker](https://pub.dev/packages/syncfusion_flutter_datepicker) depends on the [Syncfusion® Flutter Core](https://pub.dev/packages/syncfusion_flutter_core) package, make sure to add it as a dependency following the same steps mentioned above. ### Import the package -1. Navigate to the `Installing` tab on the [Syncfusion® Flutter DatePicker](https://pub.dev/packages/syncfusion_flutter_datepicker) page. Under the `Import it` section, copy the package import statement. +1. Navigate to the `Installing` tab on the [Syncfusion® Flutter DateRangePicker](https://pub.dev/packages/syncfusion_flutter_datepicker) page. Under the `Import it` section, copy the package import statement. ![Package](how-to-section-images/copy-package.png) 2. Paste the copied import statement into the code editor and then `Save` it. ![Import](how-to-section-images/import-package-flutterflow.png) ### Add widget code snippet in code editor -1. Navigate to the [Example](https://pub.dev/packages/syncfusion_flutter_datepicker/example) tab in [Syncfusion® Flutter DatePicker](https://pub.dev/packages/syncfusion_flutter_datepicker) and copy the widget specific codes. +1. Navigate to the [Example](https://pub.dev/packages/syncfusion_flutter_datepicker/example) tab in [Syncfusion® Flutter DateRangePicker](https://pub.dev/packages/syncfusion_flutter_datepicker) and copy the widget specific codes. ![Code](how-to-section-images/code-snippet.png) 2. Paste the copied code sample into the code editor, click `Format Code`, and `Save` it. ![Code snippet](how-to-section-images/Adding-code-snippent.png) diff --git a/Flutter/DateRangePicker/localization.md b/Flutter/DateRangePicker/localization.md index 2f628dbbb..56e2dac49 100644 --- a/Flutter/DateRangePicker/localization.md +++ b/Flutter/DateRangePicker/localization.md @@ -7,7 +7,7 @@ control: SfDateRangePicker documentation: ug --- -# Localization in Flutter DateRangePicker (SfDateRangePicker) +# Localization in Flutter Date Range Picker (SfDateRangePicker) By default, the [SfDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker-class.html) widget supports US English localizations. You can change other languages by specifying the [MaterialApp](https://api.flutter.dev/flutter/material/MaterialApp-class.html) properties and adding the `flutter_localizations` package to your application. diff --git a/Flutter/DateRangePicker/overview.md b/Flutter/DateRangePicker/overview.md index 16e66d8db..e9c5d0c56 100644 --- a/Flutter/DateRangePicker/overview.md +++ b/Flutter/DateRangePicker/overview.md @@ -7,7 +7,7 @@ control: SfDateRangePicker documentation: ug --- -# About Flutter DateRangePicker Control (SfDateRangePicker) +# About Flutter Date Range Picker Control (SfDateRangePicker) The Syncfusion® Flutter Date Range Picker is a lightweight widget that allows users to easily select a single date, multiple dates, or a range of dates. It provides month, year, decade, and century view options to quickly navigate to the desired date. It supports minimum, maximum, and disabled dates to restrict date selection. @@ -38,21 +38,21 @@ The Syncfusion® Flutter Date Range Picker is a lightweight widget * **Change first day of week**: Customize the first day of the week as needed. The default first day is Sunday. -* **Blackout dates**: Disable any date to make it inactive in a date range picker. Easily prevent the selection of weekends by disabling them. +* **Blackout dates**: Disable any date to make it inactive in a Date Range Picker. Easily prevent the selection of weekends by disabling them. ![Blackout dates Date Range Picker](images/overview/blackoutdates.png) -* **Highlight holidays and weekends**: Highlight any date or every weekend in a month as special days using decoration in Flutter date range picker. +* **Highlight holidays and weekends**: Highlight any date or every weekend in a month as special days using decoration in Flutter Date Range Picker. ![Highlight holidays and weekends Date Range Picker](images/overview/customization.png) -* **Appearance customization**: Change the look and feel of the date range picker by customizing its default appearance and style using Flutter decorations. +* **Appearance customization**: Change the look and feel of the Date Range Picker by customizing its default appearance and style using Flutter decorations. * **Right to left (RTL)** - Right-to-left direction support for users working in RTL languages like Hebrew and Arabic. ![Right to left Date Range Picker](images/overview/right_to_left.png) -* **Accessibility** - Easy access of the date range picker by screen readers. +* **Accessibility** - Easy access of the Date Range Picker by screen readers. * **Globalization** - Display the current date and time by following the globalized date and time formats. diff --git a/Flutter/DateRangePicker/right-to-left.md b/Flutter/DateRangePicker/right-to-left.md index 523cc7c32..1db270666 100644 --- a/Flutter/DateRangePicker/right-to-left.md +++ b/Flutter/DateRangePicker/right-to-left.md @@ -7,7 +7,7 @@ control: SfDateRangePicker documentation: ug --- -# Right-to-Left (RTL) in Flutter DateRangePicker (SfDateRangePicker) +# Right-to-Left (RTL) in Flutter Date Range Picker (SfDateRangePicker) [SfDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker-class.html) supports Right to left rendering and all the date picker elements rendering direction will be changed. @@ -40,7 +40,7 @@ The [SfDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepic ### Changing the locale to RTL languages -To change the date range picker rendering direction from right to left, change the locale to any of the RTL languages such as Arabic, Persian, Hebrew, Pashto, and Urdu. +To change the rendering direction of the Flutter Date Range Picker from right to left, change the locale to any of the RTL languages such as Arabic, Persian, Hebrew, Pashto, and Urdu. {% tabs %} {% highlight dart hl_lines="4 5 6 7 8 9 10 11 12 13" %} diff --git a/Flutter/DateRangePicker/selections.md b/Flutter/DateRangePicker/selections.md index f5c814b69..2b70241b3 100644 --- a/Flutter/DateRangePicker/selections.md +++ b/Flutter/DateRangePicker/selections.md @@ -7,15 +7,15 @@ control: SfDateRangePicker documentation: ug --- -# Selections in Flutter DateRangePicker (SfDateRangePicker) +# Selections in Flutter Date Range Picker (SfDateRangePicker) Dates can be selected by touching the month view cells. The default [selectionMode](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/selectionMode.html) is Single that allows the user to select one date at a time. [SfDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker-class.html) provides support to select dates in five modes such as [Single](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionMode.html#single), [Multiple](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionMode.html#multiple), [Range](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionMode.html#range) [MultiRange](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionMode.html#multiRange) and [ExtendableRange](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionMode.html#extendableRange) selection ->**NOTE** When the [allowViewNavigation](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/allowViewNavigation.html) property is set to `false`, the Date range picker allows you to select the cells in the year, decade, and century views of date range picker. +>**NOTE** When the [allowViewNavigation](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/allowViewNavigation.html) property is set to `false`, the Flutter Date Range Picker allows you to select the cells in the year, decade, and century views. ## Single selection - A [single](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionMode.html#single) date range picker cell can be selected in a date range picker view by setting the [DateRangePickerSelectionMode](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionMode.html) to [single](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionMode.html#single). +A [single](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionMode.html#single) cell can be selected in the Flutter Date Range Picker view by setting the [DateRangePickerSelectionMode](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionMode.html) to [single](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionMode.html#single). {% tabs %} {% highlight dart hl_lines="6" %} @@ -45,7 +45,7 @@ Dates can be selected by touching the month view cells. The default [selectionMo ## Multiple selection -You can randomly select more than one date range picker cell by setting the [DateRangePickerSelectionMode](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionMode.html) to [multiple](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionMode.html#multiple). By clicking again you can deselect the selected cells. +You can randomly select more than one Date Range Picker cell by setting the [DateRangePickerSelectionMode](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionMode.html) to [multiple](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionMode.html#multiple). By clicking again you can deselect the selected cells. {% tabs %} {% highlight dart hl_lines="6" %} @@ -67,7 +67,7 @@ You can randomly select more than one date range picker cell by setting the [Dat ## Range selection -You can select a range of cells in any date range picker view by setting the [DateRangePickerSelectionMode](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionMode.html) to the [range](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionMode.html#range). +You can select a range of cells in any Date Range Picker view by setting the [DateRangePickerSelectionMode](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionMode.html) to the [range](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionMode.html#range). {% tabs %} {% highlight dart hl_lines="6" %} @@ -97,7 +97,7 @@ You can select a range of cells in any date range picker view by setting the [Da ## Multi range selection -You can select more than one range of cells in any of the date range picker views by setting the [DateRangePickerSelectionMode](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionMode.html) to the [multiRange](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionMode.html#multiRange). +You can select more than one range of cells in any of the Date Range Picker views by setting the [DateRangePickerSelectionMode](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionMode.html) to the [multiRange](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionMode.html#multiRange). {% tabs %} {% highlight dart hl_lines="6" %} @@ -119,7 +119,7 @@ You can select more than one range of cells in any of the date range picker view ## Extendable range selection -Extend the selected range with the new selected date in any date range picker view by setting the [DateRangePickerSelectionMode](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionMode.html) to [extendableRange](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionMode.html#extendableRange). +Extend the selected range with the new selected date in any Date Range Picker view by setting the [DateRangePickerSelectionMode](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionMode.html) to [extendableRange](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerSelectionMode.html#extendableRange). {% tabs %} {% highlight dart hl_lines="7" %} diff --git a/Flutter/DateRangePicker/views.md b/Flutter/DateRangePicker/views.md index c28f7f117..61ec4694f 100644 --- a/Flutter/DateRangePicker/views.md +++ b/Flutter/DateRangePicker/views.md @@ -7,9 +7,9 @@ control: SfDateRangePicker documentation: ug --- -# Views in Flutter DateRangePicker (SfDateRangePicker) +# Views in Flutter Date Range Picker (SfDateRangePicker) -The [SfDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker-class.html) widget provides four different types of views to display. It can be assigned to the widget constructor by using the [view](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/view.html) property. Default view of the widget is month view. By default the current date will be displayed initially for all the date range picker views. +The [SfDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker-class.html) widget provides four different types of views to display. It can be assigned to the widget constructor by using the [view](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/view.html) property. Default view of the widget is month view. By default the current date will be displayed initially for all the Date Range Picker views. ## Month view @@ -178,7 +178,7 @@ The number of weeks in the month view can be customized by setting the [numberOf ## Multi-date picker view -You can enable a multi-date range picker by using the [enableMultiView](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/enableMultiView.html) property of [SfDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker-class.html), which displays two date range pickers side by side, the space between the two date-range picker can be customized by using the [viewSpacing](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/viewSpacing.html) property of [SfDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker-class.html). +You can enable a multi-view Date Range Picker by using the [enableMultiView](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/enableMultiView.html) property of [SfDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker-class.html), which displays two date range pickers side by side, the space between the two date-range picker can be customized by using the [viewSpacing](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/viewSpacing.html) property of [SfDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker-class.html). {% tabs %} {% highlight dart hl_lines="6" %} @@ -205,7 +205,7 @@ You can enable a multi-date range picker by using the [enableMultiView](https:// ## Vertical picker -You can arrange the two date range picker views in the vertical direction by setting the [navigationDirection](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/navigationDirection.html) as [DateRangePickerNavigationDirection.vertical](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerNavigationDirection.html#vertical) in the [SfDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker-class.html).` +You can arrange the two Date Range Picker views in the vertical direction by setting the [navigationDirection](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker/navigationDirection.html) as [DateRangePickerNavigationDirection.vertical](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/DateRangePickerNavigationDirection.html#vertical) in the [SfDateRangePicker](https://pub.dev/documentation/syncfusion_flutter_datepicker/latest/datepicker/SfDateRangePicker-class.html).` {% tabs %} {% highlight dart hl_lines="7" %} @@ -226,7 +226,7 @@ You can arrange the two date range picker views in the vertical direction by set {% endhighlight %} {% endtabs %} -![vertical date picker](images/views/vertical-datepicker.png) +![vertical Date Range Picker](images/views/vertical-datepicker.png) ## See also diff --git a/Flutter/ai-assistview/action-button.md b/Flutter/ai-assistview/action-button.md index 70d1fc011..493b69d61 100644 --- a/Flutter/ai-assistview/action-button.md +++ b/Flutter/ai-assistview/action-button.md @@ -48,7 +48,7 @@ class DefaultActionButtonExample extends StatelessWidget { {% endhighlight %} {% endtabs %} -![AIAssistView actionButton support](images/action-button/default-actionbutton.gif) +![AI AssistView actionButton support](images/action-button/default-actionbutton.gif) ### Child @@ -84,7 +84,7 @@ class ActionButtonChildExample extends StatelessWidget { {% endhighlight %} {% endtabs %} -![AIAssistView actionButton child](images/action-button/actionbutton-child-property.png) +![AI AssistView actionButton child](images/action-button/actionbutton-child-property.png) ### onPressed callback @@ -172,7 +172,7 @@ class ActionButtonTooltipExample extends StatelessWidget { {% endhighlight %} {% endtabs %} -![AIAssistView actionButton tooltip](images/action-button/actionbutton-tooltip-property.gif) +![AI AssistView actionButton tooltip](images/action-button/actionbutton-tooltip-property.gif) ### Colors @@ -297,7 +297,7 @@ class ActionButtonMouseCursorExample extends StatelessWidget { {% endhighlight %} {% endtabs %} -![AIAssistView actionButton mousecursor](images/action-button/actionbutton-mousecursor-property.gif) +![AI AssistView actionButton mousecursor](images/action-button/actionbutton-mousecursor-property.gif) ### Shape @@ -340,7 +340,7 @@ class ActionButtonShapeExample extends StatelessWidget { {% endhighlight %} {% endtabs %} -![AIAssistView actionButton shape](images/action-button/actionbutton-shape-property.png) +![AI AssistView actionButton shape](images/action-button/actionbutton-shape-property.png) ### Margin diff --git a/Flutter/ai-assistview/composer.md b/Flutter/ai-assistview/composer.md index 4d5a7c453..c8e0b0da9 100644 --- a/Flutter/ai-assistview/composer.md +++ b/Flutter/ai-assistview/composer.md @@ -52,7 +52,7 @@ class MinMaxLinesExample extends StatelessWidget { {% endhighlight %} {% endtabs %} -![AIAssistView composer support](images/composer/composer-minLines-maxLines.gif) +![AI AssistView composer support](images/composer/composer-minLines-maxLines.gif) ### Decoration @@ -110,7 +110,7 @@ class BorderExample extends StatelessWidget { {% endhighlight %} {% endtabs %} -![AIAssistView composer border](images/composer/composer-border.png) +![AI AssistView composer border](images/composer/composer-border.png) #### Content padding @@ -146,7 +146,7 @@ class ContentPaddingExample extends StatelessWidget { {% endhighlight %} {% endtabs %} -![AIAssistView composer contentPadding](images/composer/composer-contentPadding.png) +![AI AssistView composer contentPadding](images/composer/composer-contentPadding.png) #### Hint text @@ -181,7 +181,7 @@ class HintTextExample extends StatelessWidget { {% endhighlight %} {% endtabs %} -![AIAssistView composer hintText](images/composer/composer-hintText.png) +![AI AssistView composer hintText](images/composer/composer-hintText.png) #### Hint text style @@ -221,7 +221,7 @@ class HintTextStyleExample extends StatelessWidget { {% endhighlight %} {% endtabs %} -![AIAssistView composer hintTextStyle](images/composer/composer-hintTextStyle.png) +![AI AssistView composer hintTextStyle](images/composer/composer-hintTextStyle.png) #### Prefix and suffix icons @@ -263,7 +263,7 @@ class PrefixSuffixIconExample extends StatelessWidget { {% endhighlight %} {% endtabs %} -![AIAssistView composer icon](images/composer/composer-prefix-suffix-icon.png) +![AI AssistView composer icon](images/composer/composer-prefix-suffix-icon.png) ### Margin @@ -298,7 +298,7 @@ class ComposerMarginExample extends StatelessWidget { {% endhighlight %} {% endtabs %} -![AIAssistView composer margin](images/composer/composer-padding.png) +![AI AssistView composer margin](images/composer/composer-padding.png) ### Text style @@ -335,7 +335,7 @@ class TextStyleExample extends StatelessWidget { {% endhighlight %} {% endtabs %} -![AIAssistview composer text style](images/composer/composer-textStyle.gif) +![AI AssistView composer text style](images/composer/composer-textStyle.gif) ## Builder @@ -451,6 +451,6 @@ class _ComposerBuilderExampleState extends State { {% endhighlight %} {% endtabs %} -![AIAssistView composer builder support](images/composer/composer-builder-support.png) +![AI AssistView composer builder support](images/composer/composer-builder-support.png) >You can refer to our [Flutter AI AssistView](https://www.syncfusion.com/flutter-widgets/flutter-aiassistview) feature tour page for its groundbreaking feature representations. You can also explore our [Flutter AI AssistView example](https://flutter.syncfusion.com/#/ai-assist-view/getting-started) which demonstrates interaction between users and AI services in a fully customizable layout and shows how to easily configure the AI AssistView with built-in support for creating stunning visual effects. diff --git a/Flutter/ai-assistview/how-to/custom-widget-on-flutterflow.md b/Flutter/ai-assistview/how-to/custom-widget-on-flutterflow.md index b522bd699..a38f138ba 100644 --- a/Flutter/ai-assistview/how-to/custom-widget-on-flutterflow.md +++ b/Flutter/ai-assistview/how-to/custom-widget-on-flutterflow.md @@ -28,7 +28,7 @@ Navigate to the [FlutterFlow dashboard](https://app.flutterflow.io/dashboard) an ![Custom Widget](how-to-section-images/custom-widget.png) -### Add AIAssistView widget as a dependency +### Add AI AssistView widget as a dependency 1. Click on `+ Add Dependency`, and a text editor will appear. 2. Navigate to [Syncfusion® Flutter Chat](https://pub.dev/packages/syncfusion_flutter_chat) in [pub.dev](https://pub.dev/) and copy the dependency name and version using the `Copy to Clipboard` option. diff --git a/Flutter/ai-assistview/placeholder.md b/Flutter/ai-assistview/placeholder.md index 15d67a722..76228be0a 100644 --- a/Flutter/ai-assistview/placeholder.md +++ b/Flutter/ai-assistview/placeholder.md @@ -145,7 +145,7 @@ class _HideOnMessageExampleState extends State { {% endhighlight %} {% endtabs %} -![AIAssistView placeholder support](images/placeholder/placeholder-hideOnMessage.gif) +![AI AssistView placeholder support](images/placeholder/placeholder-hideOnMessage.gif) ## Scroll with message @@ -164,6 +164,6 @@ The placeholder can [`scroll`](https://pub.dev/documentation/syncfusion_flutter_ {% endhighlight %} {% endtabs %} -![AIAssistView placeholder support](images/placeholder/placeholder-scrollWithMessage.gif) +![AI AssistView placeholder support](images/placeholder/placeholder-scrollWithMessage.gif) >You can refer to our [Flutter AI AssistView](https://www.syncfusion.com/flutter-widgets/flutter-aiassistview) feature tour page for its groundbreaking feature representations. You can also explore our [Flutter AI AssistView example](https://flutter.syncfusion.com/#/ai-assist-view/getting-started) which demonstrates interaction between users and AI services in a fully customizable layout and shows how to easily configure the AI AssistView with built-in support for creating stunning visual effects. \ No newline at end of file diff --git a/Flutter/barcode/accessibility.md b/Flutter/barcode/accessibility.md index 7124adb05..b7737b1bf 100644 --- a/Flutter/barcode/accessibility.md +++ b/Flutter/barcode/accessibility.md @@ -1,6 +1,6 @@ --- layout: post -title: Accessibility in Flutter Barcodes | Syncfusion® +title: Accessibility in Flutter Barcode Generator | Syncfusion® description: Learn about accessibility support in Syncfusion® Flutter Barcodes (SfBarcodeGenerator), including screen readers, keyboard navigation, and more. platform: flutter @@ -8,7 +8,7 @@ control: SfBarcodeGenerator documentation: ug --- -# Accessibility in Flutter Barcodes (SfBarcodeGenerator) +# Accessibility in Flutter Barcode Generator (SfBarcodeGenerator) ## Sufficient contrast @@ -20,9 +20,9 @@ You can customize colors for the following elements: ## Large fonts -The [`SfBarcodeGenerator`](https://pub.dev/documentation/syncfusion_flutter_barcodes/latest/barcodes/SfBarcodeGenerator-class.html) automatically adjusts font size based on device settings and scales according to the [`MediaQueryData.textScaleFactor`](https://api.flutter.dev/flutter/widgets/MediaQueryData/textScaleFactor.html). It also allows you to change the font size of all text elements in the barcode generator. -* [Input value of barcode](https://help.syncfusion.com/flutter/barcode/barcode-customization#text-customization) +The [`SfBarcodeGenerator`](https://pub.dev/documentation/syncfusion_flutter_barcodes/latest/barcodes/SfBarcodeGenerator-class.html) automatically adjusts font size based on device settings and scales according to the [`MediaQueryData.textScaleFactor`](https://api.flutter.dev/flutter/widgets/MediaQueryData/textScaleFactor.html). It also allows you to change the font size of all text elements in Flutter Barcode Generator. +* [Input value of Barcode Generator](https://help.syncfusion.com/flutter/barcode/barcode-customization#text-customization) ## Screen reader support -The [`SfBarcodeGenerator`](https://pub.dev/documentation/syncfusion_flutter_barcodes/latest/barcodes/SfBarcodeGenerator-class.html) supports Flutter's built-in [`Semantics`](https://api.flutter.dev/flutter/widgets/Semantics-class.html) framework, which provides voice-over and TalkBack screen reader support. You can wrap the barcode generator in a [`Semantics`](https://api.flutter.dev/flutter/widgets/Semantics-class.html) widget and provide a descriptive label using the label property so that screen readers can announce the barcode's input value. Alternatively, the [`Semantics`](https://api.flutter.dev/flutter/widgets/Semantics-class.html) widget can be placed on the parent container holding the [`SfBarcodeGenerator`](https://pub.dev/documentation/syncfusion_flutter_barcodes/latest/barcodes/SfBarcodeGenerator-class.html). This improves accessibility for visually impaired users, especially since barcodes are inherently visual elements that cannot be interpreted by screen readers without a meaningful label. \ No newline at end of file +The [`SfBarcodeGenerator`](https://pub.dev/documentation/syncfusion_flutter_barcodes/latest/barcodes/SfBarcodeGenerator-class.html) supports Flutter's built-in [`Semantics`](https://api.flutter.dev/flutter/widgets/Semantics-class.html) framework, which provides voice-over and TalkBack screen reader support. You can wrap the Flutter Barcode Generator in a [`Semantics`](https://api.flutter.dev/flutter/widgets/Semantics-class.html) widget and provide a descriptive label using the label property so that screen readers can announce the barcode's input value. Alternatively, the [`Semantics`](https://api.flutter.dev/flutter/widgets/Semantics-class.html) widget can be placed on the parent container holding the [`SfBarcodeGenerator`](https://pub.dev/documentation/syncfusion_flutter_barcodes/latest/barcodes/SfBarcodeGenerator-class.html). This improves accessibility for visually impaired users, especially since barcodes are inherently visual elements that cannot be interpreted by screen readers without a meaningful label. \ No newline at end of file diff --git a/Flutter/barcode/barcode-customization.md b/Flutter/barcode/barcode-customization.md index 1611ffb94..6033b924d 100644 --- a/Flutter/barcode/barcode-customization.md +++ b/Flutter/barcode/barcode-customization.md @@ -1,21 +1,21 @@ --- layout: post -title: Customization in Flutter Barcodes | Syncfusion® +title: Customization in Flutter Barcode Generator | Syncfusion® description: Learn about customization options in Syncfusion® Flutter Barcodes (SfBarcodeGenerator), including appearance, sizing, colors, and styling. platform: flutter control: SfBarcodeGenerator documentation: ug --- -# Customization in Flutter Barcodes (SfBarcodeGenerator) +# Customization in Flutter Barcode Generator (SfBarcodeGenerator) -To get started with the Flutter Barcode Generator and set up the package, refer to the [Getting Started with Flutter Barcodes](https://help.syncfusion.com/flutter/barcode/getting-started) documentation. +To get started with the Flutter Barcode Generator and set up the package, refer to the [Getting Started with Flutter Barcode Generator](https://help.syncfusion.com/flutter/barcode/getting-started) documentation. ## Text customization **Displaying input value** -To display the input value of the barcode, enable its [`showValue`](https://pub.dev/documentation/syncfusion_flutter_barcodes/latest/barcodes/SfBarcodeGenerator/showValue.html) property. By default, it is set to false. +To display the input value of the Barcode Generator, enable its [`showValue`](https://pub.dev/documentation/syncfusion_flutter_barcodes/latest/barcodes/SfBarcodeGenerator/showValue.html) property. By default, it is set to false. {% tabs %} @@ -52,7 +52,7 @@ To display the input value of the barcode, enable its [`showValue`](https://pub. **Text style customization** -The text style can be customized using the [`textStyle`](https://pub.dev/documentation/syncfusion_flutter_barcodes/latest/barcodes/SfBarcodeGenerator/textStyle.html) property of the barcode generator. +The text style can be customized using the [`textStyle`](https://pub.dev/documentation/syncfusion_flutter_barcodes/latest/barcodes/SfBarcodeGenerator/textStyle.html) property of the Flutter Barcode Generator. {% tabs %} @@ -99,7 +99,7 @@ The text style can be customized using the [`textStyle`](https://pub.dev/documen **Text spacing** -Control the space between the text and the barcode with the [`textSpacing`](https://pub.dev/documentation/syncfusion_flutter_barcodes/latest/barcodes/SfBarcodeGenerator/textSpacing.html) property of barcode generator. By default, it is set to 2. +Control the space between the text and the barcode with the [`textSpacing`](https://pub.dev/documentation/syncfusion_flutter_barcodes/latest/barcodes/SfBarcodeGenerator/textSpacing.html) property of the Flutter Barcode Generator. By default, it is set to 2. {% tabs %} @@ -140,7 +140,7 @@ Control the space between the text and the barcode with the [`textSpacing`](http **Horizontal text alignment** -The horizontal text alignment can be managed with the [`textAlign`](https://pub.dev/documentation/syncfusion_flutter_barcodes/latest/barcodes/SfBarcodeGenerator/textAlign.html) property of barcode generator. Position the displayed text at the [`start`](https://api.flutter.dev/flutter/dart-ui/TextAlign.html#start), [`center`](https://api.flutter.dev/flutter/dart-ui/TextAlign.html#center) or [`end`](https://api.flutter.dev/flutter/dart-ui/TextAlign.html#end) of the control. The default value of [`textAlign`](https://pub.dev/documentation/syncfusion_flutter_barcodes/latest/barcodes/SfBarcodeGenerator/textAlign.html) property is center. +The horizontal text alignment can be managed with the [`textAlign`](https://pub.dev/documentation/syncfusion_flutter_barcodes/latest/barcodes/SfBarcodeGenerator/textAlign.html) property of the Flutter Barcode Generator. Position the displayed text at the [`start`](https://api.flutter.dev/flutter/dart-ui/TextAlign.html#start), [`center`](https://api.flutter.dev/flutter/dart-ui/TextAlign.html#center) or [`end`](https://api.flutter.dev/flutter/dart-ui/TextAlign.html#end) of the control. The default value of [`textAlign`](https://pub.dev/documentation/syncfusion_flutter_barcodes/latest/barcodes/SfBarcodeGenerator/textAlign.html) property is center. {% tabs %} @@ -351,7 +351,7 @@ The following code snippet shows the two-dimensional barcode without the [`modul **Bar color customization** -Customize the barcode's bar color using the [`barColor`](https://pub.dev/documentation/syncfusion_flutter_barcodes/latest/barcodes/SfBarcodeGenerator/barColor.html) property as shown in the following code snippet. +Customize the bar color of the Barcode Generator using the [`barColor`](https://pub.dev/documentation/syncfusion_flutter_barcodes/latest/barcodes/SfBarcodeGenerator/barColor.html) property as shown in the following code snippet. {% tabs %} @@ -391,7 +391,7 @@ Customize the barcode's bar color using the [`barColor`](https://pub.dev/documen **Background color customization** -You can customize the barcode's background color with the [`backgroundColor`](https://pub.dev/documentation/syncfusion_flutter_barcodes/latest/barcodes/SfBarcodeGenerator/backgroundColor.html) property of barcode generator as shown in the following code snippet. +You can customize the background color of the Barcode Generator using the [`backgroundColor`](https://pub.dev/documentation/syncfusion_flutter_barcodes/latest/barcodes/SfBarcodeGenerator/backgroundColor.html) property, as shown in the following code snippet. {% tabs %} diff --git a/Flutter/barcode/getting-started.md b/Flutter/barcode/getting-started.md index 271220679..353528f64 100644 --- a/Flutter/barcode/getting-started.md +++ b/Flutter/barcode/getting-started.md @@ -1,24 +1,24 @@ --- layout: post -title: Getting Started with Flutter Barcodes | Syncfusion® +title: Getting Started with Flutter Barcode Generator | Syncfusion® description: Learn how to get started with the Syncfusion® Flutter Barcodes (SfBarcodeGenerator). Explore setup, barcode generation, and customization options. platform: flutter control: SfBarcodeGenerator documentation: ug --- -# Getting Started with Flutter Barcodes (SfBarcodeGenerator) +# Getting Started with Flutter Barcode Generator (SfBarcodeGenerator) -This section explains the steps required to add the barcode and set its symbology. This section covers only basic features needed to get started with Syncfusion® barcode generator widget. +This section explains the steps required to add the barcode and set its symbology. This section covers only basic features needed to get started with Syncfusion® Flutter Barcode Generator widget. -## Add Flutter Barcode to an application +## Add Flutter Barcode Generator to an application Create a simple project using the instructions given in the [Getting Started with your first Flutter app](https://docs.flutter.dev/get-started/test-drive#choose-your-ide) documentation. **Add dependency** -Add the Syncfusion® Flutter Barcode dependency to your pubspec.yaml file. +Add the Syncfusion® Flutter Barcodes dependency to your pubspec.yaml file. {% tabs %} @@ -99,11 +99,11 @@ Add the Barcode Generator widget as a child of any widget. Here, the widget is a N> The default symbology of SfBarcodeGenerator is [`Code128`](https://pub.dev/documentation/syncfusion_flutter_barcodes/latest/barcodes/Code128-class.html). -![Initialize barcode generator](images/getting-started/getting_started1.jpg) +![Initialize Barcode Generator](images/getting-started/getting_started1.jpg) ## Initialize QR Code symbology -You can set the required symbology type to the barcode generator based on input value by initializing the [`symbology`](https://pub.dev/documentation/syncfusion_flutter_barcodes/latest/barcodes/Symbology-class.html) property. In the following code snippet, the QR code is set as the barcode symbology. +You can set the required symbology type to the Flutter Barcode Generator based on input value by initializing the [`symbology`](https://pub.dev/documentation/syncfusion_flutter_barcodes/latest/barcodes/Symbology-class.html) property. In the following code snippet, the QR code is set as the barcode symbology. {% tabs %} @@ -144,7 +144,7 @@ You can set the required symbology type to the barcode generator based on input ## Display input value -The provided input value can be displayed below the barcode by enabling the [`showValue`](https://pub.dev/documentation/syncfusion_flutter_barcodes/latest/barcodes/SfBarcodeGenerator/showValue.html) property of barcode as shown in the following code snippet. +The provided input value can be displayed below the barcode by enabling the [`showValue`](https://pub.dev/documentation/syncfusion_flutter_barcodes/latest/barcodes/SfBarcodeGenerator/showValue.html) property of Barcode Generator as shown in the following code snippet. {% tabs %} diff --git a/Flutter/barcode/how-to/custom-widget-on-flutterflow.md b/Flutter/barcode/how-to/custom-widget-on-flutterflow.md index d9b3076de..84d363435 100644 --- a/Flutter/barcode/how-to/custom-widget-on-flutterflow.md +++ b/Flutter/barcode/how-to/custom-widget-on-flutterflow.md @@ -1,19 +1,19 @@ --- layout: post -title: How to Add Barcodes in FlutterFlow | Syncfusion® +title: How to Add Barcode Generator in FlutterFlow | Syncfusion® description: Learn how to add and use Syncfusion® Flutter Barcodes (SfBarcodeGenerator) in FlutterFlow, including setup, integration, and configuration. platform: flutter control: SfBarcodeGenerator documentation: ug --- -# How to Add Barcodes in FlutterFlow (SfBarcodeGenerator) +# How to Add Barcode Generator in FlutterFlow (SfBarcodeGenerator) ## Overview [FlutterFlow](https://app.flutterflow.io/dashboard) enables you to create native applications using its graphical interface, reducing the need to write extensive amounts of code. Additionally, it offers the capability to include custom widgets that are not included in the default [FlutterFlow](https://app.flutterflow.io/dashboard) widget collection. This article explains how to incorporate our `SfBarcodeGenerator` widget as a custom widget in [FlutterFlow](https://app.flutterflow.io/dashboard). -To get started with the Flutter Barcode Generator and set up the package, refer to the [Getting Started with Flutter Barcodes](https://help.syncfusion.com/flutter/barcode/getting-started) documentation. +To get started with the Flutter Barcode Generator and set up the package, refer to the [Getting Started with Flutter Barcode Generator](https://help.syncfusion.com/flutter/barcode/getting-started) documentation. ### Create a new project @@ -30,7 +30,7 @@ Navigate to the [FlutterFlow dashboard](https://app.flutterflow.io/dashboard) an ![Custom Widget](how-to-section-images/custom-widget.png) -### Add the Barcodes widget as a dependency +### Add the Barcode Generator widget as a dependency 1. Click on `+ Add Dependency`; a text editor will appear. 2. Navigate to [Syncfusion® Flutter Barcodes](https://pub.dev/packages/syncfusion_flutter_barcodes) in [pub.dev](https://pub.dev/) and copy the dependency name and version using the `Copy to Clipboard` option. diff --git a/Flutter/barcode/one-dimensional.md b/Flutter/barcode/one-dimensional.md index 56aacad0b..7a6efd6cd 100644 --- a/Flutter/barcode/one-dimensional.md +++ b/Flutter/barcode/one-dimensional.md @@ -1,17 +1,17 @@ --- layout: post -title: One-Dimensional Symbology in Flutter Barcodes | Syncfusion® +title: One-Dimensional Symbology in Flutter Barcode Generator | Syncfusion® description: Learn about one-dimensional symbology support in Syncfusion® Flutter Barcodes (SfBarcodeGenerator), including Code128, EAN, UPC, Codabar, and Code39. platform: flutter control: SfBarcodeGenerator documentation: ug --- -# One-Dimensional Symbology in Flutter Barcodes (SfBarcodeGenerator) +# One-Dimensional Symbology in Flutter Barcode (SfBarcodeGenerator) -To get started with the Flutter Barcode Generator and set up the package, refer to the [Getting Started with Flutter Barcodes](https://help.syncfusion.com/flutter/barcode/getting-started) documentation. +To get started with the Flutter Barcode Generator and set up the package, refer to the [Getting Started with Flutter Barcode Generator](https://help.syncfusion.com/flutter/barcode/getting-started) documentation. -One-dimensional barcodes represent data by varying the widths and spacings of parallel lines. These barcode types are also known as linear barcodes. The Syncfusion® flutter barcode generator supports the following one-dimensional barcode types: +One-dimensional barcodes represent data by varying the widths and spacings of parallel lines. These barcode types are also known as linear barcodes. The Syncfusion® Flutter Barcode Generator supports the following one-dimensional barcode types: * [`Codabar`](https://pub.dev/documentation/syncfusion_flutter_barcodes/latest/barcodes/Codabar-class.html) * [`Code39`](https://pub.dev/documentation/syncfusion_flutter_barcodes/latest/barcodes/Code39-class.html) diff --git a/Flutter/barcode/overview.md b/Flutter/barcode/overview.md index dfa4de689..ab4d23188 100644 --- a/Flutter/barcode/overview.md +++ b/Flutter/barcode/overview.md @@ -11,9 +11,9 @@ documentation: ug The Syncfusion® Flutter Barcode Generator is a data visualization widget designed to generate and display data in a machine-readable format. It offers an efficient way to encode text using supported symbology types. -To get started with the Flutter Barcode Generator, refer to the [Getting Started with Flutter Barcodes](https://help.syncfusion.com/flutter/barcode/getting-started) documentation. +To get started with the Flutter Barcode Generator, refer to the [Getting Started with Flutter Barcode Generator](https://help.syncfusion.com/flutter/barcode/getting-started) documentation. -![Overview flutter barcode](images/getting-started/overview1.jpg) +![Overview Flutter Barcode Generator](images/getting-started/overview1.jpg) ![Overview flutter QR Code](images/getting-started/getting_started3.jpg) @@ -29,4 +29,4 @@ To quickly get started with our Flutter Barcode Generator widget, watch the tuto * **Barcode customization** - Customize the visual appearance of barcodes using the [`backgroundColor`](https://pub.dev/documentation/syncfusion_flutter_barcodes/latest/barcodes/SfBarcodeGenerator/backgroundColor.html) and [`barColor`](https://pub.dev/documentation/syncfusion_flutter_barcodes/latest/barcodes/SfBarcodeGenerator/barColor.html) properties and adjust the size of smallest line or dot of the code using the [`module`](https://pub.dev/documentation/syncfusion_flutter_barcodes/latest/barcodes/Symbology/module.html) property. * **Text customization** - Configure to display the barcode value and customize the position and style of the barcode text. -You can get the barcode sample in the following link: [`Flutter Barcode Examples`](https://github.com/syncfusion/flutter-examples/tree/master/lib/samples/barcodes). \ No newline at end of file +You can get the barcode sample in the following link: [`Flutter Barcode Generator Examples`](https://github.com/syncfusion/flutter-examples/tree/master/lib/samples/barcodes). \ No newline at end of file diff --git a/Flutter/barcode/two-dimensional.md b/Flutter/barcode/two-dimensional.md index fe550d00c..f0ad44349 100644 --- a/Flutter/barcode/two-dimensional.md +++ b/Flutter/barcode/two-dimensional.md @@ -1,17 +1,17 @@ --- layout: post -title: Two-Dimensional Symbology in Flutter Barcodes | Syncfusion® +title: Two-Dimensional Symbology in Flutter Barcode Generator | Syncfusion® description: Learn about two-dimensional symbology support in Syncfusion® Flutter Barcodes (SfBarcodeGenerator), including QR Code, Data Matrix, and PDF417. platform: flutter control: SfBarcodeGenerator documentation: ug --- -# Two-Dimensional Symbology in Flutter Barcodes (SfBarcodeGenerator) +# Two-Dimensional Symbology in Flutter Barcode (SfBarcodeGenerator) -To get started with the Flutter Barcode Generator and set up the package, refer to the [Getting Started with Flutter Barcodes](https://help.syncfusion.com/flutter/barcode/getting-started) documentation. +To get started with the Flutter Barcode Generator and set up the package, refer to the [Getting Started with Flutter Barcode Generator](https://help.syncfusion.com/flutter/barcode/getting-started) documentation. -Two-dimensional barcode is a way to represent information by using the two-dimensional approach. It is similar to one-dimensional barcode, but can represent more data per unit area. The barcode generator control supports the following two-dimensional symbology: + Two-dimensional barcode is a way to represent information by using the two-dimensional approach. It is similar to one-dimensional barcode, but can represent more data per unit area. The Flutter Barcode Generator widget supports the following two-dimensional symbology: * [`QR Code`](https://pub.dev/documentation/syncfusion_flutter_barcodes/latest/barcodes/QRCode-class.html) * [`Data Matrix`](https://pub.dev/documentation/syncfusion_flutter_barcodes/latest/barcodes/DataMatrix-class.html) @@ -21,7 +21,7 @@ Two-dimensional barcode is a way to represent information by using the two-dimen A [`QR Code`](https://pub.dev/documentation/syncfusion_flutter_barcodes/latest/barcodes/QRCode-class.html) is a two-dimensional barcode that consists of a grid of dark and light dots or blocks that form a square. The data encoded in the barcode can be numeric, alphanumeric, or Shift JIS characters. * The QR Code uses version from 1 to 40. Version 1 measures 21 modules x 21 modules, Version 2 measures 25 modules x 25 modules, and so on. The number of modules increases in steps of 4 modules per side up to Version 40 that measures 177 modules x 177 modules. -* Each version has its own capacity. By default, the barcode control automatically sets the version according to the length of the input text. +* Each version has its own capacity. By default, the Barcode Generator widget automatically sets the version according to the length of the input text. * The QR Barcodes are designed for industrial uses and also commonly used in consumer advertising. {% tabs %} diff --git a/Flutter/calendar/accessibility.md b/Flutter/calendar/accessibility.md index cae33c7eb..a80e63b41 100644 --- a/Flutter/calendar/accessibility.md +++ b/Flutter/calendar/accessibility.md @@ -70,7 +70,7 @@ The following APIs allow you to customize the colors of the following elements. ## Large fonts -The [SfCalendar](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar-class.html) font size can be adjusted automatically based on device settings and the font size scaled based on the `MediaQueryData.textScaler`. And also it allows to change the font size of all UI elements in the calendar. +The [SfCalendar](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar-class.html) font size can be adjusted automatically based on device settings and the font size scaled based on the `MediaQueryData.textScaler`. And also it allows to change the font size of all UI elements in the Flutter Calendar. * [appointmentTextStyle](https://help.syncfusion.com/flutter/calendar/appointments#appearance-customization) * [timeTextStyle](https://help.syncfusion.com/flutter/calendar/timeslot-views#time-text-appearance) * [dateTextStyle](https://help.syncfusion.com/flutter/calendar/schedule-view#day-header-customization) @@ -90,7 +90,7 @@ The following keyboard interactions are supported by the [SfCalendar](https://pu | Left arrow | Moves selection to the same time slot on the previous day | | Tab | Focuses the next clickable element, except appointments and cells | | Shift + tab | Focuses the previous clickable element, except appointment and cells | -| Alt + number | Calendar view changes in the order of day, week, work week, month, timeline and schedule. Also view change will be restricted if it is not mentioned in the allowed views property of the calendar | +| Alt + number | Calendar view changes in the order of day, week, work week, month, timeline and schedule. Also view change will be restricted if it is not mentioned in the allowed views property of the Flutter Event Calendar | | Ctrl + left arrow | To navigate to the previous view | | Ctrl + right arrow| To navigate to the next view | | Page up/down | Vertically scrolls through the timeslot views | diff --git a/Flutter/calendar/appointments.md b/Flutter/calendar/appointments.md index 680107bb5..99642e528 100644 --- a/Flutter/calendar/appointments.md +++ b/Flutter/calendar/appointments.md @@ -9,7 +9,7 @@ documentation: ug # Flutter Event Calendar Appointments (SfCalendar) -SfCalendar widget has a built-in capability to handle the appointment arrangement internally based on the [CalendarDataSource](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarDataSource-class.html). [Appointment](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/Appointment-class.html) is a class, which holds the details about the appointment to be rendered in calendar. + SfCalendar widget has a built-in capability to handle the appointment arrangement internally based on the [CalendarDataSource](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarDataSource-class.html). [Appointment](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/Appointment-class.html) is a class, which holds the details about the appointment to be rendered in Flutter Event Calendar. {% tabs %} {% highlight dart hl_lines="16 23 24 25 26 27 28 29 30 31 32 34 35 37 38 39 40 41" %} @@ -64,7 +64,7 @@ class _AppointmentDataSource extends CalendarDataSource { ## Calendar data source and mapping -[CalendarDataSource](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarDataSource-class.html) is an abstract class used to set the appointment datasource for calendar and has properties to map the custom appointments to the calendar `Appointment`. Calendar supports full data binding to any type of List source. Specify the corresponding property override method to map the properties in the underlying data source to the calendar appointments in [CalendarDataSource](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarDataSource-class.html). +[CalendarDataSource](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarDataSource-class.html) is an abstract class used to set the appointment datasource for calendar and has properties to map the custom appointments to the calendar `Appointment`. Flutter Event Calendar supports full data binding to any type of List source. Specify the corresponding property override method to map the properties in the underlying data source to the calendar appointments in [CalendarDataSource](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarDataSource-class.html). | Property Name | Description | |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------| @@ -329,7 +329,7 @@ class Meeting { {% endhighlight %} {% endtabs %} -You can map those properties of `Meeting` class with our calendar widget by using the [CalendarDataSource](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarDataSource-class.html) override methods properties. +You can map those properties of `Meeting` class with our Flutter Event Calendar widget by using the [CalendarDataSource](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarDataSource-class.html) override methods properties. {% tabs %} {% highlight dart hl_lines="3 4 6 7 8 9 11 12 13 14 16 17 18 19 21 22 23 24 26 27 28 29 31 32 33 34 36 37 38 39 40" %} @@ -603,7 +603,7 @@ class _AppointmentDataSource extends CalendarDataSource { #### Recurrence appointments on last day of month -To create recurring appointments on the last day of the month, use BYMONTHDAY=-1 in the flutter event calendar. +To create recurring appointments on the last day of the month, use BYMONTHDAY=-1 in the Flutter Event Calendar. {% tabs %} {% highlight dart hl_lines="20" %} @@ -668,7 +668,7 @@ class Meeting { {% endhighlight %} {% endtabs %} -You can map those properties of `Meeting` class with our calendar widget by using [CalendarDataSource](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarDataSource-class.html). +You can map those properties of `Meeting` class with our Flutter Event Calendar widget by using [CalendarDataSource](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarDataSource-class.html). {% tabs %} {% highlight dart hl_lines="31 32 33 34" %} @@ -803,7 +803,7 @@ class Meeting { #### How to get the Recurrence editor field values from RRULE? -You can get the Recurrence properties form `RRULE` by using the [parseRRule](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/parseRRule.html) method from calendar. + You can get the Recurrence properties form `RRULE` by using the [parseRRule](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/parseRRule.html) method from the Flutter Event Calendar. {% tabs %} {% highlight dart hl_lines="2 3" %} @@ -850,7 +850,7 @@ You can delete any occurrence appointment, which exception from the recurrence p #### Recurrence exception appointment -You can also change any occurrence appointment, which exception from recurrence pattern appointment by adding the recurrence exception appointment to the calendar [dataSource](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/dataSource.html). +You can also change any occurrence appointment, which exception from recurrence pattern appointment by adding the recurrence exception appointment to the [dataSource](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/dataSource.html) of the Flutter Event Calendar. #### Create recurrence exceptions for calendar appointment @@ -912,7 +912,7 @@ You can add the recurrence exception appointments and recurrence exception dates #### Delete occurrence from custom recurrence pattern appointment or adding exception dates to custom recurrence pattern appointment -You can delete any occurrence, which is an exception from the recurrence pattern appointment by using the [getRecurrenceExceptionDates](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarDataSource/getRecurrenceExceptionDates.html) override method of [CalendarDataSource](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarDataSource-class.html), which is used to map the exception dates to the calendar recurrence appointment. The deleted occurrence date will be considered as recurrence exception dates. +You can delete any occurrence, which is an exception from the recurrence pattern appointment by using the [getRecurrenceExceptionDates](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarDataSource/getRecurrenceExceptionDates.html) override method of [CalendarDataSource](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarDataSource-class.html), which is used to map the exception dates to the recurrence appointment of the Flutter Event Calendar. The deleted occurrence date will be considered as recurrence exception dates. To add the exception dates in the recurrence series of custom appointment, add the [recurrenceExceptionDates](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/Appointment/recurrenceExceptionDates.html) property to custom class Meeting. {% tabs %} @@ -1065,7 +1065,7 @@ AppointmentDataSource _getDataSource() { {% endhighlight %} {% endtabs %} -![Recurrence Series in Flutter Calendar](images/appointments/flutter-calendar-recurrence-series.png) +![Recurrence Series in Flutter Event Calendar](images/appointments/flutter-calendar-recurrence-series.png) >**NOTE** * The RecurrenceId of the changed occurrence should hold the exact recurrence pattern appointment Id. @@ -1074,7 +1074,7 @@ AppointmentDataSource _getDataSource() { ## Appearance customization -The Calendar appointment text style can be customized by using the [appointmentTextStyle](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/appointmentTextStyle.html) property of the calendar. +The appointment text style of the Flutter Event Calendar can be customized by using the [appointmentTextStyle](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/appointmentTextStyle.html) property . {% tabs %} {% highlight dart hl_lines="9 10 11 12 13" %} @@ -1104,7 +1104,7 @@ Widget build(BuildContext context) { ![Appearance customization](images/appointments/appearance-customization.png) ## Appointment time format -You can customize the displaying time format in the appointment widget in the month agenda view and schedule view of calendar by specifying the [appointmentTimeTextFormat](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/appointmentTimeTextFormat.html) property of the SfCalendar. +You can customize the displaying time format in the appointment widget in the month agenda view and schedule view of the Flutter Event Calendar by specifying the [appointmentTimeTextFormat](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/appointmentTimeTextFormat.html) property. {% tabs %} {% highlight dart hl_lines="6" %} @@ -1129,7 +1129,7 @@ You can customize the displaying time format in the appointment widget in the mo ### Get visible appointments -You can get the list of visible appointments by using the [getVisibleAppointments](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarDataSource/getVisibleAppointments.html) method available in the Calendar data source. +You can get the list of visible appointments by using the [getVisibleAppointments](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarDataSource/getVisibleAppointments.html) method available in the CalendarDataSource. {% tabs %} {% highlight dart hl_lines="19 20 21" %} @@ -1240,7 +1240,7 @@ Gets the pattern appointment for the specified occurrence by using the [getPatte ## See also -To know more about how to display more appointments in the Flutter Calendar, you can watch this video. +To know more about how to display more appointments in the Flutter Event Calendar, you can watch this video. diff --git a/Flutter/calendar/builders.md b/Flutter/calendar/builders.md index 7a8fac307..bb82fbfb5 100644 --- a/Flutter/calendar/builders.md +++ b/Flutter/calendar/builders.md @@ -9,14 +9,14 @@ documentation: ug # Flutter Event Calendar Builders (SfCalendar) -The calendar allows you to create a responsive UI with conditions based on a widget's details, to design and create your custom view for the month cells and month header of schedule view in the calendar. +The Flutter Event Calendar allows you to create a responsive UI with conditions based on a widget's details, to design and create your custom view for the month cells and month header of schedule view. -The calendar has two builders to create and assign your custom view: +The Flutter Event Calendar has two builders to create and assign your custom view: * Month cell builder * Schedule view month header builder ## Month cell builder -The [MonthCellBuilder](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/MonthCellBuilder.html) allows you to design your custom view and assign the view to the month cells of the calendar by returning an appropriate widget in the [monthCellBuilder](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/monthCellBuilder.html) of [SfCalendar](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar-class.html). +The [MonthCellBuilder](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/MonthCellBuilder.html) allows you to design your custom view and assign the view to the month cells of the Flutter Event Calendar by returning an appropriate widget in the [monthCellBuilder](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/monthCellBuilder.html) of [SfCalendar](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar-class.html). [MonthCellDetails](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/MonthCellDetails-class.html) - returns the details of the month cell. @@ -81,7 +81,7 @@ class CalendarApp extends StatelessWidget { ## Schedule view month header builder -You can design your custom view and assign this view to the month header of a schedule view in the calendar by returning an appropriate widget using the [scheduleViewMonthHeaderBuilder](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/scheduleViewMonthHeaderBuilder.html) in the [SfCalendar](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar-class.html). +You can design your custom view and assign this view to the month header of a schedule view by returning an appropriate widget using the [scheduleViewMonthHeaderBuilder](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/scheduleViewMonthHeaderBuilder.html) in the [SfCalendar](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar-class.html). [ScheduleViewMonthHeaderDetails](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/ScheduleViewMonthHeaderDetails-class.html) - returns the required details of the schedule view month header. @@ -143,7 +143,7 @@ class CalendarApp extends StatelessWidget { ![Schedule view header builder](images/builder/schedule_view_month_header_builder.png) ## Appointment builder -The [CalendarAppointmentBuilder](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarAppointmentBuilder.html) allows you to design your custom view and assign the view to the appointment UI of the calendar by returning an appropriate widget in the [appointmentBuilder](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/appointmentBuilder.html) of [SfCalendar](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar-class.html). +The [CalendarAppointmentBuilder](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarAppointmentBuilder.html) allows you to design your custom view and assign the view to the appointment UI of the Flutter Event Calendar by returning an appropriate widget in the [appointmentBuilder](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/appointmentBuilder.html) of [SfCalendar](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar-class.html). [CalendarAppointmentDetails](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarAppointmentDetails-class.html): Returns the details of the appointment view. @@ -292,7 +292,7 @@ class _CalendarAppState extends State { ## Time region builder -The [TimeRegionBuilder](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/TimeRegionBuilder.html) allows you to design your custom view and assign the view to the time region view of the calendar by returning an appropriate widget in the [timeRegionBuilder](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/timeRegionBuilder.html) of SfCalendar. +The [TimeRegionBuilder](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/TimeRegionBuilder.html) allows you to design your custom view and assign the view to the time region view of the Flutter Event Calendar by returning an appropriate widget in the [timeRegionBuilder](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/timeRegionBuilder.html). [TimeRegionDetails](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/TimeRegionDetails-class.html): Returns the details of the time region view. @@ -368,7 +368,7 @@ class CalendarApp extends StatelessWidget { ![Time regions builder](images/builder/timeregion-builder.png) ## Resource view header builder -The [ResourceViewHeaderBuilder](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/ResourceViewHeaderBuilder.html) allows you to design the custom view, and assign the view to the resource view header of the calendar by returning an appropriate widget in the [ResourceViewHeaderBuilder](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/ResourceViewHeaderBuilder.html) of the [SfCalendar](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar-class.html). + The [ResourceViewHeaderBuilder](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/ResourceViewHeaderBuilder.html) allows you to design the custom view, and assign the view to the resource view header by returning an appropriate widget in the [ResourceViewHeaderBuilder](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/ResourceViewHeaderBuilder.html) of the [SfCalendar](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar-class.html). [ResourceViewHeaderDetails](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/ResourceViewHeaderDetails-class.html) - returns the required details of the resource view header builder. @@ -421,7 +421,7 @@ class CalendarApp extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Resource View Header Builder in Flutter Calendar](images/builder/flutter-calendar-resource-view-header-builder.png) +![Resource View Header Builder in Flutter Event Calendar](images/builder/flutter-calendar-resource-view-header-builder.png) ## See also diff --git a/Flutter/calendar/callbacks.md b/Flutter/calendar/callbacks.md index 39375a4e7..5ef53a166 100644 --- a/Flutter/calendar/callbacks.md +++ b/Flutter/calendar/callbacks.md @@ -9,11 +9,11 @@ documentation: ug # Flutter Event Calendar Callbacks (SfCalendar) -The calendar supports the [ViewChangedCallback](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/ViewChangedCallback.html) and [CalendarTapCallback](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarTapCallback.html) to interact with the Flutter calendar. +The Flutter Event Calendar supports the [ViewChangedCallback](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/ViewChangedCallback.html) and [CalendarTapCallback](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarTapCallback.html) to handle user interaction. ## View changed callback -The [onViewChanged](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/onViewChanged.html) callback triggers when the current view of calendar changed, that is view swiped to previous/next view, calendar view switched to another calendar view. +The [onViewChanged](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/onViewChanged.html) callback triggers when the current view of Flutter Event Calendar changed, that is view swiped to previous/next view, or when the calendar view is switched to another view. * [visibleDates](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/ViewChangedDetails/visibleDates.html) - returns the current view visible dates collection. @@ -55,7 +55,7 @@ class CalendarApp extends StatelessWidget { ## Calendar tap callback -The [onTap](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/onTap.html) callback triggers whenever the calendar is tapped. +The [onTap](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/onTap.html) callback triggers whenever the Flutter Event Calendar is tapped. * [date](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarTouchDetails/date.html) - returns the selected date. * [appointments](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarTouchDetails/appointments.html) - returns the selected appointments. @@ -99,15 +99,15 @@ class CalendarApp extends StatelessWidget { >**NOTE** * For recurrence appointment, the tap details will always return as `Appointment`, even for the custom business object. -* The [onTap](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/onTap.html) and [onLongPress](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/onLongPress.html) callbacks are not applicable for pop-ups like allowedViews and date picker in the calendar header. +* The [onTap](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/onTap.html) and [onLongPress](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/onLongPress.html) callbacks are not applicable for pop-ups like allowedViews and date picker in the header of the Flutter Event Calendar. -## Calendar details callback +## Flutter Event Calendar details callback -Return calendar details based on the given offset passed through an argument by using the [getCalendarDetailsAtOffset](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarController/getCalendarDetailsAtOffset.html) method. +Return details of the Flutter Event Calendar based on the given offset passed through an argument by using the [getCalendarDetailsAtOffset](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarController/getCalendarDetailsAtOffset.html) method. * [date](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarTouchDetails/date.html) - returns the date based on the given offset. * [appointments](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarTouchDetails/appointments.html) - returns the appointments based on the given offset. -* [targetElement](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarTouchDetails/targetElement.html) - returns the calendar element based on the given offset. +* [targetElement](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarTouchDetails/targetElement.html) - returns the Flutter Event Calendar element based on the given offset. * [resource](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarTouchDetails/resource.html) - returns the resource based on the given offset. {% tabs %} @@ -166,8 +166,8 @@ The long-pressed date, appointments, and element details when the long-press act * [date](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarTouchDetails/date.html) - returns the long-pressed date. * [appointments](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarTouchDetails/appointments.html) - returns the long-pressed appointments. -* [targetElement](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarTouchDetails/targetElement.html) - returns the long-pressed calendar element. -* [resource](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarTouchDetails/resource.html) - returns the long-pressed calendar resource. +* [targetElement](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarTouchDetails/targetElement.html) - returns the long-pressed element in the Flutter Event Calendar. +* [resource](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarTouchDetails/resource.html) - returns the long-pressed resource in the Flutter Event Calendar. {% tabs %} {% highlight dart hl_lines="18 19 20 21 22" %} diff --git a/Flutter/calendar/date-navigations.md b/Flutter/calendar/date-navigations.md index e7dc62d5a..3fd2a0f2d 100644 --- a/Flutter/calendar/date-navigations.md +++ b/Flutter/calendar/date-navigations.md @@ -76,7 +76,7 @@ class CalendarApp extends StatelessWidget { {% endhighlight %} {% endtabs %} -![MinMaxDate Calendar](images/date-navigation/minmaxdate.png) +![MinMaxDate Flutter Event Calendar](images/date-navigation/minmaxdate.png) ![minDate and maxDate](images/date-navigation/min-maxDate.png) @@ -85,7 +85,7 @@ class CalendarApp extends StatelessWidget { ## Programmatic date navigation -You can programmatically navigate dates in calendar widget by using the [displayDate](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarController/displayDate.html) property of [CalendarController](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarController-class.html). +You can programmatically navigate dates in the Flutter Event Calendar widget by using the [displayDate](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarController/displayDate.html) property of [CalendarController](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarController-class.html). {% tabs %} {% highlight dart hl_lines="3 12 22" %} @@ -130,7 +130,7 @@ class _CalendarAppState extends State { {% endtabs %} ## Programmatic date selection -You can programmatically select the dates in calendar widget by [selectedDate](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarController/selectedDate.html) property of [CalendarController](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarController-class.html). +You can programmatically select the dates in the Flutter Event Calendar widget by [selectedDate](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarController/selectedDate.html) property of [CalendarController](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarController-class.html). {% tabs %} {% highlight dart hl_lines="3 12 22" %} @@ -277,7 +277,7 @@ class _CalendarAppState extends State { {% endtabs %} ## Show date picker -You can enable the date picker for the calendar by using the [showDatePickerButton](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/showDatePickerButton.html) property in the calendar, which displays the date picker in the header view. It allows you to quickly navigate to the different calendar views. +You can enable the date picker for the Flutter Event Calendar by using the [showDatePickerButton](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/showDatePickerButton.html) property, which displays the date picker in the header view. It allows you to quickly navigate to the different calendar views. {% tabs %} {% highlight dart hl_lines="15" %} @@ -316,7 +316,7 @@ To know more about how to customize the Date Picker's appearance in the Flutter ## Show today button -You can enable the today button by using the [showTodayButton](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/showTodayButton.html) property in the calendar, which displays the today button in the header view. It allows you to quickly navigate from the current view to the today's view. +You can enable the today button by using the [showTodayButton](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/showTodayButton.html) property in the Flutter Event Calendar, which displays the today button in the header view. It allows you to quickly navigate from the current view to the today's view. {% tabs %} {% highlight dart hl_lines="15" %} @@ -348,7 +348,7 @@ class CalendarApp extends StatelessWidget { {% endtabs %} ## Allow view navigation -You can quickly navigate to the day view by a tap on the month cell and view header of the calendar views by using the [allowViewNavigation](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/allowViewNavigation.html) property of the calendar. +You can quickly navigate to the day view by a tap on the month cell and view header of the calendar views by using the [allowViewNavigation](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/allowViewNavigation.html) property of the Flutter Event Calendar. {% tabs %} @@ -383,7 +383,7 @@ class CalendarApp extends StatelessWidget { ![Allow view navigation](images/date-navigation/allow_view_navigation.gif) ## Allowed views -You can quickly navigate to the different calendar views by using the [allowedViews](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/allowedViews.html) property in the [SfCalendar](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar-class.html). The views set to this property will display as a view button in the calendar header view. This UI will be responsive as showing more icons in the mobile view and will be updated based on the browser size change. +You can quickly navigate to the different calendar views by using the [allowedViews](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/allowedViews.html) property in the [SfCalendar](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar-class.html). The views set to this property will display as a view button in the header view of the Flutter Event Calendar. This UI will be responsive as showing more icons in the mobile view and will be updated based on the browser size change. {% tabs %} {% highlight dart hl_lines="15 16 17 18 19 20 21 22" %} diff --git a/Flutter/calendar/drag-drop.md b/Flutter/calendar/drag-drop.md index 42a49dd82..6a8476041 100644 --- a/Flutter/calendar/drag-drop.md +++ b/Flutter/calendar/drag-drop.md @@ -13,7 +13,7 @@ Easily reschedule an appointment by dragging it from one time slot or month cell ## Allow Drag and Drop -To perform drag-and-drop operations within the calendar, enable the [allowDragAndDrop](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/allowDragAndDrop.html) property of SfCalendar. +To perform drag-and-drop operations within the Flutter Event Calendar, enable the [allowDragAndDrop](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/allowDragAndDrop.html) property of SfCalendar. {% tabs %} {% highlight dart hl_lines="20" %} @@ -210,7 +210,7 @@ void dragEnd(AppointmentDragEndDetails appointmentDragEndDetails) { ## Disabling navigation when dragging appointment -You can restrict the navigation to the next/previous view when the dragging appointment reaches the start/end point of the current view in calendar by using the [allowNavigation](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/DragAndDropSettings/allowNavigation.html) property of [DragAndDropSettings](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/DragAndDropSettings-class.html). Default value of [allowNavigation](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/DragAndDropSettings/allowNavigation.html) property is true. +You can restrict the navigation to the next/previous view when the dragging appointment reaches the start/end point of the current view in Flutter Event Calendar by using the [allowNavigation](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/DragAndDropSettings/allowNavigation.html) property of [DragAndDropSettings](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/DragAndDropSettings-class.html). Default value of [allowNavigation](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/DragAndDropSettings/allowNavigation.html) property is true. {% tabs %} {% highlight dart hl_lines="20" %} @@ -247,7 +247,7 @@ class CalendarApp extends StatelessWidget { ## Disabling scroll when dragging appointment -You can restrict the timeslot views auto scroll when the appointment reaches the start/end point of the view port in the timeslot views of calendar by using the [allowScroll](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/DragAndDropSettings/allowScroll.html) property of [DragAndDropSettings](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/DragAndDropSettings/DragAndDropSettings.html). +You can restrict the timeslot views auto scroll when the appointment reaches the start/end point of the view port in the timeslot views of Flutter Event Calendar by using the [allowScroll](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/DragAndDropSettings/allowScroll.html) property of [DragAndDropSettings](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/DragAndDropSettings/DragAndDropSettings.html). {% tabs %} {% highlight dart hl_lines="20" %} diff --git a/Flutter/calendar/getting-started.md b/Flutter/calendar/getting-started.md index 7a7fcb500..090b0f0ff 100644 --- a/Flutter/calendar/getting-started.md +++ b/Flutter/calendar/getting-started.md @@ -9,21 +9,21 @@ documentation: ug # Flutter Event Calendar Getting Started (SfCalendar) -This section explains the steps required to add the calendar widget and populate appointments to the calendar widget. This section covers only basic features needed to get started with Syncfusion® calendar widget. +This section explains the steps required to add the Flutter Event Calendar widget and populate it with appointments. This section covers only basic features needed to get started with Syncfusion® Flutter Calendar widget. -To get started quickly with our [Flutter event calendar widget](https://www.syncfusion.com/flutter-widgets/flutter-calendar), you can refer to this video. +To get started quickly with our [Flutter Event Calendar widget](https://www.syncfusion.com/flutter-widgets/flutter-calendar), you can refer to this video. -N> You can also explore our [Flutter Calendar example](https://flutter.syncfusion.com/#/event-calendar/getting-started) to know how to render and configure the Flutter Examples. +N> You can also explore our [Flutter Event Calendar example](https://flutter.syncfusion.com/#/event-calendar/getting-started) to know how to render and configure the Flutter Examples. -## Add Flutter calendar to an application +## Add Flutter Event Calendar to an application Create a simple project using the instructions given in the [Getting Started with your first Flutter app](https://docs.flutter.dev/get-started/test-drive#choose-your-ide) documentation. **Add dependency** -Add the Syncfusion® Flutter calendar dependency to your pubspec.yaml file. +Add the Syncfusion® Flutter Calendar dependency to your pubspec.yaml file. {% tabs %} {% highlight dart %} @@ -61,9 +61,9 @@ import 'package:syncfusion_flutter_calendar/calendar.dart'; {% endhighlight %} {% endtabs %} -## Initialize calendar +## Initialize Flutter Event Calendar -After importing the package, initialize the calendar widget as a child of any widget. Here, the calendar widget is added as a child of the scaffold widget. +After importing the package, initialize the Flutter Event Calendar widget as a child of any widget. Here, the Flutter Event Calendar widget is added as a child of the scaffold widget. {% tabs %} {% highlight dart hl_lines="11" %} @@ -131,8 +131,8 @@ class CalendarApp extends StatelessWidget { ## Add data source -The calendar widget has a built-in capability to handle appointment arrangement internally based on the appointment collections. You need to assign the created collection to the [dataSource](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/dataSource.html) property. -You can also map custom appointment data to our calendar. +The Flutter Event Calendar widget has a built-in capability to handle appointment arrangement internally based on the appointment collections. You need to assign the created collection to the [dataSource](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/dataSource.html) property. +You can also map custom appointment data to our Flutter Event Calendar. {% tabs %} {% highlight dart hl_lines="16 22 23 24 25 26 27 28 29 30 31" %} @@ -221,7 +221,7 @@ class Meeting { ## Change first day of week -The calendar widget will be rendered with Sunday as the first day of the week, but you can customize it to any day by using the [firstDayOfWeek](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/firstDayOfWeek.html) property. +The Flutter Event Calendar widget will be rendered with Sunday as the first day of the week, but you can customize it to any day by using the [firstDayOfWeek](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/firstDayOfWeek.html) property. {% tabs %} {% highlight dart hl_lines="12" %} @@ -256,7 +256,7 @@ class CalendarApp extends StatelessWidget { ## Initial selected date -You can programmatically select the specific calendar month cell, and time slot by setting corresponding date and time value to the [initialSelectedDate](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/initialSelectedDate.html) property of calendar. By default, it is null. +You can programmatically select the specific month cell and time slot in the Flutter Event Calendar by setting corresponding date and time value to the [initialSelectedDate](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/initialSelectedDate.html) property. By default, it is null. {% tabs %} {% highlight dart hl_lines="14" %} @@ -293,7 +293,7 @@ class CalendarApp extends StatelessWidget { ## Initial display date -You can change the initial display date of calendar by using the [initialDisplayDate](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/initialDisplayDate.html) property of calendar, which displays the calendar based on the given date time. By default, current date will be set as `initialDisplayDate`. +You can change the initial display date of the Flutter Event Calendar by using the [initialDisplayDate](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/initialDisplayDate.html) property, which displays the calendar based on the given date time. By default, current date will be set as `initialDisplayDate`. {% tabs %} {% highlight dart hl_lines="14" %} @@ -330,7 +330,7 @@ class CalendarApp extends StatelessWidget { ## Selection decoration -You can decorate the selection view of calendar by using the [selectionDecoration](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/selectionDecoration.html) property of Calendar. +You can decorate the selection view of the Flutter Event Calendar by using the [selectionDecoration](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/selectionDecoration.html) property. {% tabs %} {% highlight dart hl_lines="14 15 16 17 18 19" %} @@ -372,7 +372,7 @@ class CalendarApp extends StatelessWidget { ## Today highlight color -You can customize the today highlight color of calendar by using the [todayHighlightColor](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/todayHighlightColor.html) property in calendar, which will highlight the today text in calendar view header, month cell, and agenda view. +You can customize the today highlight color of the Flutter Event Calendar by using the [todayHighlightColor](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/todayHighlightColor.html) property. This property highlights the today text in the view header, month cell, and agenda view. {% tabs %} {% highlight dart hl_lines="14" %} @@ -409,7 +409,7 @@ class CalendarApp extends StatelessWidget { ## Cell border color -You can customize the vertical and horizontal line color of calendar by using the [cellBorderColor](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/cellBorderColor.html) property in calendar. +You can customize the vertical and horizontal line color of the Flutter Event Calendar by using the [cellBorderColor](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/cellBorderColor.html) property. {% tabs %} {% highlight dart hl_lines="14" %} @@ -446,7 +446,7 @@ class CalendarApp extends StatelessWidget { ## Background color -The calendar widgets background color can be customized by using the [backgroundColor](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/backgroundColor.html) property in calendar. +The background color of the Flutter Event Calendar can be customized by using the [backgroundColor](https://pub.dev/documentation/syncfusion_flutter_Calendar/latest/Calendar/SfCalendar/backgroundColor.html) property. {% tabs %} {% highlight dart hl_lines="14" %} @@ -482,7 +482,7 @@ class CalendarApp extends StatelessWidget { ![Background color](images/getting-started/calendar-background-color.png) ## Navigation arrow -Using the [showNavigationArrow](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/showNavigationArrow.html) property of the [SfCalendar](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar-class.html), you can navigate to the next or previous views of the calendar without swiping. +Using the [showNavigationArrow](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/showNavigationArrow.html) property of the [SfCalendar](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar-class.html), you can navigate to the next or previous views of the Flutter Event Calendar without swiping. {% tabs %} {% highlight dart hl_lines="14" %} @@ -520,7 +520,7 @@ class CalendarApp extends StatelessWidget { * The [showNavigationArrow](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/showNavigationArrow.html) property is not applicable when the [view](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/view.html) is set to [CalendarView.schedule](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarView.html). ## Cell end padding -You can customize the padding of appointment view end to make touch position for timeslot and month cell by using the [cellEndPadding](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/cellEndPadding.html) property in the calendar, which allows you to tap the calendar cell when the cell has appointments. +You can customize the padding of appointment view end to make touch position for timeslot and month cell by using the [cellEndPadding](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/cellEndPadding.html) property in the Flutter Event Calendar, which allows you to tap the calendar cell when the cell has appointments. {% tabs %} {% highlight dart hl_lines="15" %} @@ -594,7 +594,7 @@ class CalendarApp extends StatelessWidget { ## Week number -Display the Week number of the year in all views except schedule view of the [SfCalendar](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar-class.html). by setting the [showWeekNumber](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/showWeekNumber.html) property as true and by default it is false. Week numbers will be displayed based on the ISO standard. +Display the Week number of the year in all views except schedule view of the [SfCalendar](https://pub.dev/documentation/syncfusion_flutter_Calendar/latest/Calendar/SfCalendar-class.html) by setting the [showWeekNumber](https://pub.dev/documentation/syncfusion_flutter_Calendar/latest/Calendar/SfCalendar/showWeekNumber.html) property as true and by default it is false. Week numbers will be displayed based on the ISO standard. {% tabs %} {% highlight dart hl_lines="15" %} @@ -625,11 +625,11 @@ class CalendarApp extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Week Number in Flutter Calendar](images\getting-started\flutter-calendar-week-number.png) +![Week Number in Flutter Event Calendar](images\getting-started\flutter-calendar-week-number.png) ## Week number appearance -Customize the Week number text style of the calendar by using the [WeekNumberStyle](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/WeekNumberStyle-class.html) property. Allows to customize the [textStyle](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/WeekNumberStyle/textStyle.html) and the [backgroundColor](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/WeekNumberStyle/backgroundColor.html) in the Week number of the calendar. +Customize the Week number text style of the Flutter Event Calendar by using the [WeekNumberStyle](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/WeekNumberStyle-class.html) property. Allows to customize the [textStyle](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/WeekNumberStyle/textStyle.html) and the [backgroundColor](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/WeekNumberStyle/backgroundColor.html) in the Week number of the Flutter Event Calendar. {% tabs %} {% highlight dart hl_lines="16 17 18 19" %} @@ -664,7 +664,7 @@ class CalendarApp extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Week Number Appearance in Flutter Calendar](images\getting-started\flutter-calendar-week-number-appearance.png) +![Week Number Appearance in Flutter Event Calendar](images\getting-started\flutter-calendar-week-number-appearance.png) Get the complete "getting started" sample from [here](https://github.com/SyncfusionExamples/flutter-calendar). diff --git a/Flutter/calendar/headers.md b/Flutter/calendar/headers.md index f9dd7b9e1..07d029412 100644 --- a/Flutter/calendar/headers.md +++ b/Flutter/calendar/headers.md @@ -14,11 +14,11 @@ You can learn about the header and view header height, date format, and appearan ## Header -You can customize the header of the calendar using the [headerStyle](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/headerStyle.html) and [headerHeight](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/headerHeight.html) properties in calendar. +You can customize the header of the Flutter Event Calendar using the [headerStyle](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/headerStyle.html) and [headerHeight](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/headerHeight.html) properties. -### Customize header height in calendar +### Customize header height in Flutter Event Calendar -You can customize the height for header in calendar using the [headerHeight](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/headerHeight.html) property in calendar. +You can customize the height for the header using the [headerHeight](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/headerHeight.html) property in Flutter Event Calendar. {% tabs %} {% highlight dart hl_lines="16" %} @@ -49,10 +49,10 @@ class CalendarApp extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Customize header height in calendar](images/headers/header-height.png) +![Customize header height in Flutter Event Calendar](images/headers/header-height.png) ### Header appearance -You can style the header using the [calendarHeaderStyle](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarHeaderStyle-class.html) in calendar. You can change the background color, textStyle, and text alignment using the properties such as [backgroundColor](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarHeaderStyle/backgroundColor.html), [textStyle](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarHeaderStyle/textStyle.html), and [textAlign](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarHeaderStyle/textAlign.html) of header using the [headerStyle](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/headerStyle.html) property in calendar. +You can style the header using the [calendarHeaderStyle](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarHeaderStyle-class.html) in Flutter Event Calendar. You can change the background color, textStyle, and text alignment using the properties such as [backgroundColor](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarHeaderStyle/backgroundColor.html), [textStyle](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarHeaderStyle/textStyle.html), and [textAlign](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarHeaderStyle/textAlign.html) of header using the [headerStyle](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/headerStyle.html) property in Flutter Event Calendar. {% tabs %} {% highlight dart hl_lines="16 17 18 19 20 21 22 23 24" %} @@ -132,11 +132,11 @@ class CalendarApp extends StatelessWidget { ## View header -You can customize the view header of the calendar using the [viewHeaderStyle](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/viewHeaderStyle.html) and [viewHeaderHeight](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/viewHeaderHeight.html) properties in calendar. +You can customize the view header of the Flutter Event Calendar using the [viewHeaderStyle](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/viewHeaderStyle.html) and [viewHeaderHeight](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/viewHeaderHeight.html) properties. -### Customize view header height in calendar +### Customize view header height in Flutter Event Calendar -You can customize the height for view header in calendar using the [viewHeaderHeight](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/viewHeaderHeight.html) property in calendar. +You can customize the height for view header in Flutter Event Calendar using the [viewHeaderHeight](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/viewHeaderHeight.html) property. {% tabs %} {% highlight dart hl_lines="16" %} @@ -167,11 +167,11 @@ class CalendarApp extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Customize view header height in calendar](images/headers/viewheader-height.png) +![Customize view header height in Flutter Event Calendar](images/headers/viewheader-height.png) ### View header appearance -You can style the header using the [viewHeaderStyle](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/ViewHeaderStyle-class.html) properties in calendar. You can change the background color, dayTextStyle, and dateTextStyle using properties such as [backgroundColor](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/ViewHeaderStyle/backgroundColor.html), [dayTextStyle](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/ViewHeaderStyle/dayTextStyle.html) and [dateTextStyle](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/ViewHeaderStyle/dateTextStyle.html) of view header using the [viewHeaderStyle](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/viewHeaderStyle.html) property in calendar. +You can style the header using the [viewHeaderStyle](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/ViewHeaderStyle-class.html) properties in the Flutter Event Calendar. You can change the background color, dayTextStyle, and dateTextStyle using properties such as [backgroundColor](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/ViewHeaderStyle/backgroundColor.html), [dayTextStyle](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/ViewHeaderStyle/dayTextStyle.html) and [dateTextStyle](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/ViewHeaderStyle/dateTextStyle.html) of view header using the [viewHeaderStyle](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/viewHeaderStyle.html) property in Flutter Event Calendar. {% tabs %} {% highlight dart hl_lines="16 17 18 19 20 21 22 23 24 25 26" %} @@ -215,7 +215,7 @@ class CalendarApp extends StatelessWidget { ![View header appearance](images/headers/viewheader-style.png) >**NOTE** -* The `dateTextStyle` property not applicable for view header in month view of calendar. +* The `dateTextStyle` property is not applicable for view header in month view of the Flutter Event Calendar. ## See also diff --git a/Flutter/calendar/how-to/custom-widget-on-flutterflow.md b/Flutter/calendar/how-to/custom-widget-on-flutterflow.md index c098d02ad..89d025d30 100644 --- a/Flutter/calendar/how-to/custom-widget-on-flutterflow.md +++ b/Flutter/calendar/how-to/custom-widget-on-flutterflow.md @@ -28,7 +28,7 @@ Navigate to the [FlutterFlow dashboard](https://app.flutterflow.io/dashboard) an ![Custom Widget](how-to-section-images/custom-widget.png) -### Add Calendar widget as a dependency +### Add Syncfusion® Flutter Calendar widget as a dependency 1. Click on `+ Add Dependency`, a text editor will appear. 2. Navigate to [Syncfusion® Flutter Calendar](https://pub.dev/packages/syncfusion_flutter_calendar) in [pub.dev](https://pub.dev/) and copy the dependency name and version using the `Copy to Clipboard` option. diff --git a/Flutter/calendar/load-more.md b/Flutter/calendar/load-more.md index 01a6e5b57..460d1b6c7 100644 --- a/Flutter/calendar/load-more.md +++ b/Flutter/calendar/load-more.md @@ -9,11 +9,11 @@ documentation: ug # Load more in Flutter Event Calendar (SfCalendar) -The Calendar provides the support to display an interactive view when the calendar view is changed, or the schedule view reaches its start or end offset. You can use the [loadMoreWidgetBuilder](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/loadMoreWidgetBuilder.html) builder to display the view while loading appointments in the calendar. +The Flutter Event Calendar provides the support to display an interactive view when the calendar view is changed, or the schedule view reaches its start or end offset. You can use the [loadMoreWidgetBuilder](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/loadMoreWidgetBuilder.html) builder to display the view while loading appointments in the Flutter Event Calendar. ## Building load more widget -Build your own custom widget by using the [loadMoreWidgetBuilder](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/loadMoreWidgetBuilder.html) that will be displayed as a loading indicator in the calendar when the calendar view changes, and in the calendar schedule view, the loading indicator will be displayed when it reaches the start or end position to load more appointments. +Build your own custom widget by using the [loadMoreWidgetBuilder](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/loadMoreWidgetBuilder.html) property. The widget will be displayed as a loading indicator when the view of the Flutter Event Calendar changes. In Schedule view, the loading indicator will be displayed when it reaches the start or end position to load more appointments. {% tabs %} {% highlight dart hl_lines="20 21 22 23 24 25 26 27 28 29 30 31 32 33" %} @@ -95,7 +95,7 @@ You can get the complete load more sample from this [link](https://github.com/Sy ## Load appointments -Update the appointments on-demand, when the loading indicator is displaying in the calendar by using the [handleLoadMore](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarDataSource/handleLoadMore.html) method in the [CalendarDataSource](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarDataSource-class.html), which allows adding the appointments to the data source, update the data source, and notify the listener to update the appointment on view. +Update the appointments on-demand, when the loading indicator is displaying in the Flutter Event Calendar by using the [handleLoadMore](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarDataSource/handleLoadMore.html) method in the [CalendarDataSource](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarDataSource-class.html), which allows adding the appointments to the data source, update the data source, and notify the listener to update the appointment on view. {% tabs %} {% highlight dart hl_lines="3 9 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34" %} diff --git a/Flutter/calendar/localization.md b/Flutter/calendar/localization.md index 8b1b1439f..c506df367 100644 --- a/Flutter/calendar/localization.md +++ b/Flutter/calendar/localization.md @@ -9,7 +9,7 @@ documentation: ug # Flutter Event Calendar Localization (SfCalendar) -By default, the calendar widget supports US English localizations. You can change to other languages by specifying the `MaterialApp` properties and adding the `flutter_localizations` package to your application. +By default, the Flutter Event Calendar widget supports US English localizations. You can change to other languages by specifying the `MaterialApp` properties and adding the `flutter_localizations` package to your application. To use `flutter_localizations`, add the package as dependency to your `pubspec.yaml` file. @@ -68,8 +68,8 @@ class CalendarApp extends StatelessWidget { {% endhighlight %} {% endtabs %} -## Localize the custom text in Calendar -Calendar custom text can be localized using the `syncfusion_localizations` package and specifying `localizationsDelegates` in `MaterialApp`. +## Localize the custom text in Flutter Event Calendar +Flutter Event Calendar custom text can be localized using the `syncfusion_localizations` package and specifying `localizationsDelegates` in `MaterialApp`. To use `syncfusion_localizations`, add the package as dependency to `pubspec.yaml` file. @@ -94,7 +94,7 @@ import 'package:syncfusion_localizations/syncfusion_localizations.dart'; {% endhighlight %} {% endtabs %} -Then, declare the `SfGlobalLocalizations.delegate` in the `localizationsDelegates`, which is used to localize the custom string (No events, No selected date) used in the calendar and specify the `supportedLocales` as well. +Then, declare the `SfGlobalLocalizations.delegate` in the `localizationsDelegates`, which is used to localize the custom string (No events, No selected date) used in the Flutter Event Calendar and specify the `supportedLocales` as well. {% tabs %} {% highlight dart hl_lines="16" %} @@ -141,7 +141,7 @@ class CalendarApp extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Localization Calendar](images/localization/localization.jpg) +![Localization Flutter Event Calendar](images/localization/localization.jpg) ## See also diff --git a/Flutter/calendar/month-view.md b/Flutter/calendar/month-view.md index 548fb5177..2361b851f 100644 --- a/Flutter/calendar/month-view.md +++ b/Flutter/calendar/month-view.md @@ -9,11 +9,11 @@ documentation: ug # Flutter Event Calendar Month View (SfCalendar) -The `month` view of Flutter Event [Calendar](https://www.syncfusion.com/flutter-widgets/flutter-calendar) (SfCalendar) is used to display entire dates of the specific month and current month by default initially. Current date color is differentiated with other dates of the current month, also the color differentiation for dates will be applicable for previous and next month dates. +The `month` view of [Flutter Event Calendar](https://www.syncfusion.com/flutter-widgets/flutter-Calendar) is used to display entire dates of the specific month and current month by default initially. Current date color is differentiated with other dates of the current month, also the color differentiation for dates will be applicable for previous and next month dates. ## Month agenda view -The calendar month view displays a divided agenda view that is used to show the selected date’s appointments below the month. You can show the agenda view by setting the [showAgenda](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/MonthViewSettings/showAgenda.html) property to true in [MonthViewSettings](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/MonthViewSettings-class.html). +The month view of the Flutter Event Calendar displays a divided agenda view that is used to show the selected date’s appointments below the month. You can show the agenda view by setting the [showAgenda](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/MonthViewSettings/showAgenda.html) property to true in [MonthViewSettings](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/MonthViewSettings-class.html). {% tabs %} {% highlight dart hl_lines="16" %} @@ -52,7 +52,7 @@ class CalendarApp extends StatelessWidget { ## Month appointment display mode -You can handle the calendar month view appointment display by using the [appointmentDisplayMode](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/MonthViewSettings/appointmentDisplayMode.html) property of [MonthViewSettings](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/MonthViewSettings-class.html). By default, `appointmentDisplayMode` is set to Indicator, using the `appointmentDisplayMode` you can set the month view appointments display as follows. +You can handle the Flutter Event Calendar month view appointment display by using the [appointmentDisplayMode](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/MonthViewSettings/appointmentDisplayMode.html) property of [MonthViewSettings](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/MonthViewSettings-class.html). By default, `appointmentDisplayMode` is set to Indicator, using the `appointmentDisplayMode` you can set the month view appointments display as follows. * [indicator](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/MonthAppointmentDisplayMode.html) - appointment will be denoted as the circle. * [appointment](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/MonthAppointmentDisplayMode.html) - appointment subject will be displayed in month cell. @@ -94,7 +94,7 @@ class CalendarApp extends StatelessWidget { ## Agenda view height -You can customize the month agenda view height from calendar by using the [agendaViewHeight](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/MonthViewSettings/agendaViewHeight.html) property of [MonthViewSettings](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/MonthViewSettings-class.html). By default, the agenda view will occupy the 30% height of the calendar height. +You can customize the month agenda view height from the Flutter Event Calendar by using the [agendaViewHeight](https://pub.dev/documentation/syncfusion_flutter_Calendar/latest/Calendar/MonthViewSettings/agendaViewHeight.html) property of [MonthViewSettings](https://pub.dev/documentation/syncfusion_flutter_Calendar/latest/Calendar/MonthViewSettings-class.html). By default, the agenda view will occupy the 30% height of the Flutter Event Calendar height. {% tabs %} {% highlight dart hl_lines="20" %} @@ -216,7 +216,7 @@ class CalendarApp extends StatelessWidget { ## Month navigation direction -MonthView of calendar can be navigated in both horizontal and vertical direction. You can change the direction of navigation using the [navigationDirection](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/MonthViewSettings/navigationDirection.html) property of [MonthViewSettings](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/MonthViewSettings-class.html), by default Month navigation direction is Horizontal. +MonthView of the Flutter Event Calendar can be navigated in both horizontal and vertical direction. You can change the direction of navigation using the [navigationDirection](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/MonthViewSettings/navigationDirection.html) property of [MonthViewSettings](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/MonthViewSettings-class.html), by default Month navigation direction is Horizontal. {% tabs %} {% highlight dart hl_lines="18 19" %} @@ -298,7 +298,7 @@ class CalendarApp extends StatelessWidget { ![Blackout dates](images/monthview/blackout-dates.png) ## Hide leading and trailing dates -You can hide the previous and next month dates of a calendar month view by using the [showTrailingAndLeadingDates](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/MonthViewSettings/showTrailingAndLeadingDates.html) property in the [MonthViewSettings](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/MonthViewSettings-class.html) of the calendar. +You can hide the previous and next month dates of the Flutter Event Calendar month view by using the [showTrailingAndLeadingDates](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/MonthViewSettings/showTrailingAndLeadingDates.html) property in the [MonthViewSettings](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/MonthViewSettings-class.html). {% tabs %} {% highlight dart hl_lines="16" %} @@ -336,7 +336,7 @@ class CalendarApp extends StatelessWidget { ## Customize number of month rows -The number of weeks in the month view can be changed by setting the [numberOfWeeksInView](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/MonthViewSettings/numberOfWeeksInView.html) property in [MonthViewSettings](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/MonthViewSettings-class.html). By default, `numberOfWeeksInView` starts from current week, and this can be modified using the [initialDisplayDate](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/initialDisplayDate.html) property of calendar, the two weeks calendar can be achieved by setting the `numberOfWeeksInView` property with the value 2. +The number of weeks in the month view can be changed by setting the [numberOfWeeksInView](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/MonthViewSettings/numberOfWeeksInView.html) property in [MonthViewSettings](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/MonthViewSettings-class.html). By default, `numberOfWeeksInView` starts from current week, and this can be modified using the [initialDisplayDate](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/initialDisplayDate.html) property of the Flutter Event Calendar. A two-week calendar can be achieved by setting the `numberOfWeeksInView` property to 2. {% tabs %} {% highlight dart hl_lines="18" %} @@ -373,7 +373,7 @@ class CalendarApp extends StatelessWidget { >**NOTE** * Week number ranges from 1 to 6. If lesser or greater than these range is considered, [numberOfWeeksInView](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/MonthViewSettings/numberOfWeeksInView.html) will be displayed as 6. -* Dynamically changing [numberOfWeeksInView](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/MonthViewSettings/numberOfWeeksInView.html) shows the first row of month view dates. It can be handled using the [initialDisplayDate](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/initialDisplayDate.html) property of calendar. +* Dynamically changing [numberOfWeeksInView](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/MonthViewSettings/numberOfWeeksInView.html) shows the first row of month view dates. It can be handled using the [initialDisplayDate](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/initialDisplayDate.html) property of the Flutter Event Calendar. ## View header DayFormat diff --git a/Flutter/calendar/overview.md b/Flutter/calendar/overview.md index 6f004a8d0..947769a03 100644 --- a/Flutter/calendar/overview.md +++ b/Flutter/calendar/overview.md @@ -9,9 +9,9 @@ documentation: ug # Flutter Event Calendar Overview (SfCalendar) -The Syncfusion® Flutter Calendar library is written natively in Dart and has nine types of built-in configurable view modes that provide basic functionality for scheduling, managing, and representing appointments efficiently. The calendar widget exposes a clean and convenient user interface for custom working days and hours and basic calendar operations such as date navigation and selection. +The Syncfusion® Flutter Calendar library is written natively in Dart and has nine types of built-in configurable view modes that provide basic functionality for scheduling, managing, and representing appointments efficiently. The Flutter Event Calendar widget exposes a clean and convenient user interface for custom working days and hours and basic calendar operations such as date navigation and selection. -![Calendar overview](images/overview/calendar_overview.png) +![Flutter Event Calendar overview](images/overview/calendar_overview.png) ## Key features @@ -20,13 +20,13 @@ The Syncfusion® Flutter Calendar library is written natively in D ![Multiple calendar views](images/overview/multiple_calendar_views.png) * **Appointments**: Appointments contain information on events scheduled at specific times. In addition to default appointments, users can use their own collections to connect a business entity to an appointment by mapping their fields, such as start time, end time, subject, notes, and recurrence. -![Calendar appointments](images/overview/appointments_events.png) +![Flutter Event Calendar appointments](images/overview/appointments_events.png) * **Recurring appointments**: Easily configure recurring events to be repeated on a daily, weekly, monthly, or yearly basis with optimized recurrence options. You can also skip or change the occurrence of a recurring appointment. ![Recurring appointments](images/overview/recurring_events.png) -* **Time zone**: Regardless of the time zone in your device, Calendar supports setting any required time zone for the control itself, as well as individual events. +* **Time zone**: Regardless of the time zone in your device, Flutter Event Calendar supports setting any required time zone for the control itself, as well as individual events. -![Calendar timezone](images/overview/timezone.png) +![Flutter Event Calendar timezone](images/overview/timezone.png) * **Schedule view**: Show a list of scheduled appointments grouped by week, between set minimum and maximum dates, with the schedule view. You can customize everything from the date and time formats to the styling of each header. ![Schedule view](images/overview/Schedule_view.png) @@ -37,7 +37,7 @@ The Syncfusion® Flutter Calendar library is written natively in D ![Resource view](images/overview/resource-view.png) * **Special time regions**: Disable interactions and selections for specific time ranges. This is useful when you want to block user interaction during holidays or other special events and to highlight those time slots. -![Calendar time regions](images/overview/Special_region.png) +![Flutter Event Calendar time regions](images/overview/Special_region.png) * **Flexible working days**: Customize the work days in a workweek so that the remaining days will be hidden from view. @@ -46,19 +46,19 @@ The Syncfusion® Flutter Calendar library is written natively in D * **First day of the week**: Customize the first day of the week as needed. The default is Sunday. ![First day of week](images/overview/First_day_of_week.png) -* **Blackout dates**: Disable any date in a month and timeline month view of a calendar to make it inactive. You can easily prevent the selection of weekends by disabling them. +* **Blackout dates**: Disable any date in a month and timeline month view of a Flutter Event Calendar to make it inactive. You can easily prevent the selection of weekends by disabling them. ![Blackout dates](images/overview/blackout_dates.png) -* **Hide leading and trailing dates**: Hide the next month and previous month dates in the calendar to enhance the appearance. +* **Hide leading and trailing dates**: Hide the next month and previous month dates in the Flutter Event Calendar to enhance the appearance. ![Hide leading trailing dates](images/overview/hide-leading-trailing-dates.png) * **Month agenda view**: Display appointments in a list as shown in the following month view by clicking on a day. ![Month agenda view](images/overview/Month_agenda_view.png) -* **Appearance customization**: Provide a uniform and consistent look with Calendar’s flexible appearance and format. +* **Appearance customization**: Provide a uniform and consistent look with flexible appearance and format of the Flutter Event Calendar. ![Appearance customization](images/overview/Appearance_customization.png) -* **Custom start and end hours**: Display the event calendar timeslot views with specific time durations by hiding the unwanted hours. -* **Web layout**: The web layout improved for a better experience, and now, the mouse hovering effect has been applied to all the calendar elements. +* **Custom start and end hours**: Display the Flutter Event Calendar timeslot views with specific time durations by hiding the unwanted hours. +* **Web layout**: The web layout improved for a better experience, and now, the mouse hovering effect has been applied to all the Flutter Event Calendar elements. ## Getting started diff --git a/Flutter/calendar/resource-view.md b/Flutter/calendar/resource-view.md index ac55ddf78..a860be951 100644 --- a/Flutter/calendar/resource-view.md +++ b/Flutter/calendar/resource-view.md @@ -9,7 +9,7 @@ documentation: ug # Flutter Event Calendar Resource View (SfCalendar) -The timeline resource grouping is a discrete view integrated into our Event Calendar widget that allows you to group the appointments based on the available resource in timeline views of the calendar. Using this feature, you can group the appointments and time regions arranged in a row-wise order based on the allocated resource in the timeline views. This rich feature set includes customization and you can assign unique styles to the available resource view. +The timeline resource grouping is a discrete view integrated into our Flutter Event Calendar widget that allows you to group the appointments based on the available resource in timeline views. Using this feature, you can group the appointments and time regions arranged in a row-wise order based on the allocated resource in the timeline views. This rich feature set includes customization and you can assign unique styles to the available resource view. You can create a resource view by setting the [displayName](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarResource/displayName.html), [color](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarResource/color.html), [id](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarResource/id.html), and [image](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarResource/image.html) property of the [CalendarResource](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarResource-class.html). @@ -81,7 +81,7 @@ class _AppointmentDataSource extends CalendarDataSource { ![Resource view](images/resourceview/resource-view.png) ## Assigning events for resources -You can associate resources to the appointments by adding `id` of a resource to the [resourceIds](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/Appointment/resourceIds.html) property of [Appointment](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/Appointment-class.html). The appointments will be displayed in the row associates with the resource in the event calendar timeline views. +You can associate resources to the appointments by adding `id` of a resource to the [resourceIds](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/Appointment/resourceIds.html) property of [Appointment](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/Appointment-class.html). The appointments will be displayed in the row associates with the resource in the Flutter Event Calendar timeline views. {% tabs %} {% highlight dart hl_lines="6" %} @@ -357,7 +357,7 @@ class _CalendarAppState extends State { ![Display name text style](images/resourceview/display_name_text_style.png) ### Resource panel size -You can customize the size of the panel that displays the resource views in the calendar by setting an appropriate value to the [size](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/ResourceViewSettings/size.html) property available in the [ResourceViewSettings](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/resourceViewSettings.html). +You can customize the size of the panel that displays the resource views in the Flutter Event Calendar by setting an appropriate value to the [size](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/ResourceViewSettings/size.html) property available in the [ResourceViewSettings](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/resourceViewSettings.html). {% tabs %} {% highlight dart hl_lines="21" %} diff --git a/Flutter/calendar/right-to-left.md b/Flutter/calendar/right-to-left.md index e003d083e..e8f4f2a04 100644 --- a/Flutter/calendar/right-to-left.md +++ b/Flutter/calendar/right-to-left.md @@ -8,7 +8,7 @@ documentation: ug --- # Right to Left (RTL) in Flutter Event Calendar (SfCalendar) -The event calendar supports right-to-left rendering and all the calendar elements rendering direction will be changed. +The Flutter Event Calendar supports right-to-left rendering and the rendering direction of all the calendar elements will be changed. ## RTL rendering ways Right to Left rendering can be switched in the following ways: @@ -51,7 +51,7 @@ class CalendarApp extends StatelessWidget { {% endtabs %} ### Changing the locale to RTL languages -To change the event calendar rendering direction from right to left, change the locale to any of the RTL languages such as Arabic, Persian, Hebrew, Pashto, and Urdu. +To change the rendering direction of the Flutter Event Calendar from right to left, change the locale to any of the RTL languages such as Arabic, Persian, Hebrew, Pashto, and Urdu. {% tabs %} {% highlight dart hl_lines="14 15 16 17 18 19 20 21 22 23" %} diff --git a/Flutter/calendar/schedule-view.md b/Flutter/calendar/schedule-view.md index 7e16f72e1..019e2f812 100644 --- a/Flutter/calendar/schedule-view.md +++ b/Flutter/calendar/schedule-view.md @@ -13,10 +13,10 @@ The `schedule` view of SfCalendar shows a list of scheduled appointments grouped The schedule view displays two different UIs for mobile and web. For mobile, it will display the month header, week header, and date header, but for the web, it will display the appointments alone in the view. -![Schedule view in Flutter event calendar](images/scheduleview/Schedule-view.png) +![Schedule view in Flutter Event Calendar](images/scheduleview/Schedule-view.png) >**NOTE** -* If the web view width is less than `767`, the calendar will render the mobile schedule UI for the web. +* If the web view width is less than `767`, the Flutter Event Calendar will render the mobile schedule UI for the web. ## Appointment item height You can customize the height of an appointment in a schedule view by using the [appointmentItemHeight](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/ScheduleViewSettings/appointmentItemHeight.html) property of [ScheduleViewSettings](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/ScheduleViewSettings-class.html). diff --git a/Flutter/calendar/timeslot-views.md b/Flutter/calendar/timeslot-views.md index 79f4c6af5..151fba91f 100644 --- a/Flutter/calendar/timeslot-views.md +++ b/Flutter/calendar/timeslot-views.md @@ -9,7 +9,7 @@ documentation: ug # Flutter Event Calendar Timeslot View (SfCalendar) -[Flutter Calendar](https://www.syncfusion.com/flutter-widgets/flutter-calendar) has six built-in time slot views used to display dates, and the views will show based on the current day by default. Appointments on a specific day will be arranged in respective timeslots based on their duration. +[Flutter Event Calendar](https://www.syncfusion.com/flutter-widgets/flutter-calendar) has six built-in time slot views used to display dates, and the views will show based on the current day by default. Appointments on a specific day will be arranged in respective timeslots based on their duration. * **Day view:** Displays a single day. * **Week view:** Displays all days of a week. @@ -174,14 +174,14 @@ class CalendarApp extends StatelessWidget { >**NOTE** * The [nonWorkingDay](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/TimeSlotViewSettings/nonWorkingDays.html) property is applicable only for `workWeek` and `timelineWorkWeek` views only, and not applicable for the remaining views. -* Calendar Appointments UI, which does not fall within the `startHour` and `endHour` will not be visible and if it falls partially, it will be clipped. +* Flutter Event Calendar Appointments UI, which does not fall within the `startHour` and `endHour` will not be visible and if it falls partially, it will be clipped. * No need to specify the decimal point values for `startHour` and `endHour`, if you don’t want to set the minutes. * The number of time slots will be calculated based on total minutes of a day and time interval (total minutes of a day ((start hour - end hour) * 60) / time interval). * If custom timeInterval is given, then the number of time slots calculated based on the given TimeInterval should result in integer value (total minutes % timeInterval = 0), otherwise next immediate time interval that result in integer value when divide total minutes of a day will be considered. For example, if timeInterval=2 Hours 15 minutes and total minutes = 1440 (24 Hours per day), then timeInterval will be changed to ‘144’ (1440%144=0) by considering (total minutes % timeInterval = 0), it will return integer value for time slots rendering. * If the custom `startHour` and `endHour` are given, then the number of time slots calculated based on given `startHour` and `endHour` should result in integer value, otherwise next immediate `timeInterval` will be considered until the result is integer value. For example, if `startHour` is 9 (09:00AM), `endHour` is 18.25 (06:15 PM), `timeInterval` is 30 minutes, and total minutes = 555 ((18.25-9)*60), then the timeInterval will be changed to ’37 minutes’ (555%37=0) by considering (total minutes % timeInterval = 0). it will return integer value for time slots rendering. ## Number of days in view -You can customize the days count by setting the [numberOfDaysInView](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/TimeSlotViewSettings/numberOfDaysInView.html) property of [TimeSlotViewSettings](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/TimeSlotViewSettings-class.html/) in the calendar. +You can customize the days count by setting the [numberOfDaysInView](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/TimeSlotViewSettings/numberOfDaysInView.html) property of [TimeSlotViewSettings](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/TimeSlotViewSettings-class.html/) in the Flutter Event Calendar. {% tabs %} {% highlight dart hl_lines="17" %} @@ -220,7 +220,7 @@ class CalendarApp extends StatelessWidget { ## Special time regions You can restrict the user interaction such as selection and highlights specific regions of time in the timeslot views by adding the [specialRegions](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/specialRegions.html) property of [SfCalendar](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar-class.html). You need to set the [startTime](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/TimeRegion/startTime.html) and [endTime](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/TimeRegion/endTime.html) properties of [TimeRegion](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/TimeRegion-class.html) to create a `specialTimeRegion`, you can use the [timeZone](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/TimeRegion/timeZone.html) property to set the specific timezone for start and end time of `specialTimeRegion`. The `specialTimeRegion` will display the text or icon on it that set to the [text](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/TimeRegion/text.html) or [iconData](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/TimeRegion/iconData.html) property of [TimeRegion](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/TimeRegion-class.html). -![Special time region in Flutter event calendar](images/timeslot-views/Special_region.png) +![Special time region in Flutter Event Calendar](images/timeslot-views/Special_region.png) >**NOTE** * If time region has both the text and icon then it will draw icon only. @@ -429,7 +429,7 @@ class CalendarApp extends StatelessWidget { ## Full screen calendar -The calendar time interval height and width can be adjusted based on the screen height by changing the value of the [timeIntervalHeight](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/TimeSlotViewSettings/timeIntervalHeight.html) and [timeIntervalWidth](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/TimeSlotViewSettings/timeIntervalWidth.html) property to -1. It will auto fit the screen height and width. +The time interval height and width of the Flutter Event Calendar can be adjusted based on the screen height by changing the value of the [timeIntervalHeight](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/TimeSlotViewSettings/timeIntervalHeight.html) and [timeIntervalWidth](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/TimeSlotViewSettings/timeIntervalWidth.html) property to -1. It will auto fit the screen height and width. {% tabs %} {% highlight dart hl_lines="17" %} @@ -644,7 +644,7 @@ class CalendarApp extends StatelessWidget { ![View header text formatting](images/timeslot-views/viewheader-text-format.png) ## Time text formatting -You can customize the format for the labels mentioning the time, by setting the [timeFormat](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/TimeSlotViewSettings/timeFormat.html) property of [TimeSlotViewSettings](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/TimeSlotViewSettings-class.html) in calendar. +You can customize the format for the labels mentioning the time, by setting the [timeFormat](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/TimeSlotViewSettings/timeFormat.html) property of [TimeSlotViewSettings](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/TimeSlotViewSettings-class.html) in the Flutter Event Calendar. {% tabs %} {% highlight dart hl_lines="19" %} @@ -682,7 +682,7 @@ class CalendarApp extends StatelessWidget { ## Time text appearance -You can customize the text style for the labels mentioning the time, by setting the [timeTextStyle](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/TimeSlotViewSettings/timeTextStyle.html) property of [TimeSlotViewSettings](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/TimeSlotViewSettings-class.html) in calendar. +You can customize the text style for the labels mentioning the time, by setting the [timeTextStyle](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/TimeSlotViewSettings/timeTextStyle.html) property of [TimeSlotViewSettings](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/TimeSlotViewSettings-class.html) in Flutter Event Calendar. {% tabs %} {% highlight dart hl_lines="19 20 21 22 23 24" %} @@ -723,7 +723,7 @@ class CalendarApp extends StatelessWidget { ![Time text appearance](images/timeslot-views/time-text-appearance.png) ## All day panel background color -All day panel background color can be customized by using the [allDayPanelColor](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/TimeSlotViewSettings/allDayPanelColor.html) property of [TimeSlotViewSettings](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/TimeSlotViewSettings-class.html) in the calendar. +All day panel background color can be customized by using the [allDayPanelColor](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/TimeSlotViewSettings/allDayPanelColor.html) property of [TimeSlotViewSettings](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/TimeSlotViewSettings-class.html) in the Flutter Event Calendar. {% tabs %} {% highlight dart hl_lines="19" %} diff --git a/Flutter/calendar/timezone.md b/Flutter/calendar/timezone.md index acc54d86e..cf346cb6d 100644 --- a/Flutter/calendar/timezone.md +++ b/Flutter/calendar/timezone.md @@ -9,14 +9,14 @@ documentation: ug # Flutter Event Calendar Time Zone (SfCalendar) -[Flutter Calendar](https://www.syncfusion.com/flutter-widgets/flutter-calendar) allows you to create appointments in various time zones and display them in users’ time zone or any other time zone. You can use a time zone in the following four different ways: +[Flutter Event Calendar](https://www.syncfusion.com/flutter-widgets/flutter-calendar) allows you to create appointments in various time zones and display them in users’ time zone or any other time zone. You can use a time zone in the following four different ways: * Create appointments in different time zones. * Display appointments based on the client’s time zone. -* Display appointments based on calendar time zone. +* Display appointments based on time zone of the Flutter Event Calendar. * Display appointments at the same time everywhere regardless of client’s time zone. -We have added the following Time Zones for the respective countries to cover all time zone regions. You can use any of the time zones from the following list for calendar time zone. +We have added the following Time Zones for the respective countries to cover all time zone regions. You can use any of the time zones from the following list for Flutter Event Calendar time zone. @@ -1183,17 +1183,17 @@ appointments.add(Appointment( >**NOTE** * If the recurring appointment is converted to another time zone, then the whole sequence will be recalculated according to the new time zone information. * If you create an all-day appointment, its start time and end time will be set to 12 A.M. and 12 A.M. by default, so time zone is not applicable for all-day appointments. -* Calendar supports daylight saving time. +* Flutter Event Calendar supports daylight saving time. * The time zone support is applicable for custom appointments too, so you need to map the corresponding property. * You can use TimeZone for custom appointments by mapping the `startTimeZoneMapper` and `endTimeZoneMapper` custom properties of [CalendarDataSource](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/CalendarDataSource-class.html). ## Display appointment based on client’s time zone -You can display the appointments based on the client’s local time zone in calendar. For example, consider a scenario that you are in North Carolina and you want to set up a meeting at 10 A.M. on North Carolina time. You have colleagues in London and Chennai, and they also need to participate. The time for this meeting will be 3 P.M. (15:00) in London and 5.30 A.M. in Chennai. When you each view your calendar, you need to see the appointment displayed relative to your local time zones 5.30 A.M., 10 A.M., and 3 P.M., respectively. It can be achieved by setting calendar time zone to default (it will consider your device’s local time zone as calendar time zone) and appointment’s time zone to Eastern Standard Time (North Carolina) [as you are in North Carolina and its time zone is Eastern Standard Time]. +You can display the appointments based on the client’s local time zone in the Flutter Event Calendar. For example, consider a scenario that you are in North Carolina and you want to set up a meeting at 10 A.M. on North Carolina time. You have colleagues in London and Chennai, and they also need to participate. The time for this meeting will be 3 P.M. (15:00) in London and 5.30 A.M. in Chennai. When you each view your calendar, you need to see the appointment displayed relative to your local time zones 5.30 A.M., 10 A.M., and 3 P.M., respectively. It can be achieved by setting calendar time zone to default (it will consider your device’s local time zone as calendar time zone) and appointment’s time zone to Eastern Standard Time (North Carolina) [as you are in North Carolina and its time zone is Eastern Standard Time]. -## Display appointments based on calendar time zone +## Display appointments based on Flutter Event Calendar time zone -You can set specific time zone to calendar using the [timeZone](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/timeZone.html) property of calendar. On this scenario, the appointments will be displayed in UTC time when the [startTimeZone](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/Appointment/startTimeZone.html) and [endTimeZone](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/Appointment/endTimeZone.html) properties of `Appointment` are set to null. The appointments will be displayed in UTC time based on the given calendar time zone. +You can set specific time zone to Flutter Event Calendar using the [timeZone](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/SfCalendar/timeZone.html) property. On this scenario, the appointments will be displayed in UTC time when the [startTimeZone](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/Appointment/startTimeZone.html) and [endTimeZone](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/Appointment/endTimeZone.html) properties of `Appointment` are set to null. The appointments will be displayed in UTC time based on the given calendar time zone. {% tabs %} {% highlight dart hl_lines="8" %} @@ -1217,4 +1217,4 @@ Widget build(BuildContext context) { ## Display appointments at same time everywhere regardless of client’s time zone -You can display appointments at the same time everywhere without considering the time zone when you set the `timeZone` property of calendar, the [startTimeZone](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/Appointment/startTimeZone.html) and [endTimeZone](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/Appointment/endTimeZone.html) properties of `Appointment` to null. The appointments will be displayed based on the given `startTime` and `endTime` of appointment everywhere without considering the time zone. +You can display appointments at the same time everywhere without considering the time zone when you set the `timeZone` property of the Flutter Event Calendar, the [startTimeZone](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/Appointment/startTimeZone.html) and [endTimeZone](https://pub.dev/documentation/syncfusion_flutter_calendar/latest/calendar/Appointment/endTimeZone.html) properties of `Appointment` to null. The appointments will be displayed based on the given `startTime` and `endTime` of appointment everywhere without considering the time zone. diff --git a/Flutter/chat/chat-theme.md b/Flutter/chat/chat-theme.md index 321009d96..bffa41710 100644 --- a/Flutter/chat/chat-theme.md +++ b/Flutter/chat/chat-theme.md @@ -491,4 +491,4 @@ class SuggestionThemeExample extends StatelessWidget { {% endhighlight %} {% endtabs %} ->You can refer to our [Flutter Chat](https://www.syncfusion.com/flutter-widgets/flutter-chat) feature tour page for its groundbreaking feature representations. You can also explore our [Flutter Chat example](https://flutter.syncfusion.com/#/chat/getting-started) which demonstrates conversations between two or more users in a fully customizable layout and shows how to easily configure the chat with built-in support for creating stunning visual effects. \ No newline at end of file +>You can refer to our [Flutter Chat](https://www.syncfusion.com/flutter-widgets/flutter-chat) feature tour page for its groundbreaking feature representations. You can also explore our [Flutter Chat example](https://flutter.syncfusion.com/#/chat/getting-started) which demonstrates conversations between two or more users in a fully customizable layout and shows how to easily configure the Flutter Chat widget with built-in support for creating stunning visual effects. \ No newline at end of file diff --git a/Flutter/chat/composer.md b/Flutter/chat/composer.md index 0e38c5f30..3f136b3f6 100644 --- a/Flutter/chat/composer.md +++ b/Flutter/chat/composer.md @@ -15,7 +15,7 @@ This section explains the customization options available in [`ChatComposer`](ht The [`composer`](https://pub.dev/documentation/syncfusion_flutter_chat/latest/chat/SfChat/composer.html) is a customizable text editor designed for typing new messages. It offers options to adjust the appearance and behavior of the text editor, including settings for the `minimum` and `maximum` number of lines, `decoration`, `margin`, `textStyle`, and theme-level `editorTextStyle` (see [Chat theme - Editor text style](chat-theme.md#editor-text-style)). -When the composer is null, no default text field is added to the chat widget. +When the composer is null, no default text field is added to the Flutter Chat widget. ### Minimum and maximum lines @@ -562,4 +562,4 @@ class _ComposerBuilderExampleState extends State { ![Chat composer support](images/composer/composer-builder.png) ->You can refer to our [Flutter Chat](https://www.syncfusion.com/flutter-widgets/flutter-chat) feature tour page for its groundbreaking feature representations. You can also explore our [Flutter Chat example](https://flutter.syncfusion.com/#/chat/getting-started) which demonstrates conversations between two or more users in a fully customizable layout and shows how to easily configure the chat with built-in support for creating stunning visual effects. \ No newline at end of file +>You can refer to our [Flutter Chat](https://www.syncfusion.com/flutter-widgets/flutter-chat) feature tour page for its groundbreaking feature representations. You can also explore our [Flutter Chat example](https://flutter.syncfusion.com/#/chat/getting-started) which demonstrates conversations between two or more users in a fully customizable layout and shows how to easily configure the Flutter Chat widget with built-in support for creating stunning visual effects. \ No newline at end of file diff --git a/Flutter/chat/conversation-area.md b/Flutter/chat/conversation-area.md index ea40b29d2..ac9088e24 100644 --- a/Flutter/chat/conversation-area.md +++ b/Flutter/chat/conversation-area.md @@ -9,11 +9,11 @@ documentation: ug # Message Content in Flutter Chat (SfChat) -This section explains the customization options available for incoming and outgoing messages in the chat widget. +This section explains the customization options available for incoming and outgoing messages in the Flutter Chat widget. ## Messages -The [`messages`](https://pub.dev/documentation/syncfusion_flutter_chat/latest/chat/SfChat/messages.html) property is the data source of the Chat widget. It accepts a list of [`ChatMessage`](https://pub.dev/documentation/syncfusion_flutter_chat/latest/chat/ChatMessage-class.html) objects that are displayed as incoming or outgoing based on the [`outgoingUser`](https://pub.dev/documentation/syncfusion_flutter_chat/latest/chat/SfChat/outgoingUser.html) value. +The [`messages`](https://pub.dev/documentation/syncfusion_flutter_chat/latest/chat/SfChat/messages.html) property is the data source of the Flutter Chat widget. It accepts a list of [`ChatMessage`](https://pub.dev/documentation/syncfusion_flutter_chat/latest/chat/ChatMessage-class.html) objects that are displayed as incoming or outgoing based on the [`outgoingUser`](https://pub.dev/documentation/syncfusion_flutter_chat/latest/chat/SfChat/outgoingUser.html) value. Each [`ChatMessage`](https://pub.dev/documentation/syncfusion_flutter_chat/latest/chat/ChatMessage-class.html) contains: @@ -592,7 +592,7 @@ class MessageSettingsExample extends StatelessWidget { ![Bubble settings](images/message-content/contentbackgroundcolor-for-bubblesettings.png) ->You can refer to our [Flutter Chat](https://www.syncfusion.com/flutter-widgets/flutter-chat) feature tour page for its groundbreaking feature representations. You can also explore our [Flutter Chat example](https://flutter.syncfusion.com/#/chat/getting-started) which demonstrates conversations between two or more users in a fully customizable layout and shows how to easily configure the chat with built-in support for creating stunning visual effects. +>You can refer to our [Flutter Chat](https://www.syncfusion.com/flutter-widgets/flutter-chat) feature tour page for its groundbreaking feature representations. You can also explore our [Flutter Chat example](https://flutter.syncfusion.com/#/chat/getting-started) which demonstrates conversations between two or more users in a fully customizable layout and shows how to easily configure the Flutter Chat widget with built-in support for creating stunning visual effects. #### See Also diff --git a/Flutter/chat/getting-started.md b/Flutter/chat/getting-started.md index 93bcb335e..3e3b93bb8 100644 --- a/Flutter/chat/getting-started.md +++ b/Flutter/chat/getting-started.md @@ -57,9 +57,9 @@ import 'package:syncfusion_flutter_chat/chat.dart'; {% endhighlight %} {% endtabs %} -## Initialize chat widget +## Initialize Flutter Chat widget -Add a chat widget with the necessary properties, such as [`messages`](https://pub.dev/documentation/syncfusion_flutter_chat/latest/chat/SfChat/messages.html) and [`outgoingUser`](https://pub.dev/documentation/syncfusion_flutter_chat/latest/chat/SfChat/outgoingUser.html). +Add a Flutter Chat widget with the necessary properties, such as [`messages`](https://pub.dev/documentation/syncfusion_flutter_chat/latest/chat/SfChat/messages.html) and [`outgoingUser`](https://pub.dev/documentation/syncfusion_flutter_chat/latest/chat/SfChat/outgoingUser.html). {% tabs %} {% highlight dart hl_lines="16 42" %} @@ -115,7 +115,7 @@ class ChatInitializeExample extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Default chat](images/getting-started/initialize-chat.png) +![Default Chat](images/getting-started/initialize-chat.png) ## Add composer @@ -235,7 +235,7 @@ class ChatPlaceholderExample extends StatelessWidget { The action button represents the send button, which is not included by default. To add it, create an instance of [`ChatActionButton`](https://pub.dev/documentation/syncfusion_flutter_chat/latest/chat/ChatActionButton-class.html) for the [`actionButton`](https://pub.dev/documentation/syncfusion_flutter_chat/latest/chat/SfChat/actionButton.html) property. -When the send button is clicked, the [`ChatActionButton.onPressed`](https://pub.dev/documentation/syncfusion_flutter_chat/latest/chat/ChatActionButton/onPressed.html) callback is invoked. In that callback, add the newly composed message to the messages list and rebuild the chat widget. +When the send button is clicked, the [`ChatActionButton.onPressed`](https://pub.dev/documentation/syncfusion_flutter_chat/latest/chat/ChatActionButton/onPressed.html) callback is invoked. In that callback, add the newly composed message to the messages list and rebuild the Flutter Chat widget. {% tabs %} {% highlight dart hl_lines="55" %} @@ -321,6 +321,6 @@ class _ChatActionButtonExampleState extends State { {% endhighlight %} {% endtabs %} -![Action button chat](images/getting-started/actionbutton-chat.png) +![Action button Chat](images/getting-started/actionbutton-chat.png) ->You can refer to our [Flutter Chat](https://www.syncfusion.com/flutter-widgets/flutter-chat) feature tour page for its groundbreaking feature representations. You can also explore our [Flutter Chat example](https://flutter.syncfusion.com/#/chat/getting-started) which demonstrates conversations between two or more users in a fully customizable layout and shows how to easily configure the chat with built-in support for creating stunning visual effects. \ No newline at end of file +>You can refer to our [Flutter Chat](https://www.syncfusion.com/flutter-widgets/flutter-chat) feature tour page for its groundbreaking feature representations. You can also explore our [Flutter Chat example](https://flutter.syncfusion.com/#/chat/getting-started) which demonstrates conversations between two or more users in a fully customizable layout and shows how to easily configure the Flutter Chat widget with built-in support for creating stunning visual effects. \ No newline at end of file diff --git a/Flutter/chat/overview.md b/Flutter/chat/overview.md index 2c1ea3b01..0e652ee35 100644 --- a/Flutter/chat/overview.md +++ b/Flutter/chat/overview.md @@ -31,6 +31,6 @@ The Syncfusion® Flutter Chat widget displays conversations betwee * **Custom Message Content** - The actual message content can be customized using the [`messageContentBuilder`](https://pub.dev/documentation/syncfusion_flutter_chat/latest/chat/SfChat/messageContentBuilder.html), which lets you build a fully custom layout for each message. For customization details, refer to the [Conversation Area](conversation-area.md) documentation. -* **Message Avatar** - Displays user avatars or profile pictures of the respective message. Using the [`messageAvatarBuilder`](https://pub.dev/documentation/syncfusion_flutter_chat/latest/chat/SfChat/messageAvatarBuilder.html), a custom widget can be specified to display the chat message avatar with relevant details. +* **Message Avatar** - Displays user avatars or profile pictures of the respective message. Using the [`messageAvatarBuilder`](https://pub.dev/documentation/syncfusion_flutter_chat/latest/chat/SfChat/messageAvatarBuilder.html), a custom widget can be specified to display the message avatar of the Flutter Chat with relevant details. ->You can refer to our [Flutter Chat](https://www.syncfusion.com/flutter-widgets/flutter-chat) feature tour page for its groundbreaking feature representations. You can also explore our [Flutter Chat example](https://flutter.syncfusion.com/#/chat/getting-started) which demonstrates conversations between two or more users in a fully customizable layout and shows how to easily configure the chat with built-in support for creating stunning visual effects. \ No newline at end of file +>You can refer to our [Flutter Chat](https://www.syncfusion.com/flutter-widgets/flutter-chat) feature tour page for its groundbreaking feature representations. You can also explore our [Flutter Chat example](https://flutter.syncfusion.com/#/chat/getting-started) which demonstrates conversations between two or more users in a fully customizable layout and shows how to easily configure the Flutter Chat widget with built-in support for creating stunning visual effects. \ No newline at end of file diff --git a/Flutter/chat/placeholder.md b/Flutter/chat/placeholder.md index 59bffe841..7a464cd31 100644 --- a/Flutter/chat/placeholder.md +++ b/Flutter/chat/placeholder.md @@ -80,7 +80,7 @@ class PlaceholderExample extends StatelessWidget { ![Chat composer support](images/placeholder/placeholder-chat.gif) ->You can refer to our [Flutter Chat](https://www.syncfusion.com/flutter-widgets/flutter-chat) feature tour page for its groundbreaking feature representations. You can also explore our [Flutter Chat example](https://flutter.syncfusion.com/#/chat/getting-started) which demonstrates conversations between two or more users in a fully customizable layout and shows how to easily configure the chat with built-in support for creating stunning visual effects. +>You can refer to our [Flutter Chat](https://www.syncfusion.com/flutter-widgets/flutter-chat) feature tour page for its groundbreaking feature representations. You can also explore our [Flutter Chat example](https://flutter.syncfusion.com/#/chat/getting-started) which demonstrates conversations between two or more users in a fully customizable layout and shows how to easily configure the Flutter Chat widget with built-in support for creating stunning visual effects. #### See Also diff --git a/Flutter/chat/right-to-left.md b/Flutter/chat/right-to-left.md index 9d6f72c17..0d68df781 100644 --- a/Flutter/chat/right-to-left.md +++ b/Flutter/chat/right-to-left.md @@ -9,7 +9,7 @@ documentation: ug # Right-to-Left (RTL) in Flutter Chat (SfChat) -Chat supports right-to-left rendering for all elements in the chat widget. +Chat supports right-to-left rendering for all elements in the Flutter Chat widget. ## RTL rendering ways @@ -353,4 +353,4 @@ class RTLMessageContentExample extends StatelessWidget { ![Message Content RTL](images/rtl/message_content_rtl.png) ->You can refer to our [Flutter Chat](https://www.syncfusion.com/flutter-widgets/flutter-chat) feature tour page for its groundbreaking feature representations. You can also explore our [Flutter Chat example](https://flutter.syncfusion.com/#/chat/getting-started) which demonstrates conversations between two or more users in a fully customizable layout and shows how to easily configure the chat with built-in support for creating stunning visual effects. \ No newline at end of file +>You can refer to our [Flutter Chat](https://www.syncfusion.com/flutter-widgets/flutter-chat) feature tour page for its groundbreaking feature representations. You can also explore our [Flutter Chat example](https://flutter.syncfusion.com/#/chat/getting-started) which demonstrates conversations between two or more users in a fully customizable layout and shows how to easily configure the Flutter Chat widget with built-in support for creating stunning visual effects. \ No newline at end of file diff --git a/Flutter/linear-gauge/animation.md b/Flutter/linear-gauge/animation.md index 016d5bacb..f723cede7 100644 --- a/Flutter/linear-gauge/animation.md +++ b/Flutter/linear-gauge/animation.md @@ -44,7 +44,7 @@ class LinearGaugeDemo extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Animate axis in linear gauge](images/animation/animation-axis-range/animation-axis.gif) +![Animate axis in Flutter Linear Gauge](images/animation/animation-axis-range/animation-axis.gif) ## Animate range @@ -79,7 +79,7 @@ class LinearGaugeDemo extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Animate range in linear gauge](images/animation/animation-axis-range/animation-range.gif) +![Animate range in Flutter Linear Gauge](images/animation/animation-axis-range/animation-range.gif) ## Pointer animation @@ -182,4 +182,4 @@ class LinearGaugeDemo extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Animate marker pointer in linear gauge](images/animation/shape-pointer/bounceout.gif) +![Animate marker pointer in Flutter Linear Gauge](images/animation/shape-pointer/bounceout.gif) diff --git a/Flutter/linear-gauge/axis.md b/Flutter/linear-gauge/axis.md index e3268387c..b486851c1 100644 --- a/Flutter/linear-gauge/axis.md +++ b/Flutter/linear-gauge/axis.md @@ -41,7 +41,7 @@ class LinearGaugeDemo extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Initialize linear gauge for axis](images/getting-started/default_linear_gauge.png) +![Initialize Flutter Linear Gauge for axis](images/getting-started/default_linear_gauge.png) ## Customize minimum and maximum axis values @@ -73,7 +73,7 @@ class LinearGaugeDemo extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Update linear gauge for axis scale](images/axis/minmax_axis_linear_gauge.png) +![Update Flutter Linear Gauge for axis scale](images/axis/minmax_axis_linear_gauge.png) ## Customize axis track style @@ -104,7 +104,7 @@ The following code sample demonstrates how to customize the [`thickness`](https: {% endhighlight %} -![Change axis track thickness in linear gauge](images/axis/axis_thickness.png) +![Change axis track thickness in Flutter Linear Gauge](images/axis/axis_thickness.png) ## Apply solid color @@ -138,7 +138,7 @@ class LinearGaugeDemo extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Apply color to axis in linear gauge](images/axis/axis_solid_color.png) +![Apply color to axis in Flutter Linear Gauge](images/axis/axis_solid_color.png) ## Apply gradient @@ -182,7 +182,7 @@ class LinearGaugeDemo extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Apply color to axis in linear gauge](images/axis/axis_gradient.png) +![Apply color to axis in Flutter Linear Gauge](images/axis/axis_gradient.png) ## Customize borders @@ -268,7 +268,7 @@ class LinearGaugeDemo extends StatelessWidget { ## Inverse the axis -The direction of the linear gauge axis can be customized using the [`isAxisInversed`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/SfLinearGauge/isAxisInversed.html) property. When the [`isAxisInversed`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/SfLinearGauge/isAxisInversed.html) property is set to true, the axis will be displayed in an inverse direction. The default value is false. +The direction of the Flutter Linear Gauge axis can be customized using the [`isAxisInversed`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/SfLinearGauge/isAxisInversed.html) property. When the [`isAxisInversed`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/SfLinearGauge/isAxisInversed.html) property is set to true, the axis will be displayed in an inverse direction. The default value is false. {% tabs %} {% highlight dart %} diff --git a/Flutter/linear-gauge/bar-pointer.md b/Flutter/linear-gauge/bar-pointer.md index b934113b2..34ee0b1aa 100644 --- a/Flutter/linear-gauge/bar-pointer.md +++ b/Flutter/linear-gauge/bar-pointer.md @@ -169,7 +169,7 @@ class LinearGaugeDemo extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Customize linear gauge for bar pointer position](images/bar-pointer/bar_pointer_change_position.png) +![Customize Flutter Linear Gauge for bar pointer position](images/bar-pointer/bar_pointer_change_position.png) ## Customize the offset @@ -210,7 +210,7 @@ class LinearGaugeDemo extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Customize linear gauge bar pointer offset](images/bar-pointer/bar_pointer_offset.png) +![Customize Flutter Linear Gauge bar pointer offset](images/bar-pointer/bar_pointer_offset.png) ## Change the color of bar pointer @@ -437,7 +437,7 @@ class LinearGaugeDemo extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Customize linear gauge bar pointer border](images/bar-pointer/bar_border.png) +![Customize Flutter Linear Gauge bar pointer border](images/bar-pointer/bar_border.png) ## Add multiple bar pointers diff --git a/Flutter/linear-gauge/getting-started.md b/Flutter/linear-gauge/getting-started.md index 4ffa43245..a78641dbc 100644 --- a/Flutter/linear-gauge/getting-started.md +++ b/Flutter/linear-gauge/getting-started.md @@ -89,7 +89,7 @@ class LinearGaugeDemo extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Initialize linear gauge](images/getting-started/default_linear_gauge.png) +![Initialize Flutter Linear Gauge](images/getting-started/default_linear_gauge.png) ## Add axis @@ -121,7 +121,7 @@ class LinearGaugeDemo extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Add axis to linear gauge](images/getting-started/add_axis.png) +![Add axis to Flutter Linear Gauge](images/getting-started/add_axis.png) ## Update orientation @@ -155,7 +155,7 @@ class LinearGaugeDemo extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Update Orientation of linear gauge](images/getting-started/vertical_orientation.png) +![Update Orientation of Flutter Linear Gauge](images/getting-started/vertical_orientation.png) ## Add range @@ -194,7 +194,7 @@ class LinearGaugeDemo extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Add ranges to a linear gauge](images/getting-started/add_ranges.png) +![Add ranges to a Flutter Linear Gauge](images/getting-started/add_ranges.png) ## Add marker pointer @@ -271,7 +271,7 @@ class LinearGaugeDemo extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Add widget pointer in linear gauge](images/getting-started/add_widget_pointer.png) +![Add widget pointer in Flutter Linear Gauge](images/getting-started/add_widget_pointer.png) ## Add bar pointer @@ -362,4 +362,4 @@ class LinearGaugeDemo extends StatelessWidget { {% endhighlight %} {% endtabs %} -![A Linear gauge](images/getting-started/all_basic_elements.png) \ No newline at end of file +![A Flutter Linear Gauge](images/getting-started/all_basic_elements.png) \ No newline at end of file diff --git a/Flutter/linear-gauge/interaction.md b/Flutter/linear-gauge/interaction.md index dcc1a9719..b69014e7c 100644 --- a/Flutter/linear-gauge/interaction.md +++ b/Flutter/linear-gauge/interaction.md @@ -196,4 +196,4 @@ class _LinearGaugeDemoState extends State { {% endhighlight %} {% endtabs %} -![Shape pointer interaction in linear gauge](images/interaction/interaction.gif) \ No newline at end of file +![Shape pointer interaction in Flutter Linear Gauge](images/interaction/interaction.gif) \ No newline at end of file diff --git a/Flutter/linear-gauge/labels.md b/Flutter/linear-gauge/labels.md index dd842dcf4..d43e1e202 100644 --- a/Flutter/linear-gauge/labels.md +++ b/Flutter/linear-gauge/labels.md @@ -11,7 +11,7 @@ documentation: ug The default style of axis labels is as follows. -![Initialize linear gauge for axis](images/getting-started/default_linear_gauge.png) +![Initialize Flutter Linear Gauge for axis](images/getting-started/default_linear_gauge.png) ## Customize label styles @@ -57,7 +57,7 @@ class LinearGaugeDemo extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Customize linear gauge axis label style](images/axis-labels/customize_label_style.png) +![Customize Flutter Linear Gauge axis label style](images/axis-labels/customize_label_style.png) ## Change visibility @@ -158,7 +158,7 @@ class LinearGaugeDemo extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Set linear gauge label position](images/axis-labels/label-placement.png) +![Set Flutter Linear Gauge label position](images/axis-labels/label-placement.png) ## Change label offset @@ -193,7 +193,7 @@ class LinearGaugeDemo extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Set linear gauge label offset](images/axis-labels/label_offset.png) +![Set Flutter Linear Gauge label offset](images/axis-labels/label_offset.png) ## Customize maximum number of visible labels diff --git a/Flutter/linear-gauge/mirror-linear-gauge.md b/Flutter/linear-gauge/mirror-linear-gauge.md index 825d2f5f8..c174e5778 100644 --- a/Flutter/linear-gauge/mirror-linear-gauge.md +++ b/Flutter/linear-gauge/mirror-linear-gauge.md @@ -39,10 +39,10 @@ class LinearGaugeDemo extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Mirror linear gauge](images/mirrored/mirrored.png) +![Mirror Flutter Linear Gauge](images/mirrored/mirrored.png) ## Comparison for the mirrored and normal gauge The following screenshot provides a visual comparison between a mirrored Linear Gauge and a normal Linear Gauge. -![Mirrored linear gauge comparsion](images/mirrored/mirror_comparison.png) \ No newline at end of file +![Mirrored Flutter Linear Gauge comparsion](images/mirrored/mirror_comparison.png) \ No newline at end of file diff --git a/Flutter/linear-gauge/overview.md b/Flutter/linear-gauge/overview.md index b3b47b7a3..0b5fa83b6 100644 --- a/Flutter/linear-gauge/overview.md +++ b/Flutter/linear-gauge/overview.md @@ -11,7 +11,7 @@ documentation: ug Syncfusion® Flutter Linear Gauge is a powerful data visualization widget designed to display data on a linear scale. It's an ideal component for crafting high-quality mobile application user interfaces that require visual representation of data along a linear axis. -![Overview flutter linear gauge](images/basic_elements.png) +![Overview Flutter Linear Gauge](images/basic_elements.png) ## Key Features diff --git a/Flutter/linear-gauge/range.md b/Flutter/linear-gauge/range.md index 461b0600b..1a128cdbf 100644 --- a/Flutter/linear-gauge/range.md +++ b/Flutter/linear-gauge/range.md @@ -9,7 +9,7 @@ documentation: ug # Ranges in Flutter Linear Gauge (SfLinearGauge) -A range is a visual element that helps you quickly visualize where a range falls on the axis track. Multiple ranges with different styles can be added to a linear gauge. The default style of range will be as below. +A range is a visual element that helps you quickly visualize where a range falls on the axis track. Multiple ranges with different styles can be added to a Flutter Linear Gauge. The default style of range will be as below. {% tabs %} {% highlight dart %} @@ -44,7 +44,7 @@ class LinearGaugeDemo extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Initialize linear gauge for range](images/gauge-range/default-range.png) +![Initialize Flutter Linear Gauge for range](images/gauge-range/default-range.png) ## Customize range shape @@ -91,7 +91,7 @@ class LinearGaugeDemo extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Draw linear gauge concave range](images/gauge-range/range-concave.png) +![Draw Flutter Linear Gauge concave range](images/gauge-range/range-concave.png) ## Customize edge style @@ -177,7 +177,7 @@ class LinearGaugeDemo extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Set linear gauge range color](images/gauge-range/color_range.png) +![Set Flutter Linear Gauge range color](images/gauge-range/color_range.png) ## Apply radial gradient to a range @@ -318,7 +318,7 @@ class LinearGaugeDemo extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Apply sweep gradient to linear gauge range](images/gauge-range/sweep_gradient_range.png) +![Apply sweep gradient to Flutter Linear Gauge range](images/gauge-range/sweep_gradient_range.png) ## Customize range position @@ -356,7 +356,7 @@ class LinearGaugeDemo extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Position the linear gauge range](images/gauge-range/range_position.png) +![Position the Flutter Linear Gauge range](images/gauge-range/range_position.png) ## Setting range color to axis element @@ -462,4 +462,4 @@ class LinearGaugeDemo extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Add multiple ranges in a linear gauge](images/gauge-range/multiple_ranges.png) \ No newline at end of file +![Add multiple ranges in a Flutter Linear Gauge](images/gauge-range/multiple_ranges.png) \ No newline at end of file diff --git a/Flutter/linear-gauge/shape-marker-pointer.md b/Flutter/linear-gauge/shape-marker-pointer.md index 9b698bf18..e3e39f301 100644 --- a/Flutter/linear-gauge/shape-marker-pointer.md +++ b/Flutter/linear-gauge/shape-marker-pointer.md @@ -47,7 +47,7 @@ class LinearGaugeDemo extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Initialize linear gauge for shape pointer](images/shape-pointer/default_shape_pointer.png) +![Initialize Flutter Linear Gauge for shape pointer](images/shape-pointer/default_shape_pointer.png) ## Change the size @@ -82,7 +82,7 @@ class LinearGaugeDemo extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Set size of linear gauge shape pointer](images/shape-pointer/shape_pointer_size.png) +![Set size of Flutter Linear Gauge shape pointer](images/shape-pointer/shape_pointer_size.png) ## Customize color @@ -319,7 +319,7 @@ class LinearGaugeDemo extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Customize linear gauge bar pointer offset](images/shape-pointer/shape_pointer_offset.png) +![Customize Flutter Linear Gauge bar pointer offset](images/shape-pointer/shape_pointer_offset.png) ## Drag behavior diff --git a/Flutter/linear-gauge/ticks.md b/Flutter/linear-gauge/ticks.md index 1b639c4af..fae95ae0e 100644 --- a/Flutter/linear-gauge/ticks.md +++ b/Flutter/linear-gauge/ticks.md @@ -11,7 +11,7 @@ documentation: ug The default style of axis ticks is as follows. -![Initialize linear gauge for axis](images/getting-started/default_linear_gauge.png) +![Initialize Flutter Linear Gauge for axis](images/getting-started/default_linear_gauge.png) ## Customize tick style @@ -47,7 +47,7 @@ class LinearGaugeDemo extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Customize the linear gauge axis tick style](images/axis-ticks/axis-tick-style.png) +![Customize the Flutter Linear Gauge axis tick style](images/axis-ticks/axis-tick-style.png) ## Customize minor tick interval @@ -77,7 +77,7 @@ class LinearGaugeDemo extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Customize linear gauge ticks per interval](images/axis-ticks/minor-ticks-per-interval.png) +![Customize Flutter Linear Gauge ticks per interval](images/axis-ticks/minor-ticks-per-interval.png) ## Change tick visibility @@ -109,7 +109,7 @@ class LinearGaugeDemo extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Customize linear gauge ticks visibility](images/axis-ticks/linear-gauge-tick-visibility.png) +![Customize Linear Gauge ticks visibility](images/axis-ticks/linear-gauge-tick-visibility.png) ## Customize tick position @@ -173,5 +173,5 @@ class LinearGaugeDemo extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Customize linear gauge ticks offset from axis](images/axis-ticks/customize-tick-offset.png) +![Customize Flutter Linear Gauge ticks offset from axis](images/axis-ticks/customize-tick-offset.png) diff --git a/Flutter/linear-gauge/widget-marker-pointer.md b/Flutter/linear-gauge/widget-marker-pointer.md index 2f9abf2e5..84092bca3 100644 --- a/Flutter/linear-gauge/widget-marker-pointer.md +++ b/Flutter/linear-gauge/widget-marker-pointer.md @@ -42,7 +42,7 @@ class LinearGaugeDemo extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Initialize linear gauge for widget pointer](images/widget-pointer/default_widget_pointer.png) +![Initialize Flutter Linear Gauge for widget pointer](images/widget-pointer/default_widget_pointer.png) ## Change marker alignment @@ -166,7 +166,7 @@ class LinearGaugeDemo extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Customize linear gauge bar pointer offset](images/widget-pointer/widget_pointer_offset.png) +![Customize Flutter Linear Gauge bar pointer offset](images/widget-pointer/widget_pointer_offset.png) ## Drag behavior diff --git a/Flutter/maps/data-labels.md b/Flutter/maps/data-labels.md index d80bb3cab..4e3e4ac9d 100644 --- a/Flutter/maps/data-labels.md +++ b/Flutter/maps/data-labels.md @@ -1,379 +1,379 @@ ---- -layout: post -title: Data Labels in Flutter Maps | Syncfusion® -description: Learn about data labels in Syncfusion® Flutter Maps (SfMaps), including shape labeling, customization options, text styling, and placement. -platform: flutter -control: SfMaps -documentation: ug ---- - -# Data Labels in Flutter Maps (SfMaps) - -Data labels provide identification for the shapes by displaying their names. You can trim or hide the labels if they exceed the shape bounds. - -## Show data labels - -You can show data labels on the map using the [`MapShapeLayer.showDataLabels`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/showDataLabels.html) property. By default, the data labels are rendered based on the value of [`shapeDataField`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeDataField.html) property. The default value of the [`showDataLabels`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/showDataLabels.html) property is `false`. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late MapShapeSource dataSource; - - @override - void initState() { - dataSource = MapShapeSource.asset( - "assets/world_map.json", - shapeDataField: "continent", - ); - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: Padding( - padding: EdgeInsets.only(left: 15, right: 15), - child: SfMaps( - layers: [ - MapShapeLayer( - source: dataSource, - showDataLabels: true, - ), - ], - ), - ), - ), - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Data labels support](images/data-labels/default-data-labels.png) - -## Text customization - -You can customize text of the data labels using the [`MapShapeSource.dataLabelMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/dataLabelMapper.html) property. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late List data; - late MapShapeSource dataSource; - - @override - void initState() { - super.initState(); - data = const [ - Model('Asia', 'Asia'), - Model('Europe', 'EU'), - Model('North America', 'NA'), - Model('South America', 'SA'), - Model('Australia', 'Australia'), - Model('Africa', 'Africa') - ]; - - dataSource = MapShapeSource.asset( - "assets/world_map.json", - shapeDataField: "continent", - dataCount: data.length, - primaryValueMapper: (int index) => data[index].continent, - dataLabelMapper: (int index) => data[index].code, - ); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: Padding( - padding: EdgeInsets.only(left: 15, right: 15), - child: SfMaps( - layers: [ - MapShapeLayer( - source: dataSource, - showDataLabels: true, - ), - ], - ), - ), - ), - ); - } -} - -class Model { - const Model(this.continent, this.code); - - final String continent; - final String code; -} - -{% endhighlight %} -{% endtabs %} - -![Data labels support](images/data-labels/data-labels-customization.png) - -## Overflow mode - -You can trim or remove the data label when it is overflowed from the shape using the [`MapDataLabelSettings.overflowMode`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapDataLabelSettings/overflowMode.html) property. The possible values are [`visible`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLabelOverflow.html#visible), [`ellipsis`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLabelOverflow.html#ellipsis), and [`hide`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLabelOverflow.html#hide). The default value of the [`overflowMode`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapDataLabelSettings/overflowMode.html) property is [`MapLabelOverflow.visible`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLabelOverflow.html#visible). - -By default, the data labels will render even if they overflow from the shape. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late List data; - late MapShapeSource dataSource; - - @override - void initState() { - data = [ - Model('New South Wales', 'New South Wales'), - Model('Queensland', 'Queensland'), - Model('Northern Territory', 'Northern Territory'), - Model('Victoria', 'Victoria'), - Model('South Australia', 'South Australia'), - Model('Western Australia', 'Western Australia'), - Model('Tasmania', 'Tasmania'), - ]; - - dataSource = MapShapeSource.asset( - 'assets/australia.json', - shapeDataField: 'STATE_NAME', - dataCount: data.length, - primaryValueMapper: (int index) => data[index].state, - dataLabelMapper: (int index) => data[index].dataLabel, - ); - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: Padding( - padding: EdgeInsets.only(left: 15, right: 15), - child: SfMaps( - layers: [ - MapShapeLayer( - source: dataSource, - showDataLabels: true, - dataLabelSettings: MapDataLabelSettings( - overflowMode: MapLabelOverflow.ellipsis, - ), - ), - ], - ), - ), - ), - ); - } -} - -class Model { - Model(this.state, this.dataLabel); - - String state; - String dataLabel; -} - -{% endhighlight %} -{% endtabs %} - -![Data labels trim support](images/data-labels/data-labels-overflow-mode.png) - -## Appearance customization - -You can customize the data labels using the [`MapDataLabelSettings.textStyle`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapDataLabelSettings/textStyle.html) property. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late List data; - late MapShapeSource dataSource; - - @override - void initState() { - data = [ - Model('New South Wales', 'New South Wales'), - Model('Queensland', 'Queensland'), - Model('Northern Territory', 'Northern Territory'), - Model('Victoria', 'Victoria'), - Model('South Australia', 'South Australia'), - Model('Western Australia', 'Western Australia'), - Model('Tasmania', 'Tasmania'), - ]; - - dataSource = MapShapeSource.asset( - 'assets/australia.json', - shapeDataField: 'STATE_NAME', - dataCount: data.length, - primaryValueMapper: (int index) => data[index].state, - dataLabelMapper: (int index) => data[index].dataLabel, - ); - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: Padding( - padding: EdgeInsets.only(left: 15, right: 15), - child: SfMaps( - layers: [ - MapShapeLayer( - source: dataSource, - showDataLabels: true, - dataLabelSettings: MapDataLabelSettings( - textStyle: const TextStyle( - color: Colors.red, - fontSize: 12, - fontWeight: FontWeight.bold, - fontStyle: FontStyle.italic, - fontFamily: 'Times'), - ), - ), - ], - ), - ), - ), - ); - } -} - -class Model { - Model(this.state, this.dataLabel); - - String state; - String dataLabel; -} - -{% endhighlight %} -{% endtabs %} - -Using SfMapsTheme - -You can also customize the data labels using the [`SfMapsThemeData.dataLabelTextStyle`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsThemeData/dataLabelTextStyle.html) property in [`SfMapsTheme`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsTheme-class.html). - -N> You must import the `theme.dart` library from the [`Core`](https://pub.dev/packages/syncfusion_flutter_core) package to use [`SfMapsTheme`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsTheme-class.html). - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late List data; - late MapShapeSource dataSource; - - @override - void initState() { - data = [ - Model('New South Wales', 'New South Wales'), - Model('Queensland', 'Queensland'), - Model('Northern Territory', 'Northern Territory'), - Model('Victoria', 'Victoria'), - Model('South Australia', 'South Australia'), - Model('Western Australia', 'Western Australia'), - Model('Tasmania', 'Tasmania'), - ]; - - dataSource = MapShapeSource.asset( - 'assets/australia.json', - shapeDataField: 'STATE_NAME', - dataCount: data.length, - primaryValueMapper: (int index) => data[index].state, - dataLabelMapper: (int index) => data[index].dataLabel, - ); - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: Padding( - padding: EdgeInsets.only(left: 15, right: 15), - child: SfMapsTheme( - data: SfMapsThemeData( - dataLabelTextStyle: TextStyle( - color: Colors.red, - fontSize: 12, - fontWeight: FontWeight.bold, - fontStyle: FontStyle.italic, - fontFamily: 'Times'), - ), - child: SfMaps( - layers: [ - MapShapeLayer( - source: dataSource, - showDataLabels: true, - ), - ], - ), - ), - ), - ), - ); - } -} - -class Model { - Model(this.state, this.dataLabel); - - String state; - String dataLabel; -} - -{% endhighlight %} -{% endtabs %} - -![Data labels customization](images/data-labels/data-labels-appearance-customization.png) +--- +layout: post +title: Data Labels in Flutter Maps | Syncfusion® +description: Learn about data labels in Syncfusion® Flutter Maps (SfMaps), including shape labeling, customization options, text styling, and placement. +platform: flutter +control: SfMaps +documentation: ug +--- + +# Data Labels in Flutter Maps (SfMaps) + +Data labels provide identification for the shapes by displaying their names. You can trim or hide the labels if they exceed the shape bounds. + +## Show data labels + +You can show data labels on the Flutter Maps using the [`MapShapeLayer.showDataLabels`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/showDataLabels.html) property. By default, the data labels are rendered based on the value of [`shapeDataField`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeDataField.html) property. The default value of the [`showDataLabels`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/showDataLabels.html) property is `false`. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late MapShapeSource dataSource; + + @override + void initState() { + dataSource = MapShapeSource.asset( + "assets/world_map.json", + shapeDataField: "continent", + ); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Padding( + padding: EdgeInsets.only(left: 15, right: 15), + child: SfMaps( + layers: [ + MapShapeLayer( + source: dataSource, + showDataLabels: true, + ), + ], + ), + ), + ), + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Data labels support](images/data-labels/default-data-labels.png) + +## Text customization + +You can customize text of the data labels using the [`MapShapeSource.dataLabelMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/dataLabelMapper.html) property. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late List data; + late MapShapeSource dataSource; + + @override + void initState() { + super.initState(); + data = const [ + Model('Asia', 'Asia'), + Model('Europe', 'EU'), + Model('North America', 'NA'), + Model('South America', 'SA'), + Model('Australia', 'Australia'), + Model('Africa', 'Africa') + ]; + + dataSource = MapShapeSource.asset( + "assets/world_map.json", + shapeDataField: "continent", + dataCount: data.length, + primaryValueMapper: (int index) => data[index].continent, + dataLabelMapper: (int index) => data[index].code, + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Padding( + padding: EdgeInsets.only(left: 15, right: 15), + child: SfMaps( + layers: [ + MapShapeLayer( + source: dataSource, + showDataLabels: true, + ), + ], + ), + ), + ), + ); + } +} + +class Model { + const Model(this.continent, this.code); + + final String continent; + final String code; +} + +{% endhighlight %} +{% endtabs %} + +![Data labels support](images/data-labels/data-labels-customization.png) + +## Overflow mode + +You can trim or remove the data label when it is overflowed from the shape using the [`MapDataLabelSettings.overflowMode`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapDataLabelSettings/overflowMode.html) property. The possible values are [`visible`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLabelOverflow.html#visible), [`ellipsis`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLabelOverflow.html#ellipsis), and [`hide`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLabelOverflow.html#hide). The default value of the [`overflowMode`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapDataLabelSettings/overflowMode.html) property is [`MapLabelOverflow.visible`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLabelOverflow.html#visible). + +By default, the data labels will render even if they overflow from the shape. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late List data; + late MapShapeSource dataSource; + + @override + void initState() { + data = [ + Model('New South Wales', 'New South Wales'), + Model('Queensland', 'Queensland'), + Model('Northern Territory', 'Northern Territory'), + Model('Victoria', 'Victoria'), + Model('South Australia', 'South Australia'), + Model('Western Australia', 'Western Australia'), + Model('Tasmania', 'Tasmania'), + ]; + + dataSource = MapShapeSource.asset( + 'assets/australia.json', + shapeDataField: 'STATE_NAME', + dataCount: data.length, + primaryValueMapper: (int index) => data[index].state, + dataLabelMapper: (int index) => data[index].dataLabel, + ); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Padding( + padding: EdgeInsets.only(left: 15, right: 15), + child: SfMaps( + layers: [ + MapShapeLayer( + source: dataSource, + showDataLabels: true, + dataLabelSettings: MapDataLabelSettings( + overflowMode: MapLabelOverflow.ellipsis, + ), + ), + ], + ), + ), + ), + ); + } +} + +class Model { + Model(this.state, this.dataLabel); + + String state; + String dataLabel; +} + +{% endhighlight %} +{% endtabs %} + +![Data labels trim support](images/data-labels/data-labels-overflow-mode.png) + +## Appearance customization + +You can customize the data labels using the [`MapDataLabelSettings.textStyle`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapDataLabelSettings/textStyle.html) property. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late List data; + late MapShapeSource dataSource; + + @override + void initState() { + data = [ + Model('New South Wales', 'New South Wales'), + Model('Queensland', 'Queensland'), + Model('Northern Territory', 'Northern Territory'), + Model('Victoria', 'Victoria'), + Model('South Australia', 'South Australia'), + Model('Western Australia', 'Western Australia'), + Model('Tasmania', 'Tasmania'), + ]; + + dataSource = MapShapeSource.asset( + 'assets/australia.json', + shapeDataField: 'STATE_NAME', + dataCount: data.length, + primaryValueMapper: (int index) => data[index].state, + dataLabelMapper: (int index) => data[index].dataLabel, + ); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Padding( + padding: EdgeInsets.only(left: 15, right: 15), + child: SfMaps( + layers: [ + MapShapeLayer( + source: dataSource, + showDataLabels: true, + dataLabelSettings: MapDataLabelSettings( + textStyle: const TextStyle( + color: Colors.red, + fontSize: 12, + fontWeight: FontWeight.bold, + fontStyle: FontStyle.italic, + fontFamily: 'Times'), + ), + ), + ], + ), + ), + ), + ); + } +} + +class Model { + Model(this.state, this.dataLabel); + + String state; + String dataLabel; +} + +{% endhighlight %} +{% endtabs %} + +Using SfMapsTheme + +You can also customize the data labels using the [`SfMapsThemeData.dataLabelTextStyle`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsThemeData/dataLabelTextStyle.html) property in [`SfMapsTheme`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsTheme-class.html). + +N> You must import the `theme.dart` library from the [`Core`](https://pub.dev/packages/syncfusion_flutter_core) package to use [`SfMapsTheme`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsTheme-class.html). + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late List data; + late MapShapeSource dataSource; + + @override + void initState() { + data = [ + Model('New South Wales', 'New South Wales'), + Model('Queensland', 'Queensland'), + Model('Northern Territory', 'Northern Territory'), + Model('Victoria', 'Victoria'), + Model('South Australia', 'South Australia'), + Model('Western Australia', 'Western Australia'), + Model('Tasmania', 'Tasmania'), + ]; + + dataSource = MapShapeSource.asset( + 'assets/australia.json', + shapeDataField: 'STATE_NAME', + dataCount: data.length, + primaryValueMapper: (int index) => data[index].state, + dataLabelMapper: (int index) => data[index].dataLabel, + ); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Padding( + padding: EdgeInsets.only(left: 15, right: 15), + child: SfMapsTheme( + data: SfMapsThemeData( + dataLabelTextStyle: TextStyle( + color: Colors.red, + fontSize: 12, + fontWeight: FontWeight.bold, + fontStyle: FontStyle.italic, + fontFamily: 'Times'), + ), + child: SfMaps( + layers: [ + MapShapeLayer( + source: dataSource, + showDataLabels: true, + ), + ], + ), + ), + ), + ), + ); + } +} + +class Model { + Model(this.state, this.dataLabel); + + String state; + String dataLabel; +} + +{% endhighlight %} +{% endtabs %} + +![Data labels customization](images/data-labels/data-labels-appearance-customization.png) diff --git a/Flutter/maps/getting-started.md b/Flutter/maps/getting-started.md index 39ef7c6fb..f9f839a3b 100644 --- a/Flutter/maps/getting-started.md +++ b/Flutter/maps/getting-started.md @@ -1,464 +1,464 @@ ---- -layout: post -title: Getting Started with Flutter Maps | Syncfusion® -description: Learn how to get started with the Syncfusion® Flutter Maps (SfMaps). Explore map visualization, data binding, layers, and customization options. -platform: flutter -control: SfMaps -documentation: ug ---- - -# Getting Started with Flutter Maps (SfMaps) - -This section explains the steps required to add the maps widget with shape layer and its elements such as data labels, tooltip, assignable colors based on region, and legends. It also explains about adding tile layer with OpenStreetMap. This section covers only basic features needed to know to get started with Syncfusion® maps. - -To get started quickly with our Flutter Maps widget, you can check on this video. - - - - -## Add Flutter maps to an application - -Create a simple project using the instructions given in the [Getting Started with your first Flutter app](https://docs.flutter.dev/get-started/test-drive#choose-your-ide) documentation. - -**Add dependency** - -Add the Syncfusion® Flutter maps dependency to your pubspec.yaml file. - -{% tabs %} -{% highlight dart %} - -dependencies: - -syncfusion_flutter_maps: ^xx.x.xx - -{% endhighlight %} -{% endtabs %} - -N> Here **xx.x.xx** denotes the current version of [`Syncfusion Flutter Maps`](https://pub.dev/packages/syncfusion_flutter_maps/versions) package. It is recommended to use the latest available version from pub.dev. - -**Get packages** - -Run the following command to get the required packages. - -{% tabs %} -{% highlight dart %} - -$ flutter pub get - -{% endhighlight %} -{% endtabs %} - -**Import package** - -Import the following package in your Dart code. - -{% tabs %} -{% highlight Dart %} - -import 'package:syncfusion_flutter_maps/maps.dart'; - -{% endhighlight %} -{% endtabs %} - -## Initialize maps - -After importing the package, initialize the maps widget as a child of any widget. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatelessWidget { - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: SfMaps( - layers: [ - MapShapeLayer( - source: MapShapeSource.asset( - 'assets/australia.json', - shapeDataField: 'STATE_NAME', - ), - ), - ], - ), - ), - ); - } -} - -{% endhighlight %} -{% endtabs %} - -## Set GeoJSON data for shape layer from various sources - -The [`layers`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/SfMaps/layers.html) in [`SfMaps`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/SfMaps-class.html) contains collection of either [`MapShapeLayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer-class.html) or [`MapTileLayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTileLayer-class.html). The actual geographical rendering is done in each [`MapShapeLayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer-class.html). The [`source`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/source.html) property of the [`MapShapeLayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer-class.html) is of type [`MapShapeSource`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource-class.html). The [`source`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/source.html) can be set as the .json source from an asset bundle, from network or from Uint8List as bytes. Use the respective constructor depending on the source type. - -The [`shapeDataField`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeDataField.html) property of the [`MapShapeSource`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource-class.html) is used to refer to the unique field name in the .json source to identify each shape. In [`Mapping the data source`](https://help.syncfusion.com/flutter/maps/getting-started#mapping-the-data-source-for-shape-layer) section of this document, this [`shapeDataField`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeDataField.html) will be used to map with the respective value returned in [`primaryValueMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/primaryValueMapper.html) from the data source. - -I> The Mercator projection is the default projection in the maps. - -### From asset bundle - -Load .json data from an asset bundle. - -N> If you are using the [`MapShapeSource.asset`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/MapShapeSource.asset.html) constructor, you must add the .json file to the assets folder of your root directory and refer the json file path in the `pubspec.yaml` file as shown in the code snippet below. You can get the [`australia.json`](https://www.syncfusion.com/downloads/support/directtrac/general/ze/australia-json-910278184.zip) file here. - -{% tabs %} -{% highlight Dart %} - -flutter: - uses-material-design: true - assets: - - australia.json - -{% endhighlight %} -{% endtabs %} - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late MapShapeSource _dataSource; - - @override - void initState() { - _dataSource = MapShapeSource.asset( - 'assets/australia.json', - shapeDataField: 'STATE_NAME', - ); - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Padding( - padding: EdgeInsets.all(15), - child: SfMaps( - layers: [ - MapShapeLayer(source: _dataSource), - ], - ), - ), - ); - } -} - -{% endhighlight %} -{% endtabs %} - -### From network - -Load .json data from the network. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late MapShapeSource _dataSource; - - @override - void initState() { - _dataSource = MapShapeSource.network( - 'http://www.json-generator.com/api/json/get/bVqXoJvfjC?indent=2', - shapeDataField: 'name', - ); - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Padding( - padding: EdgeInsets.all(15), - child: SfMaps( - layers: [ - MapShapeLayer(source: _dataSource), - ], - ), - ), - ); - } -} - -{% endhighlight %} -{% endtabs %} - -### From memory - -Load .json data as bytes from `Uint8List`. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; -import 'dart:typed_data'; - -class MapsExample extends StatelessWidget { - @override - Widget build(BuildContext context) { - return Scaffold( - body: FutureBuilder( - future: _fetchJsonData(), - builder: (BuildContext context, snapshot) { - if (snapshot.hasData) { - Uint8List bytesData = snapshot.data as Uint8List; - return SfMaps( - layers: [ - MapShapeLayer( - source: MapShapeSource.memory( - bytesData, - shapeDataField: 'STATE_NAME', - ), - ), - ], - ); - } else { - return CircularProgressIndicator(); - } - }, - ), - ); - } - - Future _fetchJsonData() async { - return (await rootBundle.load('assets/australia.json')).buffer.asUint8List(); - } -} - -{% endhighlight %} -{% endtabs %} - -![maps basic view](images/getting-started/map_basic_view.png) - -## Mapping the data source for shape layer - -By default, the value specified for the [`shapeDataField`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeDataField.html) in the GeoJSON source will be used in the elements like data labels, tooltip, and legend for their respective shapes. However, it is possible to keep a data source and customize these elements based on the requirement. As mentioned above, [`shapeDataField`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeDataField.html) will be used to map with the respective value returned in [`primaryValueMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/primaryValueMapper.html) from the data source. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late List data; - - @override - void initState() { - data = [ - Model('New South Wales', - ' New\nSouth Wales'), - Model('Queensland', 'Queensland'), - Model('Northern Territory', 'Northern\nTerritory'), - Model('Victoria', 'Victoria'), - Model('South Australia', 'South Australia'), - Model('Western Australia', 'Western Australia'), - Model('Tasmania', 'Tasmania'), - Model('Australian Capital Territory', 'ACT') - ]; - - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: SfMaps( - layers: [ - MapShapeLayer( - source: MapShapeSource.asset( - 'assets/australia.json', - shapeDataField: 'STATE_NAME', - dataCount: data.length, - primaryValueMapper: (int index) => data[index].state, - ), - ), - ], - ), - ); - } -} - -class Model { - Model(this.state, this.stateCode); - - String state; - String stateCode; -} - -{% endhighlight %} -{% endtabs %} - -N> -* Refer the [`MapShapeSource.primaryValueMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/primaryValueMapper.html), for mapping the data of the data source collection with the respective [`MapShapeSource.shapeDataField`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeDataField.html) in .json source. -* Refer the [`MapShapeSource.bubbleSizeMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/bubbleSizeMapper.html), for customizing the bubble size. -* Refer the [`MapShapeSource.bubbleColorValueMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/bubbleColorValueMapper.html), for customizing the bubble colors. -* Refer the [`MapShapeSource.dataLabelMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/dataLabelMapper.html), for customizing the data label text. -* Refer the [`MapShapeSource.shapeColorValueMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeColorValueMapper.html), for customizing the shape colors. - -## Add shape layer maps elements - -Add the basic maps elements such as data labels, legend, and tooltip as shown in the code snippet below. - -* **Data labels** - You can show data labels using the [`MapShapeLayer.showDataLabels`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/showDataLabels.html) property. It is also possible to show data labels only for the particular shapes or show custom text using the [`MapShapeSource.dataLabelMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/dataLabelMapper.html) property. - -* **Legend** - You can enable legend using the [`MapShapeLayer.legend`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/legend.html) property. The icons color of the legend is applied based on the colors returned in the [`MapShapeSource.shapeColorValueMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeColorValueMapper.html) property. It is possible to customize the legend icons color and texts using the [`MapShapeSource.shapeColorMappers`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeColorMappers.html) property. - -* **Tooltip** - You can enable tooltip for the shapes using the [`MapShapeLayer.shapeTooltipBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/shapeTooltipBuilder.html) property. It will be called with the corresponding index every time when you interact with the shapes i.e., while tapping in touch devices and hover enter in mouse enabled devices. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late List data; - late MapShapeSource dataSource; - - @override - void initState() { - data = [ - Model('New South Wales', Color.fromRGBO(255, 215, 0, 1.0), - ' New\nSouth Wales'), - Model('Queensland', Color.fromRGBO(72, 209, 204, 1.0), 'Queensland'), - Model('Northern Territory', Colors.red.withOpacity(0.85), - 'Northern\nTerritory'), - Model('Victoria', Color.fromRGBO(171, 56, 224, 0.75), 'Victoria'), - Model('South Australia', Color.fromRGBO(126, 247, 74, 0.75), - 'South Australia'), - Model('Western Australia', Color.fromRGBO(79, 60, 201, 0.7), - 'Western Australia'), - Model('Tasmania', Color.fromRGBO(99, 164, 230, 1), 'Tasmania'), - Model('Australian Capital Territory', Colors.teal, 'ACT') - ]; - - dataSource = MapShapeSource.asset( - 'assets/australia.json', - shapeDataField: 'STATE_NAME', - dataCount: data.length, - primaryValueMapper: (int index) => data[index].state, - dataLabelMapper: (int index) => data[index].stateCode, - shapeColorValueMapper: (int index) => data[index].color, - ); - super.initState(); - } - - @override - Widget build(BuildContext context) { - final ThemeData themeData = Theme.of(context); - return Scaffold( - body: Center( - child: SizedBox( - height: MediaQuery.of(context).size.height * 0.55, - child: SfMaps( - layers: [ - MapShapeLayer( - source: dataSource, - showDataLabels: true, - legend: MapLegend(MapElement.shape), - shapeTooltipBuilder: (BuildContext context, int index) { - return Padding( - padding: const EdgeInsets.all(7), - child: Text(data[index].stateCode, - style: themeData.textTheme.labelSmall! - .copyWith(color: themeData.colorScheme.surface)), - ); - }, - tooltipSettings: MapTooltipSettings( - color: Colors.grey[700], - strokeColor: Colors.white, - strokeWidth: 2), - strokeColor: Colors.white, - strokeWidth: 0.5, - dataLabelSettings: MapDataLabelSettings( - textStyle: TextStyle( - color: Colors.black, - fontWeight: FontWeight.bold, - fontSize: themeData.textTheme.labelSmall!.fontSize)), - ), - ], - ), - ), - ), - ); - } -} - -class Model { - Model(this.state, this.color, this.stateCode); - - String state; - Color color; - String stateCode; -} - -{% endhighlight %} -{% endtabs %} - -![Maps getting started](images/getting-started/maps_getting_started.png) - -## Add tile layer - -The [`MapTileLayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTileLayer-class.html) needs to be added in the [`layers`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/SfMaps/layers.html) collection in [`SfMaps`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/SfMaps-class.html). The URL of the providers must be set in the [`MapTileLayer.urlTemplate`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTileLayer/urlTemplate.html) property. - -Refer to the [tile layer](https://help.syncfusion.com/flutter/maps/tile-layer#setting-url-template) section for more information. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatelessWidget { - @override - Widget build(BuildContext context) { - return SfMaps( - layers: [ - MapTileLayer( - urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', - ), - ], - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Maps tile layer getting started](images/getting-started/getting_started_tile_layer.png) - -N> You can refer to our [Flutter Maps](https://www.syncfusion.com/flutter-widgets/flutter-maps) feature tour page for its groundbreaking feature representations. You can also explore our [Flutter Maps example](https://flutter.syncfusion.com/#/maps/shape-layer/range-color-mapping) that shows how to configure a Maps in Flutter. +--- +layout: post +title: Getting Started with Flutter Maps | Syncfusion® +description: Learn how to get started with the Syncfusion® Flutter Maps (SfMaps). Explore map visualization, data binding, layers, and customization options. +platform: flutter +control: SfMaps +documentation: ug +--- + +# Getting Started with Flutter Maps (SfMaps) + +This section explains the steps required to add the Flutter Maps widget with shape layer and its elements such as data labels, tooltip, assignable colors based on region, and legends. It also explains about adding tile layer with OpenStreetMap. This section covers only basic features needed to know to get started with Syncfusion® Flutter Maps. + +To get started quickly with our Flutter Maps widget, you can check on this video. + + + + +## Add Flutter Maps to an application + +Create a simple project using the instructions given in the [Getting Started with your first Flutter app](https://docs.flutter.dev/get-started/test-drive#choose-your-ide) documentation. + +**Add dependency** + +Add the Syncfusion® Flutter Maps dependency to your pubspec.yaml file. + +{% tabs %} +{% highlight dart %} + +dependencies: + +syncfusion_flutter_maps: ^xx.x.xx + +{% endhighlight %} +{% endtabs %} + +N> Here **xx.x.xx** denotes the current version of [`Syncfusion Flutter Maps`](https://pub.dev/packages/syncfusion_flutter_maps/versions) package. It is recommended to use the latest available version from pub.dev. + +**Get packages** + +Run the following command to get the required packages. + +{% tabs %} +{% highlight dart %} + +$ flutter pub get + +{% endhighlight %} +{% endtabs %} + +**Import package** + +Import the following package in your Dart code. + +{% tabs %} +{% highlight Dart %} + +import 'package:syncfusion_flutter_maps/maps.dart'; + +{% endhighlight %} +{% endtabs %} + +## Initialize Maps + +After importing the package, initialize the Flutter Maps widget as a child of any widget. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: SfMaps( + layers: [ + MapShapeLayer( + source: MapShapeSource.asset( + 'assets/australia.json', + shapeDataField: 'STATE_NAME', + ), + ), + ], + ), + ), + ); + } +} + +{% endhighlight %} +{% endtabs %} + +## Set GeoJSON data for shape layer from various sources + +The [`layers`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/SfMaps/layers.html) in [`SfMaps`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/SfMaps-class.html) contains collection of either [`MapShapeLayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer-class.html) or [`MapTileLayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTileLayer-class.html). The actual geographical rendering is done in each [`MapShapeLayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer-class.html). The [`source`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/source.html) property of the [`MapShapeLayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer-class.html) is of type [`MapShapeSource`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource-class.html). The [`source`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/source.html) can be set as the .json source from an asset bundle, from network or from Uint8List as bytes. Use the respective constructor depending on the source type. + +The [`shapeDataField`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeDataField.html) property of the [`MapShapeSource`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource-class.html) is used to refer to the unique field name in the .json source to identify each shape. In [`Mapping the data source`](https://help.syncfusion.com/flutter/maps/getting-started#mapping-the-data-source-for-shape-layer) section of this document, this [`shapeDataField`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeDataField.html) will be used to map with the respective value returned in [`primaryValueMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/primaryValueMapper.html) from the data source. + +I> The Mercator projection is the default projection in Maps. + +### From asset bundle + +Load .json data from an asset bundle. + +N> If you are using the [`MapShapeSource.asset`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/MapShapeSource.asset.html) constructor, you must add the .json file to the assets folder of your root directory and refer the json file path in the `pubspec.yaml` file as shown in the code snippet below. You can get the [`australia.json`](https://www.syncfusion.com/downloads/support/directtrac/general/ze/australia-json-910278184.zip) file here. + +{% tabs %} +{% highlight Dart %} + +flutter: + uses-material-design: true + assets: + - australia.json + +{% endhighlight %} +{% endtabs %} + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late MapShapeSource _dataSource; + + @override + void initState() { + _dataSource = MapShapeSource.asset( + 'assets/australia.json', + shapeDataField: 'STATE_NAME', + ); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Padding( + padding: EdgeInsets.all(15), + child: SfMaps( + layers: [ + MapShapeLayer(source: _dataSource), + ], + ), + ), + ); + } +} + +{% endhighlight %} +{% endtabs %} + +### From network + +Load .json data from the network. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late MapShapeSource _dataSource; + + @override + void initState() { + _dataSource = MapShapeSource.network( + 'http://www.json-generator.com/api/json/get/bVqXoJvfjC?indent=2', + shapeDataField: 'name', + ); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Padding( + padding: EdgeInsets.all(15), + child: SfMaps( + layers: [ + MapShapeLayer(source: _dataSource), + ], + ), + ), + ); + } +} + +{% endhighlight %} +{% endtabs %} + +### From memory + +Load .json data as bytes from `Uint8List`. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; +import 'dart:typed_data'; + +class MapsExample extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Scaffold( + body: FutureBuilder( + future: _fetchJsonData(), + builder: (BuildContext context, snapshot) { + if (snapshot.hasData) { + Uint8List bytesData = snapshot.data as Uint8List; + return SfMaps( + layers: [ + MapShapeLayer( + source: MapShapeSource.memory( + bytesData, + shapeDataField: 'STATE_NAME', + ), + ), + ], + ); + } else { + return CircularProgressIndicator(); + } + }, + ), + ); + } + + Future _fetchJsonData() async { + return (await rootBundle.load('assets/australia.json')).buffer.asUint8List(); + } +} + +{% endhighlight %} +{% endtabs %} + +![maps basic view](images/getting-started/map_basic_view.png) + +## Mapping the data source for shape layer + +By default, the value specified for the [`shapeDataField`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeDataField.html) in the GeoJSON source will be used in the elements like data labels, tooltip, and legend for their respective shapes. However, it is possible to keep a data source and customize these elements based on the requirement. As mentioned above, [`shapeDataField`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeDataField.html) will be used to map with the respective value returned in [`primaryValueMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/primaryValueMapper.html) from the data source. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late List data; + + @override + void initState() { + data = [ + Model('New South Wales', + ' New\nSouth Wales'), + Model('Queensland', 'Queensland'), + Model('Northern Territory', 'Northern\nTerritory'), + Model('Victoria', 'Victoria'), + Model('South Australia', 'South Australia'), + Model('Western Australia', 'Western Australia'), + Model('Tasmania', 'Tasmania'), + Model('Australian Capital Territory', 'ACT') + ]; + + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SfMaps( + layers: [ + MapShapeLayer( + source: MapShapeSource.asset( + 'assets/australia.json', + shapeDataField: 'STATE_NAME', + dataCount: data.length, + primaryValueMapper: (int index) => data[index].state, + ), + ), + ], + ), + ); + } +} + +class Model { + Model(this.state, this.stateCode); + + String state; + String stateCode; +} + +{% endhighlight %} +{% endtabs %} + +N> +* Refer the [`MapShapeSource.primaryValueMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/primaryValueMapper.html), for mapping the data of the data source collection with the respective [`MapShapeSource.shapeDataField`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeDataField.html) in .json source. +* Refer the [`MapShapeSource.bubbleSizeMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/bubbleSizeMapper.html), for customizing the bubble size. +* Refer the [`MapShapeSource.bubbleColorValueMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/bubbleColorValueMapper.html), for customizing the bubble colors. +* Refer the [`MapShapeSource.dataLabelMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/dataLabelMapper.html), for customizing the data label text. +* Refer the [`MapShapeSource.shapeColorValueMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeColorValueMapper.html), for customizing the shape colors. + +## Add shape layer Maps elements + +Add the basic Maps elements such as data labels, legend, and tooltip as shown in the code snippet below. + +* **Data labels** - You can show data labels using the [`MapShapeLayer.showDataLabels`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/showDataLabels.html) property. It is also possible to show data labels only for the particular shapes or show custom text using the [`MapShapeSource.dataLabelMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/dataLabelMapper.html) property. + +* **Legend** - You can enable legend using the [`MapShapeLayer.legend`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/legend.html) property. The icons color of the legend is applied based on the colors returned in the [`MapShapeSource.shapeColorValueMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeColorValueMapper.html) property. It is possible to customize the legend icons color and texts using the [`MapShapeSource.shapeColorMappers`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeColorMappers.html) property. + +* **Tooltip** - You can enable tooltip for the shapes using the [`MapShapeLayer.shapeTooltipBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/shapeTooltipBuilder.html) property. It will be called with the corresponding index every time when you interact with the shapes i.e., while tapping in touch devices and hover enter in mouse enabled devices. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late List data; + late MapShapeSource dataSource; + + @override + void initState() { + data = [ + Model('New South Wales', Color.fromRGBO(255, 215, 0, 1.0), + ' New\nSouth Wales'), + Model('Queensland', Color.fromRGBO(72, 209, 204, 1.0), 'Queensland'), + Model('Northern Territory', Colors.red.withOpacity(0.85), + 'Northern\nTerritory'), + Model('Victoria', Color.fromRGBO(171, 56, 224, 0.75), 'Victoria'), + Model('South Australia', Color.fromRGBO(126, 247, 74, 0.75), + 'South Australia'), + Model('Western Australia', Color.fromRGBO(79, 60, 201, 0.7), + 'Western Australia'), + Model('Tasmania', Color.fromRGBO(99, 164, 230, 1), 'Tasmania'), + Model('Australian Capital Territory', Colors.teal, 'ACT') + ]; + + dataSource = MapShapeSource.asset( + 'assets/australia.json', + shapeDataField: 'STATE_NAME', + dataCount: data.length, + primaryValueMapper: (int index) => data[index].state, + dataLabelMapper: (int index) => data[index].stateCode, + shapeColorValueMapper: (int index) => data[index].color, + ); + super.initState(); + } + + @override + Widget build(BuildContext context) { + final ThemeData themeData = Theme.of(context); + return Scaffold( + body: Center( + child: SizedBox( + height: MediaQuery.of(context).size.height * 0.55, + child: SfMaps( + layers: [ + MapShapeLayer( + source: dataSource, + showDataLabels: true, + legend: MapLegend(MapElement.shape), + shapeTooltipBuilder: (BuildContext context, int index) { + return Padding( + padding: const EdgeInsets.all(7), + child: Text(data[index].stateCode, + style: themeData.textTheme.labelSmall! + .copyWith(color: themeData.colorScheme.surface)), + ); + }, + tooltipSettings: MapTooltipSettings( + color: Colors.grey[700], + strokeColor: Colors.white, + strokeWidth: 2), + strokeColor: Colors.white, + strokeWidth: 0.5, + dataLabelSettings: MapDataLabelSettings( + textStyle: TextStyle( + color: Colors.black, + fontWeight: FontWeight.bold, + fontSize: themeData.textTheme.labelSmall!.fontSize)), + ), + ], + ), + ), + ), + ); + } +} + +class Model { + Model(this.state, this.color, this.stateCode); + + String state; + Color color; + String stateCode; +} + +{% endhighlight %} +{% endtabs %} + +![Maps getting started](images/getting-started/maps_getting_started.png) + +## Add tile layer + +The [`MapTileLayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTileLayer-class.html) needs to be added in the [`layers`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/SfMaps/layers.html) collection in [`SfMaps`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/SfMaps-class.html). The URL of the providers must be set in the [`MapTileLayer.urlTemplate`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTileLayer/urlTemplate.html) property. + +Refer to the [tile layer](https://help.syncfusion.com/flutter/maps/tile-layer#setting-url-template) section for more information. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatelessWidget { + @override + Widget build(BuildContext context) { + return SfMaps( + layers: [ + MapTileLayer( + urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', + ), + ], + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Maps tile layer getting started](images/getting-started/getting_started_tile_layer.png) + +N> You can refer to our [Flutter Maps](https://www.syncfusion.com/flutter-widgets/flutter-maps) feature tour page for its groundbreaking feature representations. You can also explore our [Flutter Maps example](https://flutter.syncfusion.com/#/maps/shape-layer/range-color-mapping) that shows how to configure a Maps in Flutter. diff --git a/Flutter/maps/legend.md b/Flutter/maps/legend.md index 328f17971..c1aa30395 100644 --- a/Flutter/maps/legend.md +++ b/Flutter/maps/legend.md @@ -9,7 +9,7 @@ documentation: ug # Legend in Flutter Maps (SfMaps) -You can provide clear information on the data plotted on the map using legend. +You can provide clear information on the data plotted on the Flutter Maps using legend. ## Shape legend @@ -633,7 +633,7 @@ N> You can place the legend in custom position using the [`MapLegend.offset`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLegend/offset.html) property. The default value of the [`offset`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLegend/offset.html) property is `null`. -If the property [`MapLegend.offset`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLegend/offset.html) has been set with the property [`MapLegend.position`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLegend/position.html) as top, then the legend will be placed in top but with absolute position, i.e. legend will not take dedicated position for it and will be drawn at the top of the map. +If the property [`MapLegend.offset`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLegend/offset.html) has been set with the property [`MapLegend.position`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLegend/position.html) as top, then the legend will be placed in top but with absolute position, i.e. legend will not take dedicated position for it and will be drawn at the top of the Flutter Maps. {% tabs %} {% highlight Dart %} diff --git a/Flutter/maps/markers.md b/Flutter/maps/markers.md index 5f588c752..f28fa3245 100644 --- a/Flutter/maps/markers.md +++ b/Flutter/maps/markers.md @@ -1,1002 +1,1002 @@ ---- -layout: post -title: Markers in Flutter Maps | Syncfusion® -description: Learn about marker support in Syncfusion® Flutter Maps (SfMaps), including built-in markers, custom widgets, positioning, and customization options. -platform: flutter -control: SfMaps -documentation: ug ---- - -# Markers in Flutter Maps (SfMaps) - -Markers can be used to denote specific locations on a map. You can use built-in symbols or display custom widgets at specific latitude and longitude coordinates on the map. - -## Adding markers - -### Shape layer - -You can show markers at any position on the map by providing latitude and longitude coordinates to the [`MapMarker`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapMarker-class.html), which is returned from the [`markerBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/markerBuilder.html) property. - -The [`markerBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/markerBuilder.html) callback will be called a number of times equal to the value specified in the [`initialMarkersCount`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/initialMarkersCount.html) property. The default value of the [`initialMarkersCount`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/initialMarkersCount.html) property is `null`. - -{% tabs %} -{% highlight Dart %} - -late List _data; -late MapShapeSource _dataSource; - -@override -void initState() { - _data = const [ - Model('Brazil', -14.235004, -51.92528), - Model('Germany', 51.16569, 10.451526), - Model('Australia', -25.274398, 133.775136), - Model('India', 20.593684, 78.96288), - Model('Russia', 61.52401, 105.318756) - ]; - - _dataSource = MapShapeSource.asset( - 'assets/world_map.json', - shapeDataField: 'name', - dataCount: _data.length, - primaryValueMapper: (index) => _data[index].country, - ); - super.initState(); -} - -@override -Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: Padding( - padding: EdgeInsets.only(left: 15, right: 15), - child: SfMaps( - layers: [ - MapShapeLayer( - source: _dataSource, - initialMarkersCount: 5, - markerBuilder: (BuildContext context, int index) { - return MapMarker( - latitude: _data[index].latitude, - longitude: _data[index].longitude, - iconColor: Colors.blue, - ); - }, - ), - ], - ), - )), - ); -} - -class Model { - const Model(this.country, this.latitude, this.longitude); - - final String country; - final double latitude; - final double longitude; -} - -{% endhighlight %} -{% endtabs %} - -![default marker](images/markers/default_marker.png) - -N> -* Refer to the [`markerBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/markerBuilder.html) documentation for returning the [`MapMarker`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapMarker-class.html). -* Refer to the [`controller`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/controller.html) documentation for dynamically updating the markers. - -### Tile layer - -You can show markers at any position on the map by providing latitude and longitude coordinates to the [`MapMarker`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapMarker-class.html), which is returned from the [`MapTileLayer.markerBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/markerBuilder.html) property. - -The [`markerBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/markerBuilder.html) callback will be called a number of times equal to the value specified in the [`initialMarkersCount`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/initialMarkersCount.html) property. The default value of the [`initialMarkersCount`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/initialMarkersCount.html) property is `null`. - -{% tabs %} -{% highlight Dart %} - -late List _data; - -@override -void initState() { - _data = const [ - Model('Brazil', -14.235004, -51.92528), - Model('Germany', 51.16569, 10.451526), - Model('Australia', -25.274398, 133.775136), - Model('India', 20.593684, 78.96288), - Model('Russia', 61.52401, 105.318756) - ]; - - super.initState(); -} - -@override -Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: SfMaps( - layers: [ - MapTileLayer( - urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', - initialMarkersCount: 5, - markerBuilder: (BuildContext context, int index) { - return MapMarker( - latitude: _data[index].latitude, - longitude: _data[index].longitude, - iconColor: Colors.blue, - ); - }, - ), - ], - ), - ), - ); -} - -class Model { - const Model(this.country, this.latitude, this.longitude); - - final String country; - final double latitude; - final double longitude; -} - -{% endhighlight %} -{% endtabs %} - -![Tile layer marker](images/markers/tile_layer_marker.png) - -N> -* Refer to the [`markerBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/markerBuilder.html) documentation for returning the [`MapMarker`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapMarker-class.html). -* Refer to the [`controller`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTileLayer/controller.html) documentation for dynamically updating the markers. - -## Appearance customization - -You can customize the built-in markers appearance using the [`iconType`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapMarker/iconType.html), [`iconColor`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapMarker/iconColor.html), [`iconStrokeColor`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapMarker/iconStrokeColor.html), [`iconStrokeWidth`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapMarker/iconStrokeWidth.html), and [`size`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapMarker/size.html) properties of the [`MapMarker`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapMarker-class.html). - -* **Alignment** - You can change the position of the marker from the given coordinate using the [`alignment`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapMarker/alignment.html) property. The default value is [`Alignment.center`](https://api.flutter.dev/flutter/painting/Alignment/center-constant.html). The available alignment options are [`topLeft`](https://api.flutter.dev/flutter/painting/Alignment/topLeft-constant.html), [`topRight`](https://api.flutter.dev/flutter/painting/Alignment/topRight-constant.html), [`topCenter`](https://api.flutter.dev/flutter/painting/Alignment/topCenter-constant.html), [`centerLeft`](https://api.flutter.dev/flutter/painting/Alignment/centerLeft-constant.html), [`center`](https://api.flutter.dev/flutter/painting/Alignment/center-constant.html), [`centerRight`](https://api.flutter.dev/flutter/painting/Alignment/centerRight-constant.html), [`bottomLeft`](https://api.flutter.dev/flutter/painting/Alignment/bottomLeft-constant.html), [`bottomCenter`](https://api.flutter.dev/flutter/painting/Alignment/bottomCenter-constant.html), [`bottomRight`](https://api.flutter.dev/flutter/painting/Alignment/bottomRight-constant.html). - -* **Offset** - You can adjust the marker position from the given coordinate using the `offset` property. The default value of the `offset` property is `Offset.zero`. - -N> -* The default value of the [`iconType`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapMarker/iconType.html) is `MapIconType.circle`. -* The default value of the [`iconStrokeWidth`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapMarker/iconStrokeWidth.html) is `1.0`. -* The default value of the [`iconColor`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapMarker/iconColor.html) is `Colors.blue`. -* The default value of the [`size`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapMarker/size.html) is `Size(14.0, 14.0)`. - -{% tabs %} -{% highlight Dart %} - -late List _data; -late MapShapeSource _dataSource; - -@override -void initState() { - _data = [ - Model(-14.235004, -51.92528), - Model(51.16569, 10.451526), - Model(-25.274398, 133.775136), - Model(20.593684, 78.96288), - Model(61.52401, 105.318756) - ]; - - _dataSource = MapShapeSource.asset( - 'assets/world_map.json', - shapeDataField: 'name', - ); - super.initState(); -} - -@override -Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: Padding( - padding: EdgeInsets.only(left: 15, right: 15), - child: SfMaps( - layers: [ - MapShapeLayer( - source: _dataSource, - initialMarkersCount: 5, - markerBuilder: (BuildContext context, int index) { - return MapMarker( - latitude: _data[index].latitude, - longitude: _data[index].longitude, - iconType: MapIconType.triangle, - size: Size(18, 18), - alignment: Alignment.center, - offset: Offset(0, 9), - iconColor: Colors.green[200], - iconStrokeColor: Colors.green[900], - iconStrokeWidth: 2, - ); - }, - ), - ], - ), - )), - ); -} - -class Model { - Model(this.latitude, this.longitude); - - final double latitude; - final double longitude; -} - -{% endhighlight %} -{% endtabs %} - -![marker customization](images/markers/marker_customization.png) - -## Adding custom markers - -You can show custom markers using the [`child`](https://api.flutter.dev/flutter/widgets/SingleChildRenderObjectWidget/child.html) property of the [`MapMarker`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapMarker-class.html) which is returned from the [`markerBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/markerBuilder.html). - -{% tabs %} -{% highlight Dart %} - -late List _data; -late List _iconsList; -late MapShapeSource _dataSource; - -@override -void initState() { - _data = [ - Model(-14.235004, -51.92528), - Model(51.16569, 10.451526), - Model(-25.274398, 133.775136), - Model(20.593684, 78.96288), - Model(61.52401, 105.318756) - ]; - - _iconsList = [ - Icon(Icons.add_location), - Icon(Icons.airplanemode_active), - Icon(Icons.add_alarm), - Icon(Icons.accessibility_new), - Icon(Icons.account_balance) - ]; - - _dataSource = MapShapeSource.asset( - 'assets/world_map.json', - shapeDataField: 'name', - ); - super.initState(); -} - -@override -Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: Padding( - padding: EdgeInsets.only(left: 15, right: 15), - child: SfMaps( - layers: [ - MapShapeLayer( - source: _dataSource, - initialMarkersCount: 5, - markerBuilder: (BuildContext context, int index) { - return MapMarker( - latitude: _data[index].latitude, - longitude: _data[index].longitude, - child: _iconsList[index], - ); - }, - ), - ], - ), - )), - ); -} - -class Model { - Model(this.latitude, this.longitude); - - final double latitude; - final double longitude; -} - -{% endhighlight %} -{% endtabs %} - -![custom marker](images/markers/custom_marker.png) - -## Adding markers dynamically - -You can add markers dynamically using the [`insertMarker`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayerController/insertMarker.html) method. The [`markerBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/markerBuilder.html) will be called for the respective index once the [`insertMarker`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayerController/insertMarker.html) method is called. The [`controller`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/controller.html) property of [`MapShapeLayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer-class.html) must be set with a new instance of [`MapShapeLayerController`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayerController-class.html). - -A marker will be inserted at the given index if the index value is less than or equal to the current available index. The marker will be added as the last item if the index value is greater than the current available index. - -N> You can get the current markers count from [`MapShapeLayerController.markersCount`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayerController/markersCount.html). - -### For shape layer - -{% tabs %} -{% highlight Dart %} - -late List _data; -late MapShapeLayerController _controller; -late MapShapeSource _dataSource; -late Random random; - -@override -void initState() { - _data = [ - Model(-14.235004, -51.92528), - Model(51.16569, 10.451526), - Model(-25.274398, 133.775136), - Model(20.593684, 78.96288), - Model(61.52401, 105.318756) - ]; - - _dataSource = MapShapeSource.asset( - 'assets/world_map.json', - shapeDataField: 'name', - ); - _controller = MapShapeLayerController(); - random = Random(); - super.initState(); -} - -@override -Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: Container( - height: 350, - child: Padding( - padding: EdgeInsets.only(left: 15, right: 15), - child: Column( - children: [ - SfMaps( - layers: [ - MapShapeLayer( - source: _dataSource, - initialMarkersCount: 5, - markerBuilder: (BuildContext context, int index) { - return MapMarker( - latitude: _data[index].latitude, - longitude: _data[index].longitude, - child: Icon(Icons.add_location), - ); - }, - controller: _controller, - ), - ], - ), - ElevatedButton( - child: Text('Add marker'), - onPressed: () { - _data.add(Model(-180 + random.nextInt(360).toDouble(), - -55 + random.nextInt(139).toDouble())); - _controller.insertMarker(5); - }, - ), - ], - ), - ), - )), - ); -} - -class Model { - Model(this.latitude, this.longitude); - - final double latitude; - final double longitude; -} - -{% endhighlight %} -{% endtabs %} - -### For Tile layer - -{% tabs %} -{% highlight Dart %} - -late List _data; -late MapTileLayerController _controller; -late Random random; - -@override -void initState() { - _data = [ - Model(-14.235004, -51.92528), - Model(51.16569, 10.451526), - Model(-25.274398, 133.775136), - Model(20.593684, 78.96288), - Model(61.52401, 105.318756) - ]; - _controller = MapTileLayerController(); - random = Random(); - super.initState(); -} - -@override -Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: Container( - height: 350, - child: Padding( - padding: EdgeInsets.only(left: 15, right: 15), - child: Column( - children: [ - SfMaps( - layers: [ - MapTileLayer( - urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', - initialMarkersCount: 5, - markerBuilder: (BuildContext context, int index) { - return MapMarker( - latitude: _data[index].latitude, - longitude: _data[index].longitude, - child: Icon(Icons.add_location), - ); - }, - controller: _controller, - ), - ], - ), - ElevatedButton( - child: Text('Add marker'), - onPressed: () { - _data.add(Model(-180 + random.nextInt(360).toDouble(), - -55 + random.nextInt(139).toDouble())); - _controller.insertMarker(5); - }, - ), - ], - ), - ), - )), - ); -} - -class Model { - Model(this.latitude, this.longitude); - - final double latitude; - final double longitude; -} - -{% endhighlight %} -{% endtabs %} - -![Add markers dynamically](images/markers/add-markers.gif) - -## Updating the existing markers - -You can update multiple markers at the same time by passing indices to the [`updateMarkers`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayerController/updateMarkers.html) method in the [`MapShapeLayerController`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayerController-class.html). The [`markerBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/markerBuilder.html) will be called again for the respective indices once the [`updateMarkers`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayerController/updateMarkers.html) method is called. - -N> -* You can get the current markers count from [`MapShapeLayerController.markersCount`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayerController/markersCount.html). -* You can refer to this [`snippet`](https://help.syncfusion.com/flutter/maps/markers#for-tile-layer) to update the markers dynamically for tile layer. - -{% tabs %} -{% highlight Dart %} - -late List _data; -late MapShapeLayerController _controller; -late Widget _markerWidget; -late MapShapeSource _dataSource; - -@override -void initState() { - _data = [ - Model(-14.235004, -51.92528), - Model(51.16569, 10.451526), - Model(-25.274398, 133.775136), - Model(20.593684, 78.96288), - Model(61.52401, 105.318756) - ]; - - _dataSource = MapShapeSource.asset( - 'assets/world_map.json', - shapeDataField: 'name', - ); - - _controller = MapShapeLayerController(); - _markerWidget = Icon(Icons.add_location); - super.initState(); -} - -@override -Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: Container( - height: 350, - child: Padding( - padding: EdgeInsets.only(left: 15, right: 15), - child: Column( - children: [ - SfMaps( - layers: [ - MapShapeLayer( - source: _dataSource, - initialMarkersCount: 5, - markerBuilder: (BuildContext context, int index){ - return MapMarker( - latitude: _data[index].latitude, - longitude: _data[index].longitude, - child: _markerWidget, - ); - }, - controller: _controller, - ), - ], - ), - ElevatedButton( - child: Text('Update marker'), - onPressed: () { - List updateList = [1, 2]; - _markerWidget = Icon(Icons.people); - _controller.updateMarkers(updateList); - }, - ), - ], - ), - ), - ) - ), - ); -} - -class Model { - Model(this.latitude, this.longitude); - - final double latitude; - final double longitude; -} - -{% endhighlight %} -{% endtabs %} - -![Update markers dynamically](images/markers/update-markers.gif) - -## Deleting a marker - -You can remove a marker at any index using the [`removeMarkerAt`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayerController/removeMarkerAt.html) method. - -N> -* You can get the current markers count from [`MapShapeLayerController.markersCount`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayerController/markersCount.html). -* You can refer to this [`snippet`](https://help.syncfusion.com/flutter/maps/markers#for-tile-layer) to update the markers dynamically for tile layer. - -{% tabs %} -{% highlight Dart %} - -late List _data; -late MapShapeLayerController _controller; -late MapShapeSource _dataSource; - -@override -void initState() { - _data = [ - Model(-14.235004, -51.92528), - Model(51.16569, 10.451526), - Model(-25.274398, 133.775136), - Model(20.593684, 78.96288), - Model(61.52401, 105.318756) - ]; - - _dataSource = MapShapeSource.asset( - 'assets/world_map.json', - shapeDataField: 'name', - ); - _controller = MapShapeLayerController(); - super.initState(); -} - -@override -Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: Container( - height: 350, - child: Padding( - padding: EdgeInsets.only(left: 15, right: 15), - child: Column( - children: [ - SfMaps( - layers: [ - MapShapeLayer( - source: _dataSource, - initialMarkersCount: 5, - markerBuilder: (BuildContext context, int index){ - return MapMarker( - latitude: _data[index].latitude, - longitude: _data[index].longitude, - child: Icon(Icons.add_location), - ); - }, - controller: _controller, - ), - ], - ), - ElevatedButton( - child: Text('Remove marker'), - onPressed: () { - _controller.removeMarkerAt(4); - }, - ), - ], - ), - ), - ) - ), - ); -} - -class Model { - Model(this.latitude, this.longitude); - - final double latitude; - final double longitude; -} - -{% endhighlight %} -{% endtabs %} - -## Clearing the markers - -You can clear all markers using the [`clearMarkers`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayerController/clearMarkers.html) method. - -N> -* You can get the current markers count from [`MapShapeLayerController.markersCount`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayerController/markersCount.html). -* You can refer to this [`snippet`](https://help.syncfusion.com/flutter/maps/markers#for-tile-layer) to update the markers dynamically for tile layer. - -{% tabs %} -{% highlight Dart %} - -late List _data; -late MapShapeLayerController _controller; -late MapShapeSource _dataSource; - -@override -void initState() { - _data = [ - Model(-14.235004, -51.92528), - Model(51.16569, 10.451526), - Model(-25.274398, 133.775136), - Model(20.593684, 78.96288), - Model(61.52401, 105.318756) - ]; - - _dataSource = MapShapeSource.asset( - 'assets/world_map.json', - shapeDataField: 'name', - ); - _controller = MapShapeLayerController(); - super.initState(); -} - -@override -Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: Container( - height: 350, - child: Padding( - padding: EdgeInsets.only(left: 15, right: 15), - child: Column( - children: [ - SfMaps( - layers: [ - MapShapeLayer( - source: _dataSource, - initialMarkersCount: 5, - markerBuilder: (BuildContext context, int index){ - return MapMarker( - latitude: _data[index].latitude, - longitude: _data[index].longitude, - child: Icon(Icons.add_location), - ); - }, - controller: _controller, - ), - ], - ), - ElevatedButton( - child: Text('Clear marker'), - onPressed: () { - _controller.clearMarkers(); - }, - ), - ], - ), - ), - ) - ), - ); -} - -class Model { - Model(this.latitude, this.longitude); - - final double latitude; - final double longitude; -} - -{% endhighlight %} -{% endtabs %} - -## Marker controller - -You can position a marker at the tapped position by converting the touch pixel point into coordinates using the [`pixelToLatLng`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTileLayerController/pixelToLatLng.html) method of [`MapTileLayerController`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTileLayerController-class.html) in the [`MapTileLayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTileLayer-class.html) and the [`MapShapeLayerController`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayerController-class.html) in the [`MapShapeLayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer-class.html). - -N> This is applicable for both tile layer and shape layer. - -### Shape layer - -{% tabs %} -{% highlight Dart %} - -late MapLatLng _markerPosition; -late _CustomZoomPanBehavior _mapZoomPanBehavior; -late MapShapeLayerController _controller; -late MapShapeSource _mapSource; - -@override -void initState() { - _controller = MapShapeLayerController(); - _mapZoomPanBehavior = _CustomZoomPanBehavior() - ..zoomLevel = 1 - ..onTap = updateMarkerChange; - _mapSource = MapShapeSource.asset( - 'assets/world_map.json', - shapeDataField: 'continent', - ); - super.initState(); -} - -void updateMarkerChange(Offset position) { - _markerPosition = _controller.pixelToLatLng(position); - - /// Removed [MapShapeLayer.initialMarkersCount] property and updated - /// markers only when the user taps. - if (_controller.markersCount > 0) { - _controller.clearMarkers(); - } - _controller.insertMarker(0); -} - -@override -Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: Container( - height: 400, - width: 400, - child: MapShapeLayer( - source: _mapSource, - zoomPanBehavior: _mapZoomPanBehavior, - controller: _controller, - markerBuilder: (BuildContext context, int index) { - return MapMarker( - latitude: _markerPosition.latitude, - longitude: _markerPosition.longitude, - child: Icon( - Icons.location_on, - color: Colors.red, - size: 20, - ), - ); - }, - ), - ), - ), - ); -} - -class _CustomZoomPanBehavior extends MapZoomPanBehavior { - _CustomZoomPanBehavior(); - late MapTapCallback onTap; - - @override - void handleEvent(PointerEvent event) { - if (event is PointerUpEvent) { - onTap(event.localPosition); - } - super.handleEvent(event); - } -} - -typedef MapTapCallback = void Function(Offset position); - -{% endhighlight %} -{% endtabs %} - -### Tile layer - -{% tabs %} -{% highlight Dart %} - -late MapLatLng _markerPosition; -late _CustomZoomPanBehavior _mapZoomPanBehavior; -late MapTileLayerController _controller; - -@override -void initState() { - _controller = MapTileLayerController(); - _mapZoomPanBehavior = _CustomZoomPanBehavior() - ..onTap = updateMarkerChange; - super.initState(); -} - -void updateMarkerChange(Offset position) { - _markerPosition = _controller.pixelToLatLng(position); - - /// Removed [MapTileLayer.initialMarkersCount] property and updated - /// markers only when the user taps. - if (_controller.markersCount > 0) { - _controller.clearMarkers(); - } - _controller.insertMarker(0); -} - -@override -Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: Container( - height: 400, - width: 400, - child: MapTileLayer( - urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', - zoomPanBehavior: _mapZoomPanBehavior, - controller: _controller, - markerBuilder: (BuildContext context, int index) { - return MapMarker( - latitude: _markerPosition.latitude, - longitude: _markerPosition.longitude, - child: Icon( - Icons.location_on, - color: Colors.red, - size: 20, - )); - }, - ), - ), - ), - ); -} - -class _CustomZoomPanBehavior extends MapZoomPanBehavior { - _CustomZoomPanBehavior(); - late MapTapCallback onTap; - - @override - void handleEvent(PointerEvent event) { - if (event is PointerUpEvent) { - onTap(event.localPosition); - } - super.handleEvent(event); - } -} - -typedef MapTapCallback = void Function(Offset position); - -{% endhighlight %} -{% endtabs %} - -![Position marker at tapped position](images/markers/marker-at-tapped-position.gif) - -## Zoom markers to fit bounds - -You can visualize a specific area on the map by specifying the northeast and southwest coordinate points to the [`initialLatLngBounds`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/initialLatLngBounds.html) property in the [`MapTileLayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTileLayer-class.html) and [`MapShapeLayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer-class.html). It renders the map by calculating the center coordinate and zoom level depending on the [`initialLatLngBounds`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/initialLatLngBounds.html) value. - -The [`initialLatLngBounds`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/initialLatLngBounds.html) property can be set at load time alone. You can use the [`latLngBounds`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/latLngBounds.html) property of [`MapZoomPanBehavior`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior-class.html) to dynamically update the map bounds. - -{% tabs %} -{% highlight Dart %} - -late List<_TouristPlaceDetails> _touristPlaces; -late MapZoomPanBehavior _zoomPanBehavior; -bool _canFitMarkers = false; - -@override -void initState() { - _zoomPanBehavior = MapZoomPanBehavior(); - _touristPlaces = <_TouristPlaceDetails>[ - const _TouristPlaceDetails( - MapLatLng(-25.6953, -54.4367), 'Iguazu Falls, Argentina'), - const _TouristPlaceDetails(MapLatLng(-50.9423, -73.4068), - 'Torres del Paine National Park, Patagonia, Chile'), - const _TouristPlaceDetails( - MapLatLng(-15.9254, -69.3354), 'Lake Titicaca, Bolivia'), - const _TouristPlaceDetails( - MapLatLng(-13.1631, -72.5450), 'Machu Picchu, Peru'), - const _TouristPlaceDetails( - MapLatLng(-0.1862504, -78.5706247), 'The Amazon via Quito, Ecuador'), - const _TouristPlaceDetails( - MapLatLng(5.9701, -62.5362), 'Angel Falls, Venezuela'), - const _TouristPlaceDetails( - MapLatLng(-14.0875, -75.7626), 'Huacachina, Peru'), - const _TouristPlaceDetails( - MapLatLng(-22.7953, -67.8361), 'Laguna Verde, Bolivia'), - const _TouristPlaceDetails( - MapLatLng(-50.5025092, -73.1997346), 'Perito Moreno, Venezuela'), - const _TouristPlaceDetails( - MapLatLng(-22.9068, -43.1729), 'Rio de Janeiro, Brazil'), - const _TouristPlaceDetails( - MapLatLng(5.1765, -59.4808), 'Kaieteur Falls, Guyana'), - const _TouristPlaceDetails( - MapLatLng(-33.4489, -70.6693), 'Santiago, Chile'), - const _TouristPlaceDetails( - MapLatLng(4.7110, -74.0721), 'Bogota, Colombia'), - const _TouristPlaceDetails( - MapLatLng(-1.3928, -78.4269), 'Banos, Ecuador'), - ]; - super.initState(); -} - -@override -Widget build(BuildContext context) { - return Scaffold( - body: Column( - children: [ - SfMaps( - layers: [ - MapTileLayer( - urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', - zoomPanBehavior: _zoomPanBehavior, - initialMarkersCount: _touristPlaces.length, - markerBuilder: (BuildContext context, int index) { - return MapMarker( - latitude: _touristPlaces[index].latLng.latitude, - longitude: _touristPlaces[index].latLng.longitude, - child: const Icon( - Icons.location_on, - color: Colors.red, - size: 20, - ), - ); - }, - ), - ], - ), - SizedBox(height: 10), - Container( - width: 300, - padding: EdgeInsets.zero, - child: CheckboxListTile( - activeColor: Colors.blue, - value: _canFitMarkers, - title: Text('Zoom marker to fit bounds'), - onChanged: (bool? value) { - _canFitMarkers = value!; - setState(() { - if (_canFitMarkers) { - // South America bounds. - _zoomPanBehavior.latLngBounds = const MapLatLngBounds( - MapLatLng(12.434375, -34.80546874999999), - MapLatLng(-55.891699218750006, -91.654150390625)); - } else { - // World bounds. - _zoomPanBehavior.latLngBounds = const MapLatLngBounds( - MapLatLng(-90.0, -180.0), MapLatLng(90.0, 180.0)); - } - }); - }, - ), - ), - ], - ), - ); -} - -class _TouristPlaceDetails { - const _TouristPlaceDetails(this.latLng, this.place); - final MapLatLng latLng; - final String place; -} - -{% endhighlight %} -{% endtabs %} - -![Zoom markers to fit bounds](images/markers/fit_bounds.jpg) - +--- +layout: post +title: Markers in Flutter Maps | Syncfusion® +description: Learn about marker support in Syncfusion® Flutter Maps (SfMaps), including built-in markers, custom widgets, positioning, and customization options. +platform: flutter +control: SfMaps +documentation: ug +--- + +# Markers in Flutter Maps (SfMaps) + +Markers can be used to denote specific locations on a Flutter Maps. You can use built-in symbols or display custom widgets at specific latitude and longitude coordinates on the Flutter Maps. + +## Adding markers + +### Shape layer + +You can show markers at any position on the Flutter Maps by providing latitude and longitude coordinates to the [`MapMarker`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapMarker-class.html), which is returned from the [`markerBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/markerBuilder.html) property. + +The [`markerBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/markerBuilder.html) callback will be called a number of times equal to the value specified in the [`initialMarkersCount`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/initialMarkersCount.html) property. The default value of the [`initialMarkersCount`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/initialMarkersCount.html) property is `null`. + +{% tabs %} +{% highlight Dart %} + +late List _data; +late MapShapeSource _dataSource; + +@override +void initState() { + _data = const [ + Model('Brazil', -14.235004, -51.92528), + Model('Germany', 51.16569, 10.451526), + Model('Australia', -25.274398, 133.775136), + Model('India', 20.593684, 78.96288), + Model('Russia', 61.52401, 105.318756) + ]; + + _dataSource = MapShapeSource.asset( + 'assets/world_map.json', + shapeDataField: 'name', + dataCount: _data.length, + primaryValueMapper: (index) => _data[index].country, + ); + super.initState(); +} + +@override +Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Padding( + padding: EdgeInsets.only(left: 15, right: 15), + child: SfMaps( + layers: [ + MapShapeLayer( + source: _dataSource, + initialMarkersCount: 5, + markerBuilder: (BuildContext context, int index) { + return MapMarker( + latitude: _data[index].latitude, + longitude: _data[index].longitude, + iconColor: Colors.blue, + ); + }, + ), + ], + ), + )), + ); +} + +class Model { + const Model(this.country, this.latitude, this.longitude); + + final String country; + final double latitude; + final double longitude; +} + +{% endhighlight %} +{% endtabs %} + +![default marker](images/markers/default_marker.png) + +N> +* Refer to the [`markerBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/markerBuilder.html) documentation for returning the [`MapMarker`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapMarker-class.html). +* Refer to the [`controller`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/controller.html) documentation for dynamically updating the markers. + +### Tile layer + +You can show markers at any position on the Flutter Maps by providing latitude and longitude coordinates to the [`MapMarker`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapMarker-class.html), which is returned from the [`MapTileLayer.markerBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/markerBuilder.html) property. + +The [`markerBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/markerBuilder.html) callback will be called a number of times equal to the value specified in the [`initialMarkersCount`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/initialMarkersCount.html) property. The default value of the [`initialMarkersCount`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/initialMarkersCount.html) property is `null`. + +{% tabs %} +{% highlight Dart %} + +late List _data; + +@override +void initState() { + _data = const [ + Model('Brazil', -14.235004, -51.92528), + Model('Germany', 51.16569, 10.451526), + Model('Australia', -25.274398, 133.775136), + Model('India', 20.593684, 78.96288), + Model('Russia', 61.52401, 105.318756) + ]; + + super.initState(); +} + +@override +Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: SfMaps( + layers: [ + MapTileLayer( + urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', + initialMarkersCount: 5, + markerBuilder: (BuildContext context, int index) { + return MapMarker( + latitude: _data[index].latitude, + longitude: _data[index].longitude, + iconColor: Colors.blue, + ); + }, + ), + ], + ), + ), + ); +} + +class Model { + const Model(this.country, this.latitude, this.longitude); + + final String country; + final double latitude; + final double longitude; +} + +{% endhighlight %} +{% endtabs %} + +![Tile layer marker](images/markers/tile_layer_marker.png) + +N> +* Refer to the [`markerBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/markerBuilder.html) documentation for returning the [`MapMarker`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapMarker-class.html). +* Refer to the [`controller`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTileLayer/controller.html) documentation for dynamically updating the markers. + +## Appearance customization + +You can customize the built-in markers appearance using the [`iconType`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapMarker/iconType.html), [`iconColor`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapMarker/iconColor.html), [`iconStrokeColor`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapMarker/iconStrokeColor.html), [`iconStrokeWidth`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapMarker/iconStrokeWidth.html), and [`size`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapMarker/size.html) properties of the [`MapMarker`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapMarker-class.html). + +* **Alignment** - You can change the position of the marker from the given coordinate using the [`alignment`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapMarker/alignment.html) property. The default value is [`Alignment.center`](https://api.flutter.dev/flutter/painting/Alignment/center-constant.html). The available alignment options are [`topLeft`](https://api.flutter.dev/flutter/painting/Alignment/topLeft-constant.html), [`topRight`](https://api.flutter.dev/flutter/painting/Alignment/topRight-constant.html), [`topCenter`](https://api.flutter.dev/flutter/painting/Alignment/topCenter-constant.html), [`centerLeft`](https://api.flutter.dev/flutter/painting/Alignment/centerLeft-constant.html), [`center`](https://api.flutter.dev/flutter/painting/Alignment/center-constant.html), [`centerRight`](https://api.flutter.dev/flutter/painting/Alignment/centerRight-constant.html), [`bottomLeft`](https://api.flutter.dev/flutter/painting/Alignment/bottomLeft-constant.html), [`bottomCenter`](https://api.flutter.dev/flutter/painting/Alignment/bottomCenter-constant.html), [`bottomRight`](https://api.flutter.dev/flutter/painting/Alignment/bottomRight-constant.html). + +* **Offset** - You can adjust the marker position from the given coordinate using the `offset` property. The default value of the `offset` property is `Offset.zero`. + +N> +* The default value of the [`iconType`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapMarker/iconType.html) is `MapIconType.circle`. +* The default value of the [`iconStrokeWidth`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapMarker/iconStrokeWidth.html) is `1.0`. +* The default value of the [`iconColor`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapMarker/iconColor.html) is `Colors.blue`. +* The default value of the [`size`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapMarker/size.html) is `Size(14.0, 14.0)`. + +{% tabs %} +{% highlight Dart %} + +late List _data; +late MapShapeSource _dataSource; + +@override +void initState() { + _data = [ + Model(-14.235004, -51.92528), + Model(51.16569, 10.451526), + Model(-25.274398, 133.775136), + Model(20.593684, 78.96288), + Model(61.52401, 105.318756) + ]; + + _dataSource = MapShapeSource.asset( + 'assets/world_map.json', + shapeDataField: 'name', + ); + super.initState(); +} + +@override +Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Padding( + padding: EdgeInsets.only(left: 15, right: 15), + child: SfMaps( + layers: [ + MapShapeLayer( + source: _dataSource, + initialMarkersCount: 5, + markerBuilder: (BuildContext context, int index) { + return MapMarker( + latitude: _data[index].latitude, + longitude: _data[index].longitude, + iconType: MapIconType.triangle, + size: Size(18, 18), + alignment: Alignment.center, + offset: Offset(0, 9), + iconColor: Colors.green[200], + iconStrokeColor: Colors.green[900], + iconStrokeWidth: 2, + ); + }, + ), + ], + ), + )), + ); +} + +class Model { + Model(this.latitude, this.longitude); + + final double latitude; + final double longitude; +} + +{% endhighlight %} +{% endtabs %} + +![marker customization](images/markers/marker_customization.png) + +## Adding custom markers + +You can show custom markers using the [`child`](https://api.flutter.dev/flutter/widgets/SingleChildRenderObjectWidget/child.html) property of the [`MapMarker`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapMarker-class.html) which is returned from the [`markerBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/markerBuilder.html). + +{% tabs %} +{% highlight Dart %} + +late List _data; +late List _iconsList; +late MapShapeSource _dataSource; + +@override +void initState() { + _data = [ + Model(-14.235004, -51.92528), + Model(51.16569, 10.451526), + Model(-25.274398, 133.775136), + Model(20.593684, 78.96288), + Model(61.52401, 105.318756) + ]; + + _iconsList = [ + Icon(Icons.add_location), + Icon(Icons.airplanemode_active), + Icon(Icons.add_alarm), + Icon(Icons.accessibility_new), + Icon(Icons.account_balance) + ]; + + _dataSource = MapShapeSource.asset( + 'assets/world_map.json', + shapeDataField: 'name', + ); + super.initState(); +} + +@override +Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Padding( + padding: EdgeInsets.only(left: 15, right: 15), + child: SfMaps( + layers: [ + MapShapeLayer( + source: _dataSource, + initialMarkersCount: 5, + markerBuilder: (BuildContext context, int index) { + return MapMarker( + latitude: _data[index].latitude, + longitude: _data[index].longitude, + child: _iconsList[index], + ); + }, + ), + ], + ), + )), + ); +} + +class Model { + Model(this.latitude, this.longitude); + + final double latitude; + final double longitude; +} + +{% endhighlight %} +{% endtabs %} + +![custom marker](images/markers/custom_marker.png) + +## Adding markers dynamically + +You can add markers dynamically using the [`insertMarker`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayerController/insertMarker.html) method. The [`markerBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/markerBuilder.html) will be called for the respective index once the [`insertMarker`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayerController/insertMarker.html) method is called. The [`controller`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/controller.html) property of [`MapShapeLayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer-class.html) must be set with a new instance of [`MapShapeLayerController`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayerController-class.html). + +A marker will be inserted at the given index if the index value is less than or equal to the current available index. The marker will be added as the last item if the index value is greater than the current available index. + +N> You can get the current markers count from [`MapShapeLayerController.markersCount`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayerController/markersCount.html). + +### For shape layer + +{% tabs %} +{% highlight Dart %} + +late List _data; +late MapShapeLayerController _controller; +late MapShapeSource _dataSource; +late Random random; + +@override +void initState() { + _data = [ + Model(-14.235004, -51.92528), + Model(51.16569, 10.451526), + Model(-25.274398, 133.775136), + Model(20.593684, 78.96288), + Model(61.52401, 105.318756) + ]; + + _dataSource = MapShapeSource.asset( + 'assets/world_map.json', + shapeDataField: 'name', + ); + _controller = MapShapeLayerController(); + random = Random(); + super.initState(); +} + +@override +Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Container( + height: 350, + child: Padding( + padding: EdgeInsets.only(left: 15, right: 15), + child: Column( + children: [ + SfMaps( + layers: [ + MapShapeLayer( + source: _dataSource, + initialMarkersCount: 5, + markerBuilder: (BuildContext context, int index) { + return MapMarker( + latitude: _data[index].latitude, + longitude: _data[index].longitude, + child: Icon(Icons.add_location), + ); + }, + controller: _controller, + ), + ], + ), + ElevatedButton( + child: Text('Add marker'), + onPressed: () { + _data.add(Model(-180 + random.nextInt(360).toDouble(), + -55 + random.nextInt(139).toDouble())); + _controller.insertMarker(5); + }, + ), + ], + ), + ), + )), + ); +} + +class Model { + Model(this.latitude, this.longitude); + + final double latitude; + final double longitude; +} + +{% endhighlight %} +{% endtabs %} + +### For Tile layer + +{% tabs %} +{% highlight Dart %} + +late List _data; +late MapTileLayerController _controller; +late Random random; + +@override +void initState() { + _data = [ + Model(-14.235004, -51.92528), + Model(51.16569, 10.451526), + Model(-25.274398, 133.775136), + Model(20.593684, 78.96288), + Model(61.52401, 105.318756) + ]; + _controller = MapTileLayerController(); + random = Random(); + super.initState(); +} + +@override +Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Container( + height: 350, + child: Padding( + padding: EdgeInsets.only(left: 15, right: 15), + child: Column( + children: [ + SfMaps( + layers: [ + MapTileLayer( + urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', + initialMarkersCount: 5, + markerBuilder: (BuildContext context, int index) { + return MapMarker( + latitude: _data[index].latitude, + longitude: _data[index].longitude, + child: Icon(Icons.add_location), + ); + }, + controller: _controller, + ), + ], + ), + ElevatedButton( + child: Text('Add marker'), + onPressed: () { + _data.add(Model(-180 + random.nextInt(360).toDouble(), + -55 + random.nextInt(139).toDouble())); + _controller.insertMarker(5); + }, + ), + ], + ), + ), + )), + ); +} + +class Model { + Model(this.latitude, this.longitude); + + final double latitude; + final double longitude; +} + +{% endhighlight %} +{% endtabs %} + +![Add markers dynamically](images/markers/add-markers.gif) + +## Updating the existing markers + +You can update multiple markers at the same time by passing indices to the [`updateMarkers`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayerController/updateMarkers.html) method in the [`MapShapeLayerController`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayerController-class.html). The [`markerBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/markerBuilder.html) will be called again for the respective indices once the [`updateMarkers`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayerController/updateMarkers.html) method is called. + +N> +* You can get the current markers count from [`MapShapeLayerController.markersCount`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayerController/markersCount.html). +* You can refer to this [`snippet`](https://help.syncfusion.com/flutter/maps/markers#for-tile-layer) to update the markers dynamically for tile layer. + +{% tabs %} +{% highlight Dart %} + +late List _data; +late MapShapeLayerController _controller; +late Widget _markerWidget; +late MapShapeSource _dataSource; + +@override +void initState() { + _data = [ + Model(-14.235004, -51.92528), + Model(51.16569, 10.451526), + Model(-25.274398, 133.775136), + Model(20.593684, 78.96288), + Model(61.52401, 105.318756) + ]; + + _dataSource = MapShapeSource.asset( + 'assets/world_map.json', + shapeDataField: 'name', + ); + + _controller = MapShapeLayerController(); + _markerWidget = Icon(Icons.add_location); + super.initState(); +} + +@override +Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Container( + height: 350, + child: Padding( + padding: EdgeInsets.only(left: 15, right: 15), + child: Column( + children: [ + SfMaps( + layers: [ + MapShapeLayer( + source: _dataSource, + initialMarkersCount: 5, + markerBuilder: (BuildContext context, int index){ + return MapMarker( + latitude: _data[index].latitude, + longitude: _data[index].longitude, + child: _markerWidget, + ); + }, + controller: _controller, + ), + ], + ), + ElevatedButton( + child: Text('Update marker'), + onPressed: () { + List updateList = [1, 2]; + _markerWidget = Icon(Icons.people); + _controller.updateMarkers(updateList); + }, + ), + ], + ), + ), + ) + ), + ); +} + +class Model { + Model(this.latitude, this.longitude); + + final double latitude; + final double longitude; +} + +{% endhighlight %} +{% endtabs %} + +![Update markers dynamically](images/markers/update-markers.gif) + +## Deleting a marker + +You can remove a marker at any index using the [`removeMarkerAt`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayerController/removeMarkerAt.html) method. + +N> +* You can get the current markers count from [`MapShapeLayerController.markersCount`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayerController/markersCount.html). +* You can refer to this [`snippet`](https://help.syncfusion.com/flutter/maps/markers#for-tile-layer) to update the markers dynamically for tile layer. + +{% tabs %} +{% highlight Dart %} + +late List _data; +late MapShapeLayerController _controller; +late MapShapeSource _dataSource; + +@override +void initState() { + _data = [ + Model(-14.235004, -51.92528), + Model(51.16569, 10.451526), + Model(-25.274398, 133.775136), + Model(20.593684, 78.96288), + Model(61.52401, 105.318756) + ]; + + _dataSource = MapShapeSource.asset( + 'assets/world_map.json', + shapeDataField: 'name', + ); + _controller = MapShapeLayerController(); + super.initState(); +} + +@override +Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Container( + height: 350, + child: Padding( + padding: EdgeInsets.only(left: 15, right: 15), + child: Column( + children: [ + SfMaps( + layers: [ + MapShapeLayer( + source: _dataSource, + initialMarkersCount: 5, + markerBuilder: (BuildContext context, int index){ + return MapMarker( + latitude: _data[index].latitude, + longitude: _data[index].longitude, + child: Icon(Icons.add_location), + ); + }, + controller: _controller, + ), + ], + ), + ElevatedButton( + child: Text('Remove marker'), + onPressed: () { + _controller.removeMarkerAt(4); + }, + ), + ], + ), + ), + ) + ), + ); +} + +class Model { + Model(this.latitude, this.longitude); + + final double latitude; + final double longitude; +} + +{% endhighlight %} +{% endtabs %} + +## Clearing the markers + +You can clear all markers using the [`clearMarkers`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayerController/clearMarkers.html) method. + +N> +* You can get the current markers count from [`MapShapeLayerController.markersCount`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayerController/markersCount.html). +* You can refer to this [`snippet`](https://help.syncfusion.com/flutter/maps/markers#for-tile-layer) to update the markers dynamically for tile layer. + +{% tabs %} +{% highlight Dart %} + +late List _data; +late MapShapeLayerController _controller; +late MapShapeSource _dataSource; + +@override +void initState() { + _data = [ + Model(-14.235004, -51.92528), + Model(51.16569, 10.451526), + Model(-25.274398, 133.775136), + Model(20.593684, 78.96288), + Model(61.52401, 105.318756) + ]; + + _dataSource = MapShapeSource.asset( + 'assets/world_map.json', + shapeDataField: 'name', + ); + _controller = MapShapeLayerController(); + super.initState(); +} + +@override +Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Container( + height: 350, + child: Padding( + padding: EdgeInsets.only(left: 15, right: 15), + child: Column( + children: [ + SfMaps( + layers: [ + MapShapeLayer( + source: _dataSource, + initialMarkersCount: 5, + markerBuilder: (BuildContext context, int index){ + return MapMarker( + latitude: _data[index].latitude, + longitude: _data[index].longitude, + child: Icon(Icons.add_location), + ); + }, + controller: _controller, + ), + ], + ), + ElevatedButton( + child: Text('Clear marker'), + onPressed: () { + _controller.clearMarkers(); + }, + ), + ], + ), + ), + ) + ), + ); +} + +class Model { + Model(this.latitude, this.longitude); + + final double latitude; + final double longitude; +} + +{% endhighlight %} +{% endtabs %} + +## Marker controller + +You can position a marker at the tapped position by converting the touch pixel point into coordinates using the [`pixelToLatLng`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTileLayerController/pixelToLatLng.html) method of [`MapTileLayerController`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTileLayerController-class.html) in the [`MapTileLayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTileLayer-class.html) and the [`MapShapeLayerController`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayerController-class.html) in the [`MapShapeLayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer-class.html). + +N> This is applicable for both tile layer and shape layer. + +### Shape layer + +{% tabs %} +{% highlight Dart %} + +late MapLatLng _markerPosition; +late _CustomZoomPanBehavior _mapZoomPanBehavior; +late MapShapeLayerController _controller; +late MapShapeSource _mapSource; + +@override +void initState() { + _controller = MapShapeLayerController(); + _mapZoomPanBehavior = _CustomZoomPanBehavior() + ..zoomLevel = 1 + ..onTap = updateMarkerChange; + _mapSource = MapShapeSource.asset( + 'assets/world_map.json', + shapeDataField: 'continent', + ); + super.initState(); +} + +void updateMarkerChange(Offset position) { + _markerPosition = _controller.pixelToLatLng(position); + + /// Removed [MapShapeLayer.initialMarkersCount] property and updated + /// markers only when the user taps. + if (_controller.markersCount > 0) { + _controller.clearMarkers(); + } + _controller.insertMarker(0); +} + +@override +Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Container( + height: 400, + width: 400, + child: MapShapeLayer( + source: _mapSource, + zoomPanBehavior: _mapZoomPanBehavior, + controller: _controller, + markerBuilder: (BuildContext context, int index) { + return MapMarker( + latitude: _markerPosition.latitude, + longitude: _markerPosition.longitude, + child: Icon( + Icons.location_on, + color: Colors.red, + size: 20, + ), + ); + }, + ), + ), + ), + ); +} + +class _CustomZoomPanBehavior extends MapZoomPanBehavior { + _CustomZoomPanBehavior(); + late MapTapCallback onTap; + + @override + void handleEvent(PointerEvent event) { + if (event is PointerUpEvent) { + onTap(event.localPosition); + } + super.handleEvent(event); + } +} + +typedef MapTapCallback = void Function(Offset position); + +{% endhighlight %} +{% endtabs %} + +### Tile layer + +{% tabs %} +{% highlight Dart %} + +late MapLatLng _markerPosition; +late _CustomZoomPanBehavior _mapZoomPanBehavior; +late MapTileLayerController _controller; + +@override +void initState() { + _controller = MapTileLayerController(); + _mapZoomPanBehavior = _CustomZoomPanBehavior() + ..onTap = updateMarkerChange; + super.initState(); +} + +void updateMarkerChange(Offset position) { + _markerPosition = _controller.pixelToLatLng(position); + + /// Removed [MapTileLayer.initialMarkersCount] property and updated + /// markers only when the user taps. + if (_controller.markersCount > 0) { + _controller.clearMarkers(); + } + _controller.insertMarker(0); +} + +@override +Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Container( + height: 400, + width: 400, + child: MapTileLayer( + urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', + zoomPanBehavior: _mapZoomPanBehavior, + controller: _controller, + markerBuilder: (BuildContext context, int index) { + return MapMarker( + latitude: _markerPosition.latitude, + longitude: _markerPosition.longitude, + child: Icon( + Icons.location_on, + color: Colors.red, + size: 20, + )); + }, + ), + ), + ), + ); +} + +class _CustomZoomPanBehavior extends MapZoomPanBehavior { + _CustomZoomPanBehavior(); + late MapTapCallback onTap; + + @override + void handleEvent(PointerEvent event) { + if (event is PointerUpEvent) { + onTap(event.localPosition); + } + super.handleEvent(event); + } +} + +typedef MapTapCallback = void Function(Offset position); + +{% endhighlight %} +{% endtabs %} + +![Position marker at tapped position](images/markers/marker-at-tapped-position.gif) + +## Zoom markers to fit bounds + +You can visualize a specific area on the Flutter Maps by specifying the northeast and southwest coordinate points to the [`initialLatLngBounds`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/initialLatLngBounds.html) property in the [`MapTileLayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTileLayer-class.html) and [`MapShapeLayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer-class.html). It renders the Flutter Maps by calculating the center coordinate and zoom level depending on the [`initialLatLngBounds`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/initialLatLngBounds.html) value. + +The [`initialLatLngBounds`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/initialLatLngBounds.html) property can be set at load time alone. You can use the [`latLngBounds`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/latLngBounds.html) property of [`MapZoomPanBehavior`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior-class.html) to dynamically update the bounds of the Flutter Maps. + +{% tabs %} +{% highlight Dart %} + +late List<_TouristPlaceDetails> _touristPlaces; +late MapZoomPanBehavior _zoomPanBehavior; +bool _canFitMarkers = false; + +@override +void initState() { + _zoomPanBehavior = MapZoomPanBehavior(); + _touristPlaces = <_TouristPlaceDetails>[ + const _TouristPlaceDetails( + MapLatLng(-25.6953, -54.4367), 'Iguazu Falls, Argentina'), + const _TouristPlaceDetails(MapLatLng(-50.9423, -73.4068), + 'Torres del Paine National Park, Patagonia, Chile'), + const _TouristPlaceDetails( + MapLatLng(-15.9254, -69.3354), 'Lake Titicaca, Bolivia'), + const _TouristPlaceDetails( + MapLatLng(-13.1631, -72.5450), 'Machu Picchu, Peru'), + const _TouristPlaceDetails( + MapLatLng(-0.1862504, -78.5706247), 'The Amazon via Quito, Ecuador'), + const _TouristPlaceDetails( + MapLatLng(5.9701, -62.5362), 'Angel Falls, Venezuela'), + const _TouristPlaceDetails( + MapLatLng(-14.0875, -75.7626), 'Huacachina, Peru'), + const _TouristPlaceDetails( + MapLatLng(-22.7953, -67.8361), 'Laguna Verde, Bolivia'), + const _TouristPlaceDetails( + MapLatLng(-50.5025092, -73.1997346), 'Perito Moreno, Venezuela'), + const _TouristPlaceDetails( + MapLatLng(-22.9068, -43.1729), 'Rio de Janeiro, Brazil'), + const _TouristPlaceDetails( + MapLatLng(5.1765, -59.4808), 'Kaieteur Falls, Guyana'), + const _TouristPlaceDetails( + MapLatLng(-33.4489, -70.6693), 'Santiago, Chile'), + const _TouristPlaceDetails( + MapLatLng(4.7110, -74.0721), 'Bogota, Colombia'), + const _TouristPlaceDetails( + MapLatLng(-1.3928, -78.4269), 'Banos, Ecuador'), + ]; + super.initState(); +} + +@override +Widget build(BuildContext context) { + return Scaffold( + body: Column( + children: [ + SfMaps( + layers: [ + MapTileLayer( + urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', + zoomPanBehavior: _zoomPanBehavior, + initialMarkersCount: _touristPlaces.length, + markerBuilder: (BuildContext context, int index) { + return MapMarker( + latitude: _touristPlaces[index].latLng.latitude, + longitude: _touristPlaces[index].latLng.longitude, + child: const Icon( + Icons.location_on, + color: Colors.red, + size: 20, + ), + ); + }, + ), + ], + ), + SizedBox(height: 10), + Container( + width: 300, + padding: EdgeInsets.zero, + child: CheckboxListTile( + activeColor: Colors.blue, + value: _canFitMarkers, + title: Text('Zoom marker to fit bounds'), + onChanged: (bool? value) { + _canFitMarkers = value!; + setState(() { + if (_canFitMarkers) { + // South America bounds. + _zoomPanBehavior.latLngBounds = const MapLatLngBounds( + MapLatLng(12.434375, -34.80546874999999), + MapLatLng(-55.891699218750006, -91.654150390625)); + } else { + // World bounds. + _zoomPanBehavior.latLngBounds = const MapLatLngBounds( + MapLatLng(-90.0, -180.0), MapLatLng(90.0, 180.0)); + } + }); + }, + ), + ), + ], + ), + ); +} + +class _TouristPlaceDetails { + const _TouristPlaceDetails(this.latLng, this.place); + final MapLatLng latLng; + final String place; +} + +{% endhighlight %} +{% endtabs %} + +![Zoom markers to fit bounds](images/markers/fit_bounds.jpg) + N> You can refer to our [Flutter Maps](https://www.syncfusion.com/flutter-widgets/flutter-maps) feature tour page for its groundbreaking feature representations. You can also explore our [Flutter Maps Markers example](https://flutter.syncfusion.com/#/maps/shape-layer/marker) that shows how to configure a Maps in Flutter. \ No newline at end of file diff --git a/Flutter/maps/overview.md b/Flutter/maps/overview.md index 8b0f2fc90..659c34740 100644 --- a/Flutter/maps/overview.md +++ b/Flutter/maps/overview.md @@ -1,50 +1,50 @@ ---- -layout: post -title: About Flutter Maps Control | Syncfusion® -description: Learn about the Syncfusion® Flutter Maps (SfMaps), its features, map layers, data visualization capabilities, and customization options. -platform: flutter -control: SfMaps -documentation: ug ---- - -# About Flutter Maps Control (SfMaps) - -[Flutter Maps](https://www.syncfusion.com/flutter-widgets/flutter-maps) is a powerful data visualization component that displays statistical information for geographical areas. Its rich feature set includes tile rendering from OpenStreetMap, Bing Maps, and other tile providers with marker support, as well as shape layer capabilities such as selection, legends, labels, markers, tooltips, bubbles, color mapping, and much more. - -To get started with the Flutter Maps widget, refer to the [Getting Started with Flutter Maps](https://help.syncfusion.com/flutter/maps/getting-started) documentation. - -## Shape layer - -Render GeoJSON data as geographical shapes or any custom shapes on a shape layer for powerful data visualization. Customize the appearance using built-in options to achieve your desired look. For example, you can render a map of the world or any particular country. - -![Maps shape layer overview](images/overview/maps-overview.png) - -### Features - -* **Data Labels** - Provide identification for shapes by displaying their names. Labels can be trimmed or hidden if they exceed shape boundaries. - -* **Markers** - Denote specific locations using built-in symbols or display custom widgets at particular latitude and longitude coordinates on the map. - -* **Bubbles** - Add information to shapes such as population density, number of users, and more. Bubbles can be rendered in different colors and sizes based on the data values of their assigned shapes. - -* **Shape Selection** - Select shapes to highlight specific areas on the map. You can use callbacks to perform custom actions during shape selection. - -* **Legend** - Provide clear information about the data plotted on the map. The legend toggling feature allows you to visualize only the shapes to which a specific legend applies. - -* **Colors** - Categorize shapes by customizing their colors based on underlying values. You can set shape colors for specific values or for ranges of values. - -* **Tooltip** - Display additional information about shapes and bubbles using customizable tooltips. - -* **Zooming and Panning** - Zoom in for a closer look at specific regions by pinching the map, scrolling the mouse wheel or track-pad, or using the toolbar on web platforms. Pan the map to navigate across regions. You can also customize the initial zoom level and center point. - -## Tile layer - -The interactive tile layer allows you to load map tiles from web map tile services such as Bing Maps, OpenStreetMap, Google Maps, TomTom, and others. Use markers to denote specific latitude and longitude coordinates in the tile layer as required. Zoom and pan the tile layer to navigate across regions and take a closer look. - -![Maps tile layer overview](images/overview/tile_layer_overview.png) - -### Features - -* **Markers** - Denote specific locations using built-in symbols or display custom widgets at particular latitude and longitude coordinates on the map. - -* **Zooming and Panning** - Zoom in for a closer look at specific regions by pinching the map, scrolling the mouse wheel or track-pad, or using the toolbar on web platforms. Pan the map to navigate across regions. You can also customize the initial zoom level and center point. +--- +layout: post +title: About Flutter Maps Control | Syncfusion® +description: Learn about the Syncfusion® Flutter Maps (SfMaps), its features, map layers, data visualization capabilities, and customization options. +platform: flutter +control: SfMaps +documentation: ug +--- + +# About Flutter Maps Control (SfMaps) + +[Flutter Maps](https://www.syncfusion.com/flutter-widgets/flutter-maps) is a powerful data visualization component that displays statistical information for geographical areas. Its rich feature set includes tile rendering from OpenStreetMap, Bing Maps, and other tile providers with marker support, as well as shape layer capabilities such as selection, legends, labels, markers, tooltips, bubbles, color mapping, and much more. + +To get started with the Flutter Maps widget, refer to the [Getting Started with Flutter Maps](https://help.syncfusion.com/flutter/maps/getting-started) documentation. + +## Shape layer + +Render GeoJSON data as geographical shapes or any custom shapes on a shape layer for powerful data visualization. Customize the appearance using built-in options to achieve your desired look. For example, you can render a map of the world or any particular country. + +![Maps shape layer overview](images/overview/maps-overview.png) + +### Features + +* **Data Labels** - Provide identification for shapes by displaying their names. Labels can be trimmed or hidden if they exceed shape boundaries. + +* **Markers** - Denote specific locations using built-in symbols or display custom widgets at particular latitude and longitude coordinates on the Flutter Maps. + +* **Bubbles** - Add information to shapes such as population density, number of users, and more. Bubbles can be rendered in different colors and sizes based on the data values of their assigned shapes. + +* **Shape Selection** - Select shapes to highlight specific areas on the Flutter Maps. You can use callbacks to perform custom actions during shape selection. + +* **Legend** - Provide clear information about the data plotted on the Flutter Maps. The legend toggling feature allows you to visualize only the shapes to which a specific legend applies. + +* **Colors** - Categorize shapes by customizing their colors based on underlying values. You can set shape colors for specific values or for ranges of values. + +* **Tooltip** - Display additional information about shapes and bubbles using customizable tooltips. + +* **Zooming and Panning** - Zoom in for a closer look at specific regions by pinching the map, scrolling the mouse wheel or track-pad, or using the toolbar on web platforms. Pan the Flutter Maps to navigate across regions. You can also customize the initial zoom level and center point. + +## Tile layer + +The interactive tile layer allows you to load map tiles from web map tile services such as Bing Maps, OpenStreetMap, Google Maps, TomTom, and others. Use markers to denote specific latitude and longitude coordinates in the tile layer as required. Zoom and pan the tile layer to navigate across regions and take a closer look. + +![Maps tile layer overview](images/overview/tile_layer_overview.png) + +### Features + +* **Markers** - Denote specific locations using built-in symbols or display custom widgets at particular latitude and longitude coordinates on the Flutter Maps. + +* **Zooming and Panning** - Zoom in for a closer look at specific regions by pinching the map, scrolling the mouse wheel or track-pad, or using the toolbar on web platforms. Pan the Flutter Maps to navigate across regions. You can also customize the initial zoom level and center point. diff --git a/Flutter/maps/right-to-left.md b/Flutter/maps/right-to-left.md index 993715177..a515db80e 100644 --- a/Flutter/maps/right-to-left.md +++ b/Flutter/maps/right-to-left.md @@ -1,296 +1,296 @@ ---- -layout: post -title: Right-to-Left (RTL) in Flutter Maps | Syncfusion® -description: Learn about right-to-left (RTL) support in Syncfusion® Flutter Maps (SfMaps), including map rendering, localization, and layout customization. -platform: flutter -control: SfMaps -documentation: ug ---- - -# Right-to-Left (RTL) in Flutter Maps (SfMaps) - -## Enable RTL rendering - -Right to left rendering can be achieved in the following ways: - -### Wrapping the SfMaps with Directionality widget - -The maps can be wrapped inside the [`Directionality`](https://api.flutter.dev/flutter/widgets/Directionality-class.html) widget and you can set the [`textDirection`](https://api.flutter.dev/flutter/widgets/Directionality/textDirection.html) property to `rtl`. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatelessWidget { - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Directionality( - textDirection: TextDirection.rtl, - child: Center( - child: SfMaps( - layers: [ - MapShapeLayer( - source: const MapShapeSource.asset( - "assets/world_map.json", - shapeDataField: "continent"), - ), - ], - ), - ) - ), - ), - ); - } -} - -{% endhighlight %} -{% endtabs %} - -### Changing the locale to RTL languages - -The maps elements will render in right to left direction if the locale belongs to RTL languages such as Arabic, Persian, Hebrew, Pashto, or Urdu. This can be achieved by specifying the MaterialApp properties such as `localizationsDelegates`, `supportedLocales`, `locale` and adding the flutter_localizations package to your pubspec.yaml file. - -{% tabs %} -{% highlight Dart %} - -dependencies: - flutter_localizations: - sdk: flutter - -{% endhighlight %} -{% endtabs %} - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:flutter_localizations/flutter_localizations.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatelessWidget { - @override - Widget build(BuildContext context) { - return MaterialApp( - localizationsDelegates: [ - GlobalMaterialLocalizations.delegate, - GlobalWidgetsLocalizations.delegate, - ], - supportedLocales: [ - Locale("fa", "IR"), - ], - locale: Locale("fa", "IR"), - home: Scaffold( - backgroundColor: Colors.white, - body: SfMaps( - layers: [ - MapShapeLayer( - source: const MapShapeSource.asset( - "assets/world_map.json", - shapeDataField: "continent"), - ), - ], - ), - ), - ); - } -} - -{% endhighlight %} -{% endtabs %} - -## RTL supported maps elements - -### Legend - -Legend items will be rendered from right to left direction. This is applicable for both shape and bubble legends with solid and bar types. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late List _data; - late MapShapeSource _mapSource; - - @override - void initState() { - super.initState(); - _data = [ - PopulationModel('Asia', 150, Color.fromRGBO(60, 120, 255, 0.8)), - PopulationModel('Africa', 45, Color.fromRGBO(51, 102, 255, 0.8)), - PopulationModel('Europe', 34, Color.fromRGBO(0, 57, 230, 0.8)), - PopulationModel('South America', 25, Color.fromRGBO(0, 51, 204, 0.8)), - PopulationModel('North America', 28, Color.fromRGBO(0, 38, 153, 0.8)), - PopulationModel('Australia', 5, Color.fromRGBO(0, 45, 179, 0.8)), - ]; - - _mapSource = MapShapeSource.asset( - "assets/world_map.json", - shapeDataField: "continent", - dataCount: _data.length, - primaryValueMapper: (int index) => _data[index].continent, - shapeColorValueMapper: (int index) => _data[index].color, - ); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: Container( - padding: const EdgeInsets.only(left: 10, right: 15, top: 30), - height: 350, - child: Directionality( - textDirection: TextDirection.rtl, - child: SfMaps( - layers: [ - MapShapeLayer( - source: _mapSource, - legend: MapLegend(MapElement.shape), - ) - ], - ), - ), - ), - ), - ); - } -} - -class PopulationModel { - const PopulationModel( - this.continent, this.populationDensityPerSqKm, this.color); - - final String continent; - final double populationDensityPerSqKm; - final Color color; -} - -{% endhighlight %} -{% endtabs %} - -![RTL legend support](images/right-to-left/legend-rtl.png) - -### Tooltip - -Tooltip text will be rendered from right to left direction. This is applicable for shape tooltip, bubble tooltip, and marker tooltip. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late List _data; - late MapShapeSource _mapSource; - - @override - void initState() { - super.initState(); - _data = [ - PopulationModel('Asia', 150, Color.fromRGBO(60, 120, 255, 0.8)), - PopulationModel('Africa', 45, Color.fromRGBO(51, 102, 255, 0.8)), - PopulationModel('Europe', 34, Color.fromRGBO(0, 57, 230, 0.8)), - PopulationModel('South America', 25, Color.fromRGBO(0, 51, 204, 0.8)), - PopulationModel('North America', 28, Color.fromRGBO(0, 38, 153, 0.8)), - PopulationModel('Australia', 5, Color.fromRGBO(0, 45, 179, 0.8)), - ]; - - _mapSource = MapShapeSource.asset( - "assets/world_map.json", - shapeDataField: "continent", - dataCount: _data.length, - primaryValueMapper: (int index) => _data[index].continent, - shapeColorValueMapper: (int index) => _data[index].color, - ); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: Container( - padding: const EdgeInsets.only(left: 10, right: 15, top: 30), - height: 350, - child: Directionality( - textDirection: TextDirection.rtl, - child: SfMaps( - layers: [ - MapShapeLayer( - source: _mapSource, - shapeTooltipBuilder: (BuildContext context, int index) { - return Container( - height: 50, - width: 190, - child: Column( - children: [ - Padding( - padding: EdgeInsets.all(5), - child: Row( - children: [ - Text('Continent : '), - Text(_data[index].continent), - ], - ), - ), - Padding( - padding: - EdgeInsets.only(left: 5, right: 5, bottom: 5), - child: Row( - children: [ - Text('Population : '), - Text(_data[index] - .populationDensityPerSqKm - .toStringAsFixed(0) + - ' per sq/km'), - ], - ), - ), - ], - ), - ); - }, - tooltipSettings: const MapTooltipSettings( - color: Colors.white, - strokeColor: Colors.black, - ), - ) - ], - ), - ), - ), - ), - ); - } -} - -class PopulationModel { - const PopulationModel( - this.continent, this.populationDensityPerSqKm, this.color); - - final String continent; - final double populationDensityPerSqKm; - final Color color; -} - -{% endhighlight %} -{% endtabs %} - -![RTL tooltip support](images/right-to-left/tooltip-rtl.png) +--- +layout: post +title: Right-to-Left (RTL) in Flutter Maps | Syncfusion® +description: Learn about right-to-left (RTL) support in Syncfusion® Flutter Maps (SfMaps), including map rendering, localization, and layout customization. +platform: flutter +control: SfMaps +documentation: ug +--- + +# Right-to-Left (RTL) in Flutter Maps (SfMaps) + +## Enable RTL rendering + +Right to left rendering can be achieved in the following ways: + +### Wrapping the SfMaps with Directionality widget + +The Flutter Maps can be wrapped inside the [`Directionality`](https://api.flutter.dev/flutter/widgets/Directionality-class.html) widget and you can set the [`textDirection`](https://api.flutter.dev/flutter/widgets/Directionality/textDirection.html) property to `rtl`. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatelessWidget { + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Directionality( + textDirection: TextDirection.rtl, + child: Center( + child: SfMaps( + layers: [ + MapShapeLayer( + source: const MapShapeSource.asset( + "assets/world_map.json", + shapeDataField: "continent"), + ), + ], + ), + ) + ), + ), + ); + } +} + +{% endhighlight %} +{% endtabs %} + +### Changing the locale to RTL languages + +The elements of the Flutter Maps will render in right to left direction if the locale belongs to RTL languages such as Arabic, Persian, Hebrew, Pashto, or Urdu. This can be achieved by specifying the MaterialApp properties such as `localizationsDelegates`, `supportedLocales`, `locale` and adding the flutter_localizations package to your pubspec.yaml file. + +{% tabs %} +{% highlight Dart %} + +dependencies: + flutter_localizations: + sdk: flutter + +{% endhighlight %} +{% endtabs %} + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:flutter_localizations/flutter_localizations.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatelessWidget { + @override + Widget build(BuildContext context) { + return MaterialApp( + localizationsDelegates: [ + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + ], + supportedLocales: [ + Locale("fa", "IR"), + ], + locale: Locale("fa", "IR"), + home: Scaffold( + backgroundColor: Colors.white, + body: SfMaps( + layers: [ + MapShapeLayer( + source: const MapShapeSource.asset( + "assets/world_map.json", + shapeDataField: "continent"), + ), + ], + ), + ), + ); + } +} + +{% endhighlight %} +{% endtabs %} + +## RTL supported maps elements + +### Legend + +Legend items will be rendered from right to left direction. This is applicable for both shape and bubble legends with solid and bar types. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late List _data; + late MapShapeSource _mapSource; + + @override + void initState() { + super.initState(); + _data = [ + PopulationModel('Asia', 150, Color.fromRGBO(60, 120, 255, 0.8)), + PopulationModel('Africa', 45, Color.fromRGBO(51, 102, 255, 0.8)), + PopulationModel('Europe', 34, Color.fromRGBO(0, 57, 230, 0.8)), + PopulationModel('South America', 25, Color.fromRGBO(0, 51, 204, 0.8)), + PopulationModel('North America', 28, Color.fromRGBO(0, 38, 153, 0.8)), + PopulationModel('Australia', 5, Color.fromRGBO(0, 45, 179, 0.8)), + ]; + + _mapSource = MapShapeSource.asset( + "assets/world_map.json", + shapeDataField: "continent", + dataCount: _data.length, + primaryValueMapper: (int index) => _data[index].continent, + shapeColorValueMapper: (int index) => _data[index].color, + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Container( + padding: const EdgeInsets.only(left: 10, right: 15, top: 30), + height: 350, + child: Directionality( + textDirection: TextDirection.rtl, + child: SfMaps( + layers: [ + MapShapeLayer( + source: _mapSource, + legend: MapLegend(MapElement.shape), + ) + ], + ), + ), + ), + ), + ); + } +} + +class PopulationModel { + const PopulationModel( + this.continent, this.populationDensityPerSqKm, this.color); + + final String continent; + final double populationDensityPerSqKm; + final Color color; +} + +{% endhighlight %} +{% endtabs %} + +![RTL legend support](images/right-to-left/legend-rtl.png) + +### Tooltip + +Tooltip text will be rendered from right to left direction. This is applicable for shape tooltip, bubble tooltip, and marker tooltip. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late List _data; + late MapShapeSource _mapSource; + + @override + void initState() { + super.initState(); + _data = [ + PopulationModel('Asia', 150, Color.fromRGBO(60, 120, 255, 0.8)), + PopulationModel('Africa', 45, Color.fromRGBO(51, 102, 255, 0.8)), + PopulationModel('Europe', 34, Color.fromRGBO(0, 57, 230, 0.8)), + PopulationModel('South America', 25, Color.fromRGBO(0, 51, 204, 0.8)), + PopulationModel('North America', 28, Color.fromRGBO(0, 38, 153, 0.8)), + PopulationModel('Australia', 5, Color.fromRGBO(0, 45, 179, 0.8)), + ]; + + _mapSource = MapShapeSource.asset( + "assets/world_map.json", + shapeDataField: "continent", + dataCount: _data.length, + primaryValueMapper: (int index) => _data[index].continent, + shapeColorValueMapper: (int index) => _data[index].color, + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Container( + padding: const EdgeInsets.only(left: 10, right: 15, top: 30), + height: 350, + child: Directionality( + textDirection: TextDirection.rtl, + child: SfMaps( + layers: [ + MapShapeLayer( + source: _mapSource, + shapeTooltipBuilder: (BuildContext context, int index) { + return Container( + height: 50, + width: 190, + child: Column( + children: [ + Padding( + padding: EdgeInsets.all(5), + child: Row( + children: [ + Text('Continent : '), + Text(_data[index].continent), + ], + ), + ), + Padding( + padding: + EdgeInsets.only(left: 5, right: 5, bottom: 5), + child: Row( + children: [ + Text('Population : '), + Text(_data[index] + .populationDensityPerSqKm + .toStringAsFixed(0) + + ' per sq/km'), + ], + ), + ), + ], + ), + ); + }, + tooltipSettings: const MapTooltipSettings( + color: Colors.white, + strokeColor: Colors.black, + ), + ) + ], + ), + ), + ), + ), + ); + } +} + +class PopulationModel { + const PopulationModel( + this.continent, this.populationDensityPerSqKm, this.color); + + final String continent; + final double populationDensityPerSqKm; + final Color color; +} + +{% endhighlight %} +{% endtabs %} + +![RTL tooltip support](images/right-to-left/tooltip-rtl.png) diff --git a/Flutter/maps/selection.md b/Flutter/maps/selection.md index a97dd8057..8d6e4e62f 100644 --- a/Flutter/maps/selection.md +++ b/Flutter/maps/selection.md @@ -1,288 +1,288 @@ ---- -layout: post -title: Shape Selection in Flutter Maps | Syncfusion® -description: Learn about shape selection in Syncfusion® Flutter Maps (SfMaps), including selection customization, interaction, highlighting, and styling options. -platform: flutter -control: SfMaps -documentation: ug ---- - -# Shape Selection in Flutter Maps (SfMaps) - -You can select a shape to highlight a specific area on a map. You can also use callbacks to perform custom actions during shape selection. - -## Enable shape selection - -You can enable shape selection on a map using the [`MapShapeLayer.onSelectionChanged`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/onSelectionChanged.html) property along with setting the [`selectedIndex`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/selectedIndex.html) property. The default value of the [`selectedIndex`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/selectedIndex.html) property is `-1`. - -The [`onSelectionChanged`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/onSelectionChanged.html) callback is triggered when a user selects a shape by tapping or clicking, or when a shape is selected programmatically. It provides the index of the selected shape. - -N> You must update the selectedIndex in the [`MapShapeLayer.onSelectionChanged`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/onSelectionChanged.html) callback to reflect the changes in the UI. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late List data; - late MapShapeSource dataSource; - int selectedIndex = 1; - - @override - void initState() { - super.initState(); - data = const [ - Model('Asia', 'Asia', Color.fromRGBO(60, 120, 255, 0.8)), - Model('Africa', 'Africa', Color.fromRGBO(51, 102, 255, 0.8)), - Model('Europe', 'Europe', Color.fromRGBO(0, 57, 230, 0.8)), - Model('South America', 'SA', Color.fromRGBO(0, 51, 204, 0.8)), - Model('Australia', 'Australia', Color.fromRGBO(0, 45, 179, 0.8)), - Model('North America', 'NA', Color.fromRGBO(0, 38, 153, 0.8)) - ]; - - dataSource = MapShapeSource.asset( - "assets/world_map.json", - shapeDataField: "continent", - dataCount: data.length, - primaryValueMapper: (int index) => data[index].continent, - shapeColorValueMapper: (int index) => data[index].color, - ); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: Container( - height: 350, - child: Padding( - padding: EdgeInsets.only(left: 15, right: 15), - child: SfMaps( - layers: [ - MapShapeLayer( - source: dataSource, - selectedIndex: selectedIndex, - onSelectionChanged: (int index) { - setState(() { - selectedIndex = index; - }); - }, - ), - ], - ), - ), - ), - ), - ); - } -} - -class Model { - const Model(this.continent, this.code, this.color); - - final String continent; - final String code; - final Color color; -} - -{% endhighlight %} -{% endtabs %} - -![Enable shape selection](images/selection/enable-shape-selection.png) - -N> -* Refer to the [`MapSelectionSettings`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapSelectionSettings-class.html) class for customizing the selected shape's appearance. - -## Appearance customization - -You can customize the following aspects of the selected shape: - -* **Background color** - Change the background color of the selected shape using the [`MapSelectionSettings.color`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapSelectionSettings/color.html) property. -* **Stroke width** - Change the stroke width of the selected shape using the [`MapSelectionSettings.strokeWidth`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapSelectionSettings/strokeWidth.html) property. -* **Stroke color** - Change the stroke color of the selected shape using the [`MapSelectionSettings.strokeColor`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapSelectionSettings/strokeColor.html) property. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late List data; - late MapShapeSource dataSource; - int selectedIndex = 5; - - @override - void initState() { - super.initState(); - data = const [ - Model('Asia', 'Asia', Color.fromRGBO(60, 120, 255, 0.8)), - Model('Africa', 'Africa', Color.fromRGBO(51, 102, 255, 0.8)), - Model('Europe', 'Europe', Color.fromRGBO(0, 57, 230, 0.8)), - Model('South America', 'SA', Color.fromRGBO(0, 51, 204, 0.8)), - Model('Australia', 'Australia', Color.fromRGBO(0, 45, 179, 0.8)), - Model('North America', 'NA', Color.fromRGBO(0, 38, 153, 0.8)) - ]; - - dataSource = MapShapeSource.asset( - "assets/world_map.json", - shapeDataField: "continent", - dataCount: data.length, - primaryValueMapper: (int index) => data[index].continent, - shapeColorValueMapper: (int index) => data[index].color, - ); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: Container( - height: 350, - child: Padding( - padding: EdgeInsets.only(left: 15, right: 15), - child: SfMaps( - layers: [ - MapShapeLayer( - source: dataSource, - selectedIndex: selectedIndex, - onSelectionChanged: (int index) { - setState(() { - selectedIndex = index; - }); - }, - selectionSettings: MapSelectionSettings( - color: Colors.orange, - strokeColor: Colors.red[900], - strokeWidth: 3, - ), - ), - ], - ), - ), - ), - ), - ); - } -} - -class Model { - const Model(this.continent, this.code, this.color); - - final String continent; - final String code; - final Color color; -} - -{% endhighlight %} -{% endtabs %} - -Using SfMapsTheme - -You can also customize the appearance of the selected shape using [`SfMapsTheme`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsTheme-class.html): - -* **Background color** - Change the background color of the selected shape using the [`SfMapsThemeData.selectionColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsThemeData/selectionColor.html) property. -* **Stroke width** - Change the stroke width of the selected shape using the [`SfMapsThemeData.selectionStrokeWidth`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsThemeData/selectionStrokeWidth.html) property. -* **Stroke color** - Change the stroke color of the selected shape using the [`SfMapsThemeData.selectionStrokeColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsThemeData/selectionStrokeColor.html) property. - -N> You must import the `theme.dart` library from the [`Core`](https://pub.dev/packages/syncfusion_flutter_core) package to use [`SfMapsTheme`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsTheme-class.html). - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late List data; - late MapShapeSource dataSource; - int selectedIndex = 5; - - @override - void initState() { - super.initState(); - data = const [ - Model('Asia', 'Asia', Color.fromRGBO(60, 120, 255, 0.8)), - Model('Africa', 'Africa', Color.fromRGBO(51, 102, 255, 0.8)), - Model('Europe', 'Europe', Color.fromRGBO(0, 57, 230, 0.8)), - Model('South America', 'SA', Color.fromRGBO(0, 51, 204, 0.8)), - Model('Australia', 'Australia', Color.fromRGBO(0, 45, 179, 0.8)), - Model('North America', 'NA', Color.fromRGBO(0, 38, 153, 0.8)) - ]; - - dataSource = MapShapeSource.asset( - "assets/world_map.json", - shapeDataField: "continent", - dataCount: data.length, - primaryValueMapper: (int index) => data[index].continent, - shapeColorValueMapper: (int index) => data[index].color, - ); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: Container( - height: 350, - child: Padding( - padding: EdgeInsets.only(left: 15, right: 15), - child: SfMapsTheme( - data: SfMapsThemeData( - selectionColor: Colors.orange, - selectionStrokeWidth: 3, - selectionStrokeColor: Colors.red[900], - ), - child: SfMaps( - layers: [ - MapShapeLayer( - source: dataSource, - selectedIndex: selectedIndex, - onSelectionChanged: (int index) { - setState(() { - selectedIndex = index; - }); - }, - ), - ], - ), - ) - ), - ), - ), - ); - } -} - -class Model { - const Model(this.continent, this.code, this.color); - - final String continent; - final String code; - final Color color; -} - -{% endhighlight %} -{% endtabs %} - -![Selection customization](images/selection/selection-customization.png) - +--- +layout: post +title: Shape Selection in Flutter Maps | Syncfusion® +description: Learn about shape selection in Syncfusion® Flutter Maps (SfMaps), including selection customization, interaction, highlighting, and styling options. +platform: flutter +control: SfMaps +documentation: ug +--- + +# Shape Selection in Flutter Maps (SfMaps) + +You can select a shape to highlight a specific area on a Flutter Maps. You can also use callbacks to perform custom actions during shape selection. + +## Enable shape selection + +You can enable shape selection on a Flutter Maps using the [`MapShapeLayer.onSelectionChanged`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/onSelectionChanged.html) property along with setting the [`selectedIndex`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/selectedIndex.html) property. The default value of the [`selectedIndex`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/selectedIndex.html) property is `-1`. + +The [`onSelectionChanged`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/onSelectionChanged.html) callback is triggered when a user selects a shape by tapping or clicking, or when a shape is selected programmatically. It provides the index of the selected shape. + +N> You must update the selectedIndex in the [`MapShapeLayer.onSelectionChanged`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/onSelectionChanged.html) callback to reflect the changes in the UI. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late List data; + late MapShapeSource dataSource; + int selectedIndex = 1; + + @override + void initState() { + super.initState(); + data = const [ + Model('Asia', 'Asia', Color.fromRGBO(60, 120, 255, 0.8)), + Model('Africa', 'Africa', Color.fromRGBO(51, 102, 255, 0.8)), + Model('Europe', 'Europe', Color.fromRGBO(0, 57, 230, 0.8)), + Model('South America', 'SA', Color.fromRGBO(0, 51, 204, 0.8)), + Model('Australia', 'Australia', Color.fromRGBO(0, 45, 179, 0.8)), + Model('North America', 'NA', Color.fromRGBO(0, 38, 153, 0.8)) + ]; + + dataSource = MapShapeSource.asset( + "assets/world_map.json", + shapeDataField: "continent", + dataCount: data.length, + primaryValueMapper: (int index) => data[index].continent, + shapeColorValueMapper: (int index) => data[index].color, + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Container( + height: 350, + child: Padding( + padding: EdgeInsets.only(left: 15, right: 15), + child: SfMaps( + layers: [ + MapShapeLayer( + source: dataSource, + selectedIndex: selectedIndex, + onSelectionChanged: (int index) { + setState(() { + selectedIndex = index; + }); + }, + ), + ], + ), + ), + ), + ), + ); + } +} + +class Model { + const Model(this.continent, this.code, this.color); + + final String continent; + final String code; + final Color color; +} + +{% endhighlight %} +{% endtabs %} + +![Enable shape selection](images/selection/enable-shape-selection.png) + +N> +* Refer to the [`MapSelectionSettings`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapSelectionSettings-class.html) class for customizing the selected shape's appearance. + +## Appearance customization + +You can customize the following aspects of the selected shape: + +* **Background color** - Change the background color of the selected shape using the [`MapSelectionSettings.color`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapSelectionSettings/color.html) property. +* **Stroke width** - Change the stroke width of the selected shape using the [`MapSelectionSettings.strokeWidth`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapSelectionSettings/strokeWidth.html) property. +* **Stroke color** - Change the stroke color of the selected shape using the [`MapSelectionSettings.strokeColor`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapSelectionSettings/strokeColor.html) property. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late List data; + late MapShapeSource dataSource; + int selectedIndex = 5; + + @override + void initState() { + super.initState(); + data = const [ + Model('Asia', 'Asia', Color.fromRGBO(60, 120, 255, 0.8)), + Model('Africa', 'Africa', Color.fromRGBO(51, 102, 255, 0.8)), + Model('Europe', 'Europe', Color.fromRGBO(0, 57, 230, 0.8)), + Model('South America', 'SA', Color.fromRGBO(0, 51, 204, 0.8)), + Model('Australia', 'Australia', Color.fromRGBO(0, 45, 179, 0.8)), + Model('North America', 'NA', Color.fromRGBO(0, 38, 153, 0.8)) + ]; + + dataSource = MapShapeSource.asset( + "assets/world_map.json", + shapeDataField: "continent", + dataCount: data.length, + primaryValueMapper: (int index) => data[index].continent, + shapeColorValueMapper: (int index) => data[index].color, + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Container( + height: 350, + child: Padding( + padding: EdgeInsets.only(left: 15, right: 15), + child: SfMaps( + layers: [ + MapShapeLayer( + source: dataSource, + selectedIndex: selectedIndex, + onSelectionChanged: (int index) { + setState(() { + selectedIndex = index; + }); + }, + selectionSettings: MapSelectionSettings( + color: Colors.orange, + strokeColor: Colors.red[900], + strokeWidth: 3, + ), + ), + ], + ), + ), + ), + ), + ); + } +} + +class Model { + const Model(this.continent, this.code, this.color); + + final String continent; + final String code; + final Color color; +} + +{% endhighlight %} +{% endtabs %} + +Using SfMapsTheme + +You can also customize the appearance of the selected shape using [`SfMapsTheme`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsTheme-class.html): + +* **Background color** - Change the background color of the selected shape using the [`SfMapsThemeData.selectionColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsThemeData/selectionColor.html) property. +* **Stroke width** - Change the stroke width of the selected shape using the [`SfMapsThemeData.selectionStrokeWidth`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsThemeData/selectionStrokeWidth.html) property. +* **Stroke color** - Change the stroke color of the selected shape using the [`SfMapsThemeData.selectionStrokeColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsThemeData/selectionStrokeColor.html) property. + +N> You must import the `theme.dart` library from the [`Core`](https://pub.dev/packages/syncfusion_flutter_core) package to use [`SfMapsTheme`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsTheme-class.html). + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late List data; + late MapShapeSource dataSource; + int selectedIndex = 5; + + @override + void initState() { + super.initState(); + data = const [ + Model('Asia', 'Asia', Color.fromRGBO(60, 120, 255, 0.8)), + Model('Africa', 'Africa', Color.fromRGBO(51, 102, 255, 0.8)), + Model('Europe', 'Europe', Color.fromRGBO(0, 57, 230, 0.8)), + Model('South America', 'SA', Color.fromRGBO(0, 51, 204, 0.8)), + Model('Australia', 'Australia', Color.fromRGBO(0, 45, 179, 0.8)), + Model('North America', 'NA', Color.fromRGBO(0, 38, 153, 0.8)) + ]; + + dataSource = MapShapeSource.asset( + "assets/world_map.json", + shapeDataField: "continent", + dataCount: data.length, + primaryValueMapper: (int index) => data[index].continent, + shapeColorValueMapper: (int index) => data[index].color, + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Container( + height: 350, + child: Padding( + padding: EdgeInsets.only(left: 15, right: 15), + child: SfMapsTheme( + data: SfMapsThemeData( + selectionColor: Colors.orange, + selectionStrokeWidth: 3, + selectionStrokeColor: Colors.red[900], + ), + child: SfMaps( + layers: [ + MapShapeLayer( + source: dataSource, + selectedIndex: selectedIndex, + onSelectionChanged: (int index) { + setState(() { + selectedIndex = index; + }); + }, + ), + ], + ), + ) + ), + ), + ), + ); + } +} + +class Model { + const Model(this.continent, this.code, this.color); + + final String continent; + final String code; + final Color color; +} + +{% endhighlight %} +{% endtabs %} + +![Selection customization](images/selection/selection-customization.png) + N> You can refer to our [Flutter Maps](https://www.syncfusion.com/flutter-widgets/flutter-maps) feature tour page for its groundbreaking feature representations. You can also explore our [Flutter Maps Selection example](https://flutter.syncfusion.com/#/maps/shape-layer/selection) that shows how to configure a Maps in Flutter. \ No newline at end of file diff --git a/Flutter/maps/shape-sublayer.md b/Flutter/maps/shape-sublayer.md index 9e386c14c..428ea35b3 100644 --- a/Flutter/maps/shape-sublayer.md +++ b/Flutter/maps/shape-sublayer.md @@ -1,954 +1,954 @@ ---- -layout: post -title: Shape Sublayer in Flutter Maps | Syncfusion® -description: Learn about shape sublayers in Syncfusion® Flutter Maps (SfMaps), including shape layer customization, data visualization, and map overlays. -platform: flutter -control: SfMaps -documentation: ug ---- - -# Shape Sublayer in Flutter Maps (SfMaps) - -The shape sublayer is where geographical rendering happens for the sublayer. This is similar to the main [`shape layer`](https://help.syncfusion.com/flutter/maps/getting-started#add-a-geojson-file-for-shape-layer) rendering. This section explains how to add a shape sublayer on both the shape layer and tile layer. - -## Shape sublayer on tile layer - -The [`sublayers`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/sublayers.html) property in [`MapTileLayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTileLayer-class.html) contains a collection of [`MapSublayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapSublayer-class.html). The actual geographical rendering is done in each [`MapShapeSublayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer-class.html). The [`source`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer/source.html) property of the [`MapShapeSublayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer-class.html) is of type [`MapShapeSource`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource-class.html). The path of the .json file which contains the GeoJSON data must be set to the [`MapShapeSource`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource-class.html). - -The [`shapeDataField`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeDataField.html) property of the [`MapShapeSource`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource-class.html) is used to refer to the unique field name in the .json file to identify each shape. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late MapShapeSource _sublayerSource; - - @override - void initState() { - super.initState(); - - _sublayerSource = MapShapeSource.asset( - 'assets/africa.json', - shapeDataField: 'name', - ); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Padding( - padding: const EdgeInsets.only(left: 15, right: 15), - child: SfMaps( - layers: [ - MapTileLayer( - urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', - sublayers: [ - MapShapeSublayer( - source: _sublayerSource, - ), - ], - ), - ], - ), - ), - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Tile sublayer support](images/shape-sublayer/tile-sublayer.png) - -N> -* Refer to the [`MapTileLayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTileLayer-class.html) documentation for adding a tile layer in [`SfMaps`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/SfMaps-class.html). - -## Shape sublayer on shape layer - -The [`sublayers`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/sublayers.html) property in [`MapShapeLayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer-class.html) contains a collection of [`MapSublayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapSublayer-class.html). The actual geographical rendering is done in each [`MapShapeSublayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer-class.html). The [`source`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer/source.html) property of the [`MapShapeSublayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer-class.html) is of type [`MapShapeSource`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource-class.html). The path of the .json file which contains the GeoJSON data must be set to the [`MapShapeSource`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource-class.html). - -The [`shapeDataField`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeDataField.html) property of the [`MapShapeSource`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource-class.html) is used to refer to the unique field name in the .json file to identify each shape. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late MapShapeSource _shapeSource; - late MapShapeSource _sublayerSource; - - @override - void initState() { - super.initState(); - _shapeSource = MapShapeSource.asset( - "assets/world_map.json", - shapeDataField: "continent", - ); - - _sublayerSource = MapShapeSource.asset( - 'assets/africa.json', - shapeDataField: 'name', - ); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Padding( - padding: const EdgeInsets.only(left: 15, right: 15), - child: SfMaps( - layers: [ - MapShapeLayer( - source: _shapeSource, - sublayers: [ - MapShapeSublayer( - source: _sublayerSource, - ), - ], - ), - ], - ), - ), - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Shape sublayer support](images/shape-sublayer/shape-sublayer.png) - -N> -* Refer the [`MapShapeLayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer-class.html), for adding shape layer in [`SfMaps`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/SfMaps-class.html). - -## Color and stroke color - -You can change the color, strokeColor, and strokeWidth of the shape sublayer using the [`color`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer/color.html), [`strokeColor`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer/strokeColor.html), and [`strokeWidth`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer/strokeWidth.html) properties. - -N> It is applicable for both tile layer and shape layer. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late MapShapeSource _shapeSource; - late MapShapeSource _sublayerSource; - - @override - void initState() { - super.initState(); - _shapeSource = MapShapeSource.asset( - "assets/world_map.json", - shapeDataField: "continent", - ); - - _sublayerSource = MapShapeSource.asset( - 'assets/africa.json', - shapeDataField: 'name', - ); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Padding( - padding: const EdgeInsets.only(left: 15, right: 15), - child: SfMaps( - layers: [ - MapShapeLayer( - source: _shapeSource, - sublayers: [ - MapShapeSublayer( - source: _sublayerSource, - color: Colors.blue[100], - strokeWidth: 2, - strokeColor: Colors.blue[800], - ), - ], - ), - ], - ), - ), - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Shape sublayer color](images/shape-sublayer/sublayer-color.png) - -## Equal color mapping - -You can apply color to the sublayer shape by comparing a value that returns from the [`shapeColorValueMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeColorValueMapper.html) with the [`MapColorMapper.value`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapColorMapper/value.html). For the matched values, the [`MapColorMapper.color`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapColorMapper/color.html) will be applied to the respective shapes. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late List data; - late MapShapeSource sublayerDataSource; - late MapShapeSource shapeDataSource; - - @override - void initState() { - data = [ - Model('Algeria', "Low"), - Model('Nigeria', "High"), - Model('Libya', "High"), - ]; - - shapeDataSource = MapShapeSource.asset( - "assets/world_map.json", - shapeDataField: 'continent', - ); - - sublayerDataSource = MapShapeSource.asset( - "assets/africa.json", - shapeDataField: "name", - dataCount: data.length, - primaryValueMapper: (int index) { - return data[index].state; - }, - shapeColorValueMapper: (int index) { - return data[index].storage; - }, - shapeColorMappers: [ - MapColorMapper(value: "Low", color: Colors.red), - MapColorMapper(value: "High", color: Colors.green) - ], - ); - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Padding( - padding: EdgeInsets.only(left: 15, right: 15), - child: SfMaps( - layers: [ - MapShapeLayer( - source: shapeDataSource, - sublayers: [ - MapShapeSublayer( - source: sublayerDataSource, - ) - ], - ), - ], - ), - ), - ); - } -} - -class Model { - const Model(this.state, this.storage); - - final String state; - final String storage; -} - -{% endhighlight %} -{% endtabs %} - -![Equal color mapping](images/shape-sublayer/equal_color_mapping.png) - -## Range color mapping - -You can apply color to the sublayer shape based on whether the value returned from [`shapeColorValueMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeColorValueMapper.html) falls within the [`MapColorMapper.from`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapColorMapper/from.html) and [`MapColorMapper.to`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapColorMapper/to.html) range. Then, the [`MapColorMapper.color`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapColorMapper/color.html) will be applied to the respective shapes. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late List data; - late MapShapeSource sublayerDataSource; - late MapShapeSource shapeDataSource; - - @override - void initState() { - data = [ - Model('Algeria', 196), - Model('Nigeria', 280), - Model('Libya', 45), - ]; - - shapeDataSource = MapShapeSource.asset( - "assets/world_map.json", - shapeDataField: 'continent', - ); - - sublayerDataSource = MapShapeSource.asset( - "assets/africa.json", - shapeDataField: "name", - dataCount: data.length, - primaryValueMapper: (int index) { - return data[index].state; - }, - shapeColorValueMapper: (int index) => data[index].count, - shapeColorMappers: [ - MapColorMapper(from: 0, to: 100, color: Colors.red), - MapColorMapper(from: 101, to: 300, color: Colors.green) - ], - ); - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Padding( - padding: EdgeInsets.only(left: 15, right: 15), - child: SfMaps( - layers: [ - MapShapeLayer( - source: shapeDataSource, - sublayers: [ - MapShapeSublayer( - source: sublayerDataSource, - ) - ], - ), - ], - ), - ), - ); - } -} - -class Model { - const Model(this.state, this.count); - - final String state; - final double count; -} - -{% endhighlight %} -{% endtabs %} - -![Range color mapping](images/shape-sublayer/range_color_mapping.png) - -## Enable data labels and its customization - -You can enable data labels for the shape sublayer using the [`showDataLabels`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer/showDataLabels.html) property and customize the data labels text using the [`dataLabelMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/dataLabelMapper.html) property. - -N> Refer to the [`DataLabels`](https://help.syncfusion.com/flutter/maps/data-labels) section, for customizing data labels. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late MapShapeSource _shapeSource; - late MapShapeSource _sublayerSource; - late List _sublayerData; - late MapZoomPanBehavior _zoomPanBehavior; - - @override - void initState() { - super.initState(); - _shapeSource = MapShapeSource.asset( - "assets/world_map.json", - shapeDataField: "continent", - ); - - _sublayerData = [ - DataModel('Algeria', Colors.green, 'Algeria'), - DataModel('Libya', Colors.teal, 'Libya'), - DataModel('Egypt', Colors.blue, 'Egypt'), - DataModel('Mali', Colors.purple, 'Mali'), - DataModel('Niger', Colors.indigo, 'Niger'), - DataModel('Nigeria', Colors.purpleAccent, 'Nigeria'), - DataModel('Chad', Colors.lightGreen, 'Chad'), - DataModel('Sudan', Colors.redAccent, 'Sudan'), - DataModel('Mauritania', Colors.orange, 'Mauritania'), - DataModel('South Sudan', Colors.lime, 'South Sudan'), - DataModel('Ethiopia', Colors.greenAccent, 'Ethiopia') - ]; - - _sublayerSource = MapShapeSource.asset( - 'assets/africa.json', - shapeDataField: 'name', - dataCount: _sublayerData.length, - primaryValueMapper: (int index) => _sublayerData[index].key, - dataLabelMapper: (int index) => _sublayerData[index].stateCode, - ); - _zoomPanBehavior = MapZoomPanBehavior( - zoomLevel: 3, - focalLatLng: MapLatLng(38.9637, 35.2433), - ); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: SfMaps( - layers: [ - MapShapeLayer( - source: _shapeSource, - zoomPanBehavior: _zoomPanBehavior, - sublayers: [ - MapShapeSublayer( - source: _sublayerSource, - showDataLabels: true, - dataLabelSettings: const MapDataLabelSettings( - overflowMode: MapLabelOverflow.ellipsis, - textStyle: const TextStyle( - color: Colors.red, - fontSize: 12, - fontWeight: FontWeight.bold, - fontStyle: FontStyle.italic, - fontFamily: 'Times'), - ), - ), - ], - ), - ], - ), - ); - } - DataModel(this.key, this.color, this.stateCode); - - final String key; - final Color color; - final String stateCode; -} - -{% endhighlight %} -{% endtabs %} - -![Shape sublayer data labels](images/shape-sublayer/sublayer-data-labels.png) - -## Add bubbles to the sublayer - -You can enable bubbles for the shape sublayer using the [`bubbleSizeMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/bubbleSizeMapper.html) property and customize the bubbles appearance using the [`bubbleSettings`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer/bubbleSettings.html) property. You can also enable tooltips for the shape sublayer bubbles using the [`bubbleTooltipBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer/bubbleTooltipBuilder.html) property. - -N> It is applicable for both tile layer and shape layer. - -N> Refer to the [`Bubbles`](https://help.syncfusion.com/flutter/maps/bubble#tooltip-for-the-bubbles) section, to know more about the bubbles customization. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late MapShapeSource _shapeSource; - late MapShapeSource _sublayerSource; - late List _sublayerData; - late MapZoomPanBehavior _zoomPanBehavior; - - @override - void initState() { - super.initState(); - _shapeSource = MapShapeSource.asset( - "assets/world_map.json", - shapeDataField: "continent", - ); - - _sublayerData = [ - DataModel('Algeria', Colors.green, 36232), - DataModel('Libya', Colors.teal, 34121), - DataModel('Egypt', Colors.blue, 43453), - DataModel('Mali', Colors.purple, 28123), - DataModel('Niger', Colors.indigo, 40111), - DataModel('Nigeria', Colors.purpleAccent, 30232), - DataModel('Chad', Colors.lightGreen, 48132), - DataModel('Sudan', Colors.redAccent, 52654), - DataModel('Mauritania', Colors.orange, 42231), - DataModel('South Sudan', Colors.lime, 40421), - DataModel('Ethiopia', Colors.greenAccent, 27198) - ]; - - _sublayerSource = MapShapeSource.asset( - 'assets/africa.json', - shapeDataField: 'name', - dataCount: _sublayerData.length, - primaryValueMapper: (int index) => _sublayerData[index].key, - bubbleColorValueMapper: (int index) => _sublayerData[index].color, - bubbleSizeMapper: (int index) => _sublayerData[index].size, - ); - _zoomPanBehavior = MapZoomPanBehavior( - zoomLevel: 3, - focalLatLng: MapLatLng(38.9637, 35.2433), - ); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: SfMaps( - layers: [ - MapShapeLayer( - source: _shapeSource, - zoomPanBehavior: _zoomPanBehavior, - sublayers: [ - MapShapeSublayer( - source: _sublayerSource, - bubbleSettings: const MapBubbleSettings( - minRadius: 5, - maxRadius: 20, - ), - bubbleTooltipBuilder: (BuildContext context, int index) { - return Container( - height: 40, - width: 120, - padding: const EdgeInsets.all(5), - child: Column( - children: [ - Row( - children: [ - Text('State : ', - style: TextStyle(color: Colors.white)), - Text(_sublayerData[index].key, - style: TextStyle(color: Colors.white)), - ], - ), - Row( - children: [ - Text('Population : ', - style: TextStyle(color: Colors.white)), - Text(_sublayerData[index].size.toStringAsFixed(0), - style: TextStyle(color: Colors.white)), - ], - ), - ], - ), - ); - }, - ), - ], - ), - ], - ), - ); - } -} - -class DataModel { - DataModel(this.key, this.color, this.size); - - final String key; - final Color color; - final double size; -} - -{% endhighlight %} -{% endtabs %} - -![Shape sublayer bubbles](images/shape-sublayer/sublayer-bubbles.png) - -## Enable tooltip for shape sublayer - -You can enable tooltips for the shape sublayer using the [`shapeTooltipBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer/shapeTooltipBuilder.html) property. - -N> It is applicable for both tile layer and shape layer. - -N> Refer to the [`Tooltip`](https://help.syncfusion.com/flutter/maps/tooltip) section to know more about the tooltip customization. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late MapShapeSource _shapeSource; - late MapShapeSource _sublayerSource; - late List _sublayerData; - late MapZoomPanBehavior _zoomPanBehavior; - - @override - void initState() { - super.initState(); - _shapeSource = MapShapeSource.asset( - "assets/world_map.json", - shapeDataField: "continent", - ); - - _sublayerData = [ - DataModel('Algeria', Colors.green, 36232), - DataModel('Libya', Colors.teal, 34121), - DataModel('Egypt', Colors.blue, 43453), - DataModel('Mali', Colors.purple, 28123), - DataModel('Niger', Colors.indigo, 40111), - DataModel('Nigeria', Colors.purpleAccent, 30232), - DataModel('Chad', Colors.lightGreen, 48132), - DataModel('Sudan', Colors.redAccent, 52654), - DataModel('Mauritania', Colors.orange, 42231), - DataModel('South Sudan', Colors.lime, 40421), - DataModel('Ethiopia', Colors.greenAccent, 27198) - ]; - - _sublayerSource = MapShapeSource.asset( - 'assets/africa.json', - shapeDataField: 'name', - dataCount: _sublayerData.length, - primaryValueMapper: (int index) => _sublayerData[index].key, - shapeColorValueMapper: (int index) => _sublayerData[index].color, - ); - _zoomPanBehavior = MapZoomPanBehavior( - zoomLevel: 3, - focalLatLng: MapLatLng(38.9637, 35.2433), - ); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: SfMaps( - layers: [ - MapShapeLayer( - source: _shapeSource, - zoomPanBehavior: _zoomPanBehavior, - sublayers: [ - MapShapeSublayer( - source: _sublayerSource, - shapeTooltipBuilder: (BuildContext context, int index) { - return Container( - height: 40, - width: 120, - padding: const EdgeInsets.all(5), - child: Column( - children: [ - Row( - children: [ - Text('State : ', - style: TextStyle(color: Colors.white)), - Text(_sublayerData[index].key, - style: TextStyle(color: Colors.white)), - ], - ), - Row( - children: [ - Text('Population : ', - style: TextStyle(color: Colors.white)), - Text(_sublayerData[index].size.toStringAsFixed(0), - style: TextStyle(color: Colors.white)), - ], - ), - ], - ), - ); - }, - ), - ], - ), - ], - ), - ); - } -} - -class DataModel { - DataModel(this.key, this.color, this.size); - - final String key; - final Color color; - final double size; -} - -{% endhighlight %} -{% endtabs %} - -![Shape sublayer shape tooltip](images/shape-sublayer/sublayer-shape-tooltip.png) - -## Selection - -You can enable shape sublayer selection using the [`onSelectionChanged`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer/onSelectionChanged.html) callback along with setting the [`selectedIndex`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer/selectedIndex.html) property. - -The [`onSelectionChanged`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer/onSelectionChanged.html) callback is triggered when the user selects a shape by tapping or clicking, or when a shape is selected programmatically. It provides the index of the selected shape. - -If the selected shape is tapped or clicked again, the index will be passed as -1, indicating that the shape is unselected. - -N> It is applicable for both tile layer and shape layer. - -N> Refer the [`Shape selection`](https://help.syncfusion.com/flutter/maps/selection) section to know more about the selection feature. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late MapShapeSource _shapeSource; - late MapShapeSource _sublayerSource; - late List _sublayerData; - late MapZoomPanBehavior _zoomPanBehavior; - int _selectedIndex = 0; - - @override - void initState() { - super.initState(); - _shapeSource = MapShapeSource.asset( - "assets/world_map.json", - shapeDataField: "continent", - ); - - _sublayerData = [ - DataModel('Algeria', Colors.green, 36232), - DataModel('Libya', Colors.teal, 34121), - DataModel('Egypt', Colors.blue, 43453), - DataModel('Mali', Colors.purple, 28123), - DataModel('Niger', Colors.indigo, 40111), - DataModel('Nigeria', Colors.purpleAccent, 30232), - DataModel('Chad', Colors.lightGreen, 48132), - DataModel('Sudan', Colors.redAccent, 52654), - DataModel('Mauritania', Colors.orange, 42231), - DataModel('South Sudan', Colors.lime, 40421), - DataModel('Ethiopia', Colors.greenAccent, 27198) - ]; - - _sublayerSource = MapShapeSource.asset( - 'assets/africa.json', - shapeDataField: 'name', - dataCount: _sublayerData.length, - primaryValueMapper: (int index) => _sublayerData[index].key, - shapeColorValueMapper: (int index) => _sublayerData[index].color, - ); - _zoomPanBehavior = MapZoomPanBehavior( - zoomLevel: 3, - focalLatLng: MapLatLng(38.9637, 35.2433), - ); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: SfMaps( - layers: [ - MapShapeLayer( - source: _shapeSource, - zoomPanBehavior: _zoomPanBehavior, - sublayers: [ - MapShapeSublayer( - source: _sublayerSource, - selectedIndex: _selectedIndex, - onSelectionChanged: (int index) { - setState(() { - _selectedIndex = index; - }); - }, - selectionSettings: const MapSelectionSettings( - color: Colors.lime, - strokeWidth: 3, - strokeColor: Colors.black, - ), - ), - ], - ), - ], - ), - ); - } -} - -class DataModel { - DataModel(this.key, this.color, this.size); - - final String key; - final Color color; - final double size; -} - -{% endhighlight %} -{% endtabs %} - -![Shape sublayer shape selection](images/shape-sublayer/sublayer-shape-selection.png) - -## Marker - -You can show markers at any position on the map by providing latitude and longitude coordinates to the [`MapMarker`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapMarker-class.html), which is returned from the [`markerBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer/markerBuilder.html) property. - -The [`markerBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer/markerBuilder.html) callback will be called a number of times equal to the value specified in the [`initialMarkersCount`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer/initialMarkersCount.html) property. The default value of the [`initialMarkersCount`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer/initialMarkersCount.html) property is null. - -N> It is applicable for both tile layer and shape layer. - -N> -* Refer to the [`Marker`](https://help.syncfusion.com/flutter/maps/markers) section to know more about the marker feature. -* Refer to the [`Tooltip`](https://help.syncfusion.com/flutter/maps/tooltip) section to know more about the tooltip feature. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late MapShapeSource _shapeSource; - late MapShapeSource _sublayerSource; - late List _sublayerData; - late MapZoomPanBehavior _zoomPanBehavior; - late List _markerData; - - @override - void initState() { - super.initState(); - _shapeSource = MapShapeSource.asset( - "assets/world_map.json", - shapeDataField: "continent", - ); - - _markerData = [ - MapLatLng(28.0339, 1.6596), - MapLatLng(26.3351, 17.2283), - MapLatLng(26.8208, 30.8025), - MapLatLng(17.6078, 8.0817), - MapLatLng(9.0820, 8.6753), - MapLatLng(9.1450, 40.4897), - MapLatLng(15.4542, 18.7322), - MapLatLng(6.8770, 31.3070), - MapLatLng(21.0079, -10.9408), - MapLatLng(12.8628, 30.2176), - ]; - - _sublayerData = [ - DataModel('Algeria', Colors.green, 36232), - DataModel('Libya', Colors.teal, 34121), - DataModel('Egypt', Colors.blue, 43453), - DataModel('Mali', Colors.purple, 28123), - DataModel('Niger', Colors.indigo, 40111), - DataModel('Nigeria', Colors.purpleAccent, 30232), - DataModel('Chad', Colors.lightGreen, 48132), - DataModel('Sudan', Colors.redAccent, 52654), - DataModel('Mauritania', Colors.orange, 42231), - DataModel('South Sudan', Colors.lime, 40421), - DataModel('Ethiopia', Colors.greenAccent, 27198) - ]; - - _sublayerSource = MapShapeSource.asset( - 'assets/africa.json', - shapeDataField: 'name', - dataCount: _sublayerData.length, - primaryValueMapper: (int index) => _sublayerData[index].key, - shapeColorValueMapper: (int index) => _sublayerData[index].color, - ); - _zoomPanBehavior = MapZoomPanBehavior( - zoomLevel: 3, - focalLatLng: MapLatLng(38.9637, 35.2433), - ); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: SfMaps( - layers: [ - MapShapeLayer( - source: _shapeSource, - zoomPanBehavior: _zoomPanBehavior, - sublayers: [ - MapShapeSublayer( - source: _sublayerSource, - initialMarkersCount: _markerData.length, - markerBuilder: (BuildContext context, int index) { - return MapMarker( - latitude: _markerData[index].latitude, - longitude: _markerData[index].longitude, - iconColor: Colors.white, - iconStrokeWidth: 2, - iconStrokeColor: Colors.black, - iconType: MapIconType.triangle, - size: Size(15, 15), - ); - }, - markerTooltipBuilder: (BuildContext context, int index) { - return Padding( - padding: EdgeInsets.all(10), - child: Text(_sublayerData[index].key, - style: TextStyle(color: Colors.white)), - ); - }, - ), - ], - ), - ], - ), - ); - } -} - -class DataModel { - DataModel(this.key, this.color, this.size); - - final String key; - final Color color; - final double size; -} - -{% endhighlight %} -{% endtabs %} - -![Shape sublayer marker](images/shape-sublayer/sublayer-marker.png) - +--- +layout: post +title: Shape Sublayer in Flutter Maps | Syncfusion® +description: Learn about shape sublayers in Syncfusion® Flutter Maps (SfMaps), including shape layer customization, data visualization, and map overlays. +platform: flutter +control: SfMaps +documentation: ug +--- + +# Shape Sublayer in Flutter Maps (SfMaps) + +The shape sublayer is where geographical rendering happens for the sublayer. This is similar to the main [`shape layer`](https://help.syncfusion.com/flutter/maps/getting-started#add-a-geojson-file-for-shape-layer) rendering. This section explains how to add a shape sublayer on both the shape layer and tile layer. + +## Shape sublayer on tile layer + +The [`sublayers`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/sublayers.html) property in [`MapTileLayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTileLayer-class.html) contains a collection of [`MapSublayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapSublayer-class.html). The actual geographical rendering is done in each [`MapShapeSublayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer-class.html). The [`source`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer/source.html) property of the [`MapShapeSublayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer-class.html) is of type [`MapShapeSource`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource-class.html). The path of the .json file which contains the GeoJSON data must be set to the [`MapShapeSource`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource-class.html). + +The [`shapeDataField`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeDataField.html) property of the [`MapShapeSource`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource-class.html) is used to refer to the unique field name in the .json file to identify each shape. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late MapShapeSource _sublayerSource; + + @override + void initState() { + super.initState(); + + _sublayerSource = MapShapeSource.asset( + 'assets/africa.json', + shapeDataField: 'name', + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Padding( + padding: const EdgeInsets.only(left: 15, right: 15), + child: SfMaps( + layers: [ + MapTileLayer( + urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', + sublayers: [ + MapShapeSublayer( + source: _sublayerSource, + ), + ], + ), + ], + ), + ), + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Tile sublayer support](images/shape-sublayer/tile-sublayer.png) + +N> +* Refer to the [`MapTileLayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTileLayer-class.html) documentation for adding a tile layer in [`SfMaps`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/SfMaps-class.html). + +## Shape sublayer on shape layer + +The [`sublayers`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/sublayers.html) property in [`MapShapeLayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer-class.html) contains a collection of [`MapSublayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapSublayer-class.html). The actual geographical rendering is done in each [`MapShapeSublayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer-class.html). The [`source`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer/source.html) property of the [`MapShapeSublayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer-class.html) is of type [`MapShapeSource`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource-class.html). The path of the .json file which contains the GeoJSON data must be set to the [`MapShapeSource`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource-class.html). + +The [`shapeDataField`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeDataField.html) property of the [`MapShapeSource`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource-class.html) is used to refer to the unique field name in the .json file to identify each shape. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late MapShapeSource _shapeSource; + late MapShapeSource _sublayerSource; + + @override + void initState() { + super.initState(); + _shapeSource = MapShapeSource.asset( + "assets/world_map.json", + shapeDataField: "continent", + ); + + _sublayerSource = MapShapeSource.asset( + 'assets/africa.json', + shapeDataField: 'name', + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Padding( + padding: const EdgeInsets.only(left: 15, right: 15), + child: SfMaps( + layers: [ + MapShapeLayer( + source: _shapeSource, + sublayers: [ + MapShapeSublayer( + source: _sublayerSource, + ), + ], + ), + ], + ), + ), + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Shape sublayer support](images/shape-sublayer/shape-sublayer.png) + +N> +* Refer the [`MapShapeLayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer-class.html), for adding shape layer in [`SfMaps`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/SfMaps-class.html). + +## Color and stroke color + +You can change the color, strokeColor, and strokeWidth of the shape sublayer using the [`color`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer/color.html), [`strokeColor`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer/strokeColor.html), and [`strokeWidth`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer/strokeWidth.html) properties. + +N> It is applicable for both tile layer and shape layer. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late MapShapeSource _shapeSource; + late MapShapeSource _sublayerSource; + + @override + void initState() { + super.initState(); + _shapeSource = MapShapeSource.asset( + "assets/world_map.json", + shapeDataField: "continent", + ); + + _sublayerSource = MapShapeSource.asset( + 'assets/africa.json', + shapeDataField: 'name', + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Padding( + padding: const EdgeInsets.only(left: 15, right: 15), + child: SfMaps( + layers: [ + MapShapeLayer( + source: _shapeSource, + sublayers: [ + MapShapeSublayer( + source: _sublayerSource, + color: Colors.blue[100], + strokeWidth: 2, + strokeColor: Colors.blue[800], + ), + ], + ), + ], + ), + ), + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Shape sublayer color](images/shape-sublayer/sublayer-color.png) + +## Equal color mapping + +You can apply color to the sublayer shape by comparing a value that returns from the [`shapeColorValueMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeColorValueMapper.html) with the [`MapColorMapper.value`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapColorMapper/value.html). For the matched values, the [`MapColorMapper.color`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapColorMapper/color.html) will be applied to the respective shapes. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late List data; + late MapShapeSource sublayerDataSource; + late MapShapeSource shapeDataSource; + + @override + void initState() { + data = [ + Model('Algeria', "Low"), + Model('Nigeria', "High"), + Model('Libya', "High"), + ]; + + shapeDataSource = MapShapeSource.asset( + "assets/world_map.json", + shapeDataField: 'continent', + ); + + sublayerDataSource = MapShapeSource.asset( + "assets/africa.json", + shapeDataField: "name", + dataCount: data.length, + primaryValueMapper: (int index) { + return data[index].state; + }, + shapeColorValueMapper: (int index) { + return data[index].storage; + }, + shapeColorMappers: [ + MapColorMapper(value: "Low", color: Colors.red), + MapColorMapper(value: "High", color: Colors.green) + ], + ); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Padding( + padding: EdgeInsets.only(left: 15, right: 15), + child: SfMaps( + layers: [ + MapShapeLayer( + source: shapeDataSource, + sublayers: [ + MapShapeSublayer( + source: sublayerDataSource, + ) + ], + ), + ], + ), + ), + ); + } +} + +class Model { + const Model(this.state, this.storage); + + final String state; + final String storage; +} + +{% endhighlight %} +{% endtabs %} + +![Equal color mapping](images/shape-sublayer/equal_color_mapping.png) + +## Range color mapping + +You can apply color to the sublayer shape based on whether the value returned from [`shapeColorValueMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeColorValueMapper.html) falls within the [`MapColorMapper.from`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapColorMapper/from.html) and [`MapColorMapper.to`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapColorMapper/to.html) range. Then, the [`MapColorMapper.color`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapColorMapper/color.html) will be applied to the respective shapes. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late List data; + late MapShapeSource sublayerDataSource; + late MapShapeSource shapeDataSource; + + @override + void initState() { + data = [ + Model('Algeria', 196), + Model('Nigeria', 280), + Model('Libya', 45), + ]; + + shapeDataSource = MapShapeSource.asset( + "assets/world_map.json", + shapeDataField: 'continent', + ); + + sublayerDataSource = MapShapeSource.asset( + "assets/africa.json", + shapeDataField: "name", + dataCount: data.length, + primaryValueMapper: (int index) { + return data[index].state; + }, + shapeColorValueMapper: (int index) => data[index].count, + shapeColorMappers: [ + MapColorMapper(from: 0, to: 100, color: Colors.red), + MapColorMapper(from: 101, to: 300, color: Colors.green) + ], + ); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Padding( + padding: EdgeInsets.only(left: 15, right: 15), + child: SfMaps( + layers: [ + MapShapeLayer( + source: shapeDataSource, + sublayers: [ + MapShapeSublayer( + source: sublayerDataSource, + ) + ], + ), + ], + ), + ), + ); + } +} + +class Model { + const Model(this.state, this.count); + + final String state; + final double count; +} + +{% endhighlight %} +{% endtabs %} + +![Range color mapping](images/shape-sublayer/range_color_mapping.png) + +## Enable data labels and its customization + +You can enable data labels for the shape sublayer using the [`showDataLabels`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer/showDataLabels.html) property and customize the data labels text using the [`dataLabelMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/dataLabelMapper.html) property. + +N> Refer to the [`DataLabels`](https://help.syncfusion.com/flutter/maps/data-labels) section, for customizing data labels. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late MapShapeSource _shapeSource; + late MapShapeSource _sublayerSource; + late List _sublayerData; + late MapZoomPanBehavior _zoomPanBehavior; + + @override + void initState() { + super.initState(); + _shapeSource = MapShapeSource.asset( + "assets/world_map.json", + shapeDataField: "continent", + ); + + _sublayerData = [ + DataModel('Algeria', Colors.green, 'Algeria'), + DataModel('Libya', Colors.teal, 'Libya'), + DataModel('Egypt', Colors.blue, 'Egypt'), + DataModel('Mali', Colors.purple, 'Mali'), + DataModel('Niger', Colors.indigo, 'Niger'), + DataModel('Nigeria', Colors.purpleAccent, 'Nigeria'), + DataModel('Chad', Colors.lightGreen, 'Chad'), + DataModel('Sudan', Colors.redAccent, 'Sudan'), + DataModel('Mauritania', Colors.orange, 'Mauritania'), + DataModel('South Sudan', Colors.lime, 'South Sudan'), + DataModel('Ethiopia', Colors.greenAccent, 'Ethiopia') + ]; + + _sublayerSource = MapShapeSource.asset( + 'assets/africa.json', + shapeDataField: 'name', + dataCount: _sublayerData.length, + primaryValueMapper: (int index) => _sublayerData[index].key, + dataLabelMapper: (int index) => _sublayerData[index].stateCode, + ); + _zoomPanBehavior = MapZoomPanBehavior( + zoomLevel: 3, + focalLatLng: MapLatLng(38.9637, 35.2433), + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SfMaps( + layers: [ + MapShapeLayer( + source: _shapeSource, + zoomPanBehavior: _zoomPanBehavior, + sublayers: [ + MapShapeSublayer( + source: _sublayerSource, + showDataLabels: true, + dataLabelSettings: const MapDataLabelSettings( + overflowMode: MapLabelOverflow.ellipsis, + textStyle: const TextStyle( + color: Colors.red, + fontSize: 12, + fontWeight: FontWeight.bold, + fontStyle: FontStyle.italic, + fontFamily: 'Times'), + ), + ), + ], + ), + ], + ), + ); + } + DataModel(this.key, this.color, this.stateCode); + + final String key; + final Color color; + final String stateCode; +} + +{% endhighlight %} +{% endtabs %} + +![Shape sublayer data labels](images/shape-sublayer/sublayer-data-labels.png) + +## Add bubbles to the sublayer + +You can enable bubbles for the shape sublayer using the [`bubbleSizeMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/bubbleSizeMapper.html) property and customize the bubbles appearance using the [`bubbleSettings`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer/bubbleSettings.html) property. You can also enable tooltips for the shape sublayer bubbles using the [`bubbleTooltipBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer/bubbleTooltipBuilder.html) property. + +N> It is applicable for both tile layer and shape layer. + +N> Refer to the [`Bubbles`](https://help.syncfusion.com/flutter/maps/bubble#tooltip-for-the-bubbles) section, to know more about the bubbles customization. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late MapShapeSource _shapeSource; + late MapShapeSource _sublayerSource; + late List _sublayerData; + late MapZoomPanBehavior _zoomPanBehavior; + + @override + void initState() { + super.initState(); + _shapeSource = MapShapeSource.asset( + "assets/world_map.json", + shapeDataField: "continent", + ); + + _sublayerData = [ + DataModel('Algeria', Colors.green, 36232), + DataModel('Libya', Colors.teal, 34121), + DataModel('Egypt', Colors.blue, 43453), + DataModel('Mali', Colors.purple, 28123), + DataModel('Niger', Colors.indigo, 40111), + DataModel('Nigeria', Colors.purpleAccent, 30232), + DataModel('Chad', Colors.lightGreen, 48132), + DataModel('Sudan', Colors.redAccent, 52654), + DataModel('Mauritania', Colors.orange, 42231), + DataModel('South Sudan', Colors.lime, 40421), + DataModel('Ethiopia', Colors.greenAccent, 27198) + ]; + + _sublayerSource = MapShapeSource.asset( + 'assets/africa.json', + shapeDataField: 'name', + dataCount: _sublayerData.length, + primaryValueMapper: (int index) => _sublayerData[index].key, + bubbleColorValueMapper: (int index) => _sublayerData[index].color, + bubbleSizeMapper: (int index) => _sublayerData[index].size, + ); + _zoomPanBehavior = MapZoomPanBehavior( + zoomLevel: 3, + focalLatLng: MapLatLng(38.9637, 35.2433), + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SfMaps( + layers: [ + MapShapeLayer( + source: _shapeSource, + zoomPanBehavior: _zoomPanBehavior, + sublayers: [ + MapShapeSublayer( + source: _sublayerSource, + bubbleSettings: const MapBubbleSettings( + minRadius: 5, + maxRadius: 20, + ), + bubbleTooltipBuilder: (BuildContext context, int index) { + return Container( + height: 40, + width: 120, + padding: const EdgeInsets.all(5), + child: Column( + children: [ + Row( + children: [ + Text('State : ', + style: TextStyle(color: Colors.white)), + Text(_sublayerData[index].key, + style: TextStyle(color: Colors.white)), + ], + ), + Row( + children: [ + Text('Population : ', + style: TextStyle(color: Colors.white)), + Text(_sublayerData[index].size.toStringAsFixed(0), + style: TextStyle(color: Colors.white)), + ], + ), + ], + ), + ); + }, + ), + ], + ), + ], + ), + ); + } +} + +class DataModel { + DataModel(this.key, this.color, this.size); + + final String key; + final Color color; + final double size; +} + +{% endhighlight %} +{% endtabs %} + +![Shape sublayer bubbles](images/shape-sublayer/sublayer-bubbles.png) + +## Enable tooltip for shape sublayer + +You can enable tooltips for the shape sublayer using the [`shapeTooltipBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer/shapeTooltipBuilder.html) property. + +N> It is applicable for both tile layer and shape layer. + +N> Refer to the [`Tooltip`](https://help.syncfusion.com/flutter/maps/tooltip) section to know more about the tooltip customization. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late MapShapeSource _shapeSource; + late MapShapeSource _sublayerSource; + late List _sublayerData; + late MapZoomPanBehavior _zoomPanBehavior; + + @override + void initState() { + super.initState(); + _shapeSource = MapShapeSource.asset( + "assets/world_map.json", + shapeDataField: "continent", + ); + + _sublayerData = [ + DataModel('Algeria', Colors.green, 36232), + DataModel('Libya', Colors.teal, 34121), + DataModel('Egypt', Colors.blue, 43453), + DataModel('Mali', Colors.purple, 28123), + DataModel('Niger', Colors.indigo, 40111), + DataModel('Nigeria', Colors.purpleAccent, 30232), + DataModel('Chad', Colors.lightGreen, 48132), + DataModel('Sudan', Colors.redAccent, 52654), + DataModel('Mauritania', Colors.orange, 42231), + DataModel('South Sudan', Colors.lime, 40421), + DataModel('Ethiopia', Colors.greenAccent, 27198) + ]; + + _sublayerSource = MapShapeSource.asset( + 'assets/africa.json', + shapeDataField: 'name', + dataCount: _sublayerData.length, + primaryValueMapper: (int index) => _sublayerData[index].key, + shapeColorValueMapper: (int index) => _sublayerData[index].color, + ); + _zoomPanBehavior = MapZoomPanBehavior( + zoomLevel: 3, + focalLatLng: MapLatLng(38.9637, 35.2433), + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SfMaps( + layers: [ + MapShapeLayer( + source: _shapeSource, + zoomPanBehavior: _zoomPanBehavior, + sublayers: [ + MapShapeSublayer( + source: _sublayerSource, + shapeTooltipBuilder: (BuildContext context, int index) { + return Container( + height: 40, + width: 120, + padding: const EdgeInsets.all(5), + child: Column( + children: [ + Row( + children: [ + Text('State : ', + style: TextStyle(color: Colors.white)), + Text(_sublayerData[index].key, + style: TextStyle(color: Colors.white)), + ], + ), + Row( + children: [ + Text('Population : ', + style: TextStyle(color: Colors.white)), + Text(_sublayerData[index].size.toStringAsFixed(0), + style: TextStyle(color: Colors.white)), + ], + ), + ], + ), + ); + }, + ), + ], + ), + ], + ), + ); + } +} + +class DataModel { + DataModel(this.key, this.color, this.size); + + final String key; + final Color color; + final double size; +} + +{% endhighlight %} +{% endtabs %} + +![Shape sublayer shape tooltip](images/shape-sublayer/sublayer-shape-tooltip.png) + +## Selection + +You can enable shape sublayer selection using the [`onSelectionChanged`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer/onSelectionChanged.html) callback along with setting the [`selectedIndex`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer/selectedIndex.html) property. + +The [`onSelectionChanged`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer/onSelectionChanged.html) callback is triggered when the user selects a shape by tapping or clicking, or when a shape is selected programmatically. It provides the index of the selected shape. + +If the selected shape is tapped or clicked again, the index will be passed as -1, indicating that the shape is unselected. + +N> It is applicable for both tile layer and shape layer. + +N> Refer the [`Shape selection`](https://help.syncfusion.com/flutter/maps/selection) section to know more about the selection feature. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late MapShapeSource _shapeSource; + late MapShapeSource _sublayerSource; + late List _sublayerData; + late MapZoomPanBehavior _zoomPanBehavior; + int _selectedIndex = 0; + + @override + void initState() { + super.initState(); + _shapeSource = MapShapeSource.asset( + "assets/world_map.json", + shapeDataField: "continent", + ); + + _sublayerData = [ + DataModel('Algeria', Colors.green, 36232), + DataModel('Libya', Colors.teal, 34121), + DataModel('Egypt', Colors.blue, 43453), + DataModel('Mali', Colors.purple, 28123), + DataModel('Niger', Colors.indigo, 40111), + DataModel('Nigeria', Colors.purpleAccent, 30232), + DataModel('Chad', Colors.lightGreen, 48132), + DataModel('Sudan', Colors.redAccent, 52654), + DataModel('Mauritania', Colors.orange, 42231), + DataModel('South Sudan', Colors.lime, 40421), + DataModel('Ethiopia', Colors.greenAccent, 27198) + ]; + + _sublayerSource = MapShapeSource.asset( + 'assets/africa.json', + shapeDataField: 'name', + dataCount: _sublayerData.length, + primaryValueMapper: (int index) => _sublayerData[index].key, + shapeColorValueMapper: (int index) => _sublayerData[index].color, + ); + _zoomPanBehavior = MapZoomPanBehavior( + zoomLevel: 3, + focalLatLng: MapLatLng(38.9637, 35.2433), + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SfMaps( + layers: [ + MapShapeLayer( + source: _shapeSource, + zoomPanBehavior: _zoomPanBehavior, + sublayers: [ + MapShapeSublayer( + source: _sublayerSource, + selectedIndex: _selectedIndex, + onSelectionChanged: (int index) { + setState(() { + _selectedIndex = index; + }); + }, + selectionSettings: const MapSelectionSettings( + color: Colors.lime, + strokeWidth: 3, + strokeColor: Colors.black, + ), + ), + ], + ), + ], + ), + ); + } +} + +class DataModel { + DataModel(this.key, this.color, this.size); + + final String key; + final Color color; + final double size; +} + +{% endhighlight %} +{% endtabs %} + +![Shape sublayer shape selection](images/shape-sublayer/sublayer-shape-selection.png) + +## Marker + +You can show markers at any position on the Flutter Maps by providing latitude and longitude coordinates to the [`MapMarker`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapMarker-class.html), which is returned from the [`markerBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer/markerBuilder.html) property. + +The [`markerBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer/markerBuilder.html) callback will be called a number of times equal to the value specified in the [`initialMarkersCount`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer/initialMarkersCount.html) property. The default value of the [`initialMarkersCount`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSublayer/initialMarkersCount.html) property is null. + +N> It is applicable for both tile layer and shape layer. + +N> +* Refer to the [`Marker`](https://help.syncfusion.com/flutter/maps/markers) section to know more about the marker feature. +* Refer to the [`Tooltip`](https://help.syncfusion.com/flutter/maps/tooltip) section to know more about the tooltip feature. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late MapShapeSource _shapeSource; + late MapShapeSource _sublayerSource; + late List _sublayerData; + late MapZoomPanBehavior _zoomPanBehavior; + late List _markerData; + + @override + void initState() { + super.initState(); + _shapeSource = MapShapeSource.asset( + "assets/world_map.json", + shapeDataField: "continent", + ); + + _markerData = [ + MapLatLng(28.0339, 1.6596), + MapLatLng(26.3351, 17.2283), + MapLatLng(26.8208, 30.8025), + MapLatLng(17.6078, 8.0817), + MapLatLng(9.0820, 8.6753), + MapLatLng(9.1450, 40.4897), + MapLatLng(15.4542, 18.7322), + MapLatLng(6.8770, 31.3070), + MapLatLng(21.0079, -10.9408), + MapLatLng(12.8628, 30.2176), + ]; + + _sublayerData = [ + DataModel('Algeria', Colors.green, 36232), + DataModel('Libya', Colors.teal, 34121), + DataModel('Egypt', Colors.blue, 43453), + DataModel('Mali', Colors.purple, 28123), + DataModel('Niger', Colors.indigo, 40111), + DataModel('Nigeria', Colors.purpleAccent, 30232), + DataModel('Chad', Colors.lightGreen, 48132), + DataModel('Sudan', Colors.redAccent, 52654), + DataModel('Mauritania', Colors.orange, 42231), + DataModel('South Sudan', Colors.lime, 40421), + DataModel('Ethiopia', Colors.greenAccent, 27198) + ]; + + _sublayerSource = MapShapeSource.asset( + 'assets/africa.json', + shapeDataField: 'name', + dataCount: _sublayerData.length, + primaryValueMapper: (int index) => _sublayerData[index].key, + shapeColorValueMapper: (int index) => _sublayerData[index].color, + ); + _zoomPanBehavior = MapZoomPanBehavior( + zoomLevel: 3, + focalLatLng: MapLatLng(38.9637, 35.2433), + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SfMaps( + layers: [ + MapShapeLayer( + source: _shapeSource, + zoomPanBehavior: _zoomPanBehavior, + sublayers: [ + MapShapeSublayer( + source: _sublayerSource, + initialMarkersCount: _markerData.length, + markerBuilder: (BuildContext context, int index) { + return MapMarker( + latitude: _markerData[index].latitude, + longitude: _markerData[index].longitude, + iconColor: Colors.white, + iconStrokeWidth: 2, + iconStrokeColor: Colors.black, + iconType: MapIconType.triangle, + size: Size(15, 15), + ); + }, + markerTooltipBuilder: (BuildContext context, int index) { + return Padding( + padding: EdgeInsets.all(10), + child: Text(_sublayerData[index].key, + style: TextStyle(color: Colors.white)), + ); + }, + ), + ], + ), + ], + ), + ); + } +} + +class DataModel { + DataModel(this.key, this.color, this.size); + + final String key; + final Color color; + final double size; +} + +{% endhighlight %} +{% endtabs %} + +![Shape sublayer marker](images/shape-sublayer/sublayer-marker.png) + N> You can refer to our [Flutter Maps](https://www.syncfusion.com/flutter-widgets/flutter-maps) feature tour page for its groundbreaking feature representations. You can also explore our [Flutter Maps Sublayer example](https://flutter.syncfusion.com/#/maps/shape-layer/sublayer) that shows how to configure a Maps in Flutter. \ No newline at end of file diff --git a/Flutter/maps/shape.md b/Flutter/maps/shape.md index a935dc313..234bf4b66 100644 --- a/Flutter/maps/shape.md +++ b/Flutter/maps/shape.md @@ -1,547 +1,547 @@ ---- -layout: post -title: Shape Colors in Flutter Maps | Syncfusion® -description: Learn about shape color customization in Syncfusion® Flutter Maps (SfMaps), including fill colors, color mapping, selection colors, and styling options. -platform: flutter -control: SfMaps -documentation: ug ---- - -# Shape Colors in Flutter Maps (SfMaps) - -This section explains about shapes and how to apply colors to the shapes based on specific values in the Flutter maps. - -## Loading progress indicator - -You can notify the user that the map is being loaded using the [`MapShapeLayer.loadingBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/loadingBuilder.html). It returns the widget which will be visible until the map is loaded. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late MapShapeSource dataSource; - - @override - void initState() { - dataSource = MapShapeSource.asset( - 'assets/world_map.json', - shapeDataField: 'continent', - ); - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Padding( - padding: EdgeInsets.all(15), - child: SfMaps( - layers: [ - MapShapeLayer( - source: dataSource, - loadingBuilder: (BuildContext context) { - return Container( - height: 25, - width: 25, - child: const CircularProgressIndicator( - strokeWidth: 3, - ), - ); - }, - ), - ], - ), - ), - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Loading builder](images/shape-colors/loading-builder.gif) - -## Shape color - -You can apply color, stroke color and stroke width to the shapes using the [`MapShapeLayer.color`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/color.html), [`MapShapeLayer.strokeColor`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/strokeColor.html) and [`MapShapeLayer.strokeWidth`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/strokeWidth.html) properties respectively. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late MapShapeSource dataSource; - - @override - void initState() { - dataSource = MapShapeSource.asset( - 'assets/world_map.json', - shapeDataField: 'continent', - ); - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Padding( - padding: EdgeInsets.all(15), - child: SfMaps( - layers: [ - MapShapeLayer( - source: dataSource, - color: Colors.blue[100], - strokeColor: Colors.blue, - strokeWidth: 2, - ), - ], - ), - ), - ); - } -} - -{% endhighlight %} -{% endtabs %} - -Using SfMapsTheme - -You can also customize the appearance of the shape using [`SfMapsTheme`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsTheme-class.html): - -* **Color** - Change the color of the shapes using the [`SfMapsThemeData.layerColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsThemeData/layerColor.html) property. -* **Stroke color** - Change the stroke color of the shapes using the [`SfMapsThemeData.layerStrokeColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsThemeData/layerStrokeColor.html) property. -* **Stroke width** - Change the stroke width of the shapes using the [`SfMapsThemeData.layerStrokeWidth`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsThemeData/layerStrokeWidth.html) property. - -N> You must import the `theme.dart` library from the [`Core`](https://pub.dev/packages/syncfusion_flutter_core) package to use [`SfMapsTheme`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsTheme-class.html). - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late MapShapeSource dataSource; - - @override - void initState() { - dataSource = MapShapeSource.asset( - 'assets/world_map.json', - shapeDataField: 'continent', - ); - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Padding( - padding: EdgeInsets.all(15), - child: SfMapsTheme( - data: SfMapsThemeData( - layerColor: Colors.blue[100], - layerStrokeColor: Colors.blue, - layerStrokeWidth: 2, - ), - child: SfMaps( - layers: [ - MapShapeLayer( - source: dataSource, - ), - ], - ), - ), - ), - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Shapes color](images/shape-colors/shapes-stroke-color.png) - -## Hover color - -You can apply hover color, stroke color and stroke width to the shapes in the web platform using the [`SfMapsThemeData.shapeHoverColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsThemeData/shapeHoverColor.html), [`SfMapsThemeData.shapeHoverStrokeColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsThemeData/shapeHoverStrokeColor.html) and [`SfMapsThemeData.shapeHoverStrokeWidth`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsThemeData/shapeHoverStrokeWidth.html) properties respectively. - -N> You must import the `theme.dart` library from the [`Core`](https://pub.dev/packages/syncfusion_flutter_core) package to use [`SfMapsTheme`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsTheme-class.html). - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late MapShapeSource dataSource; - - @override - void initState() { - dataSource = MapShapeSource.asset( - 'assets/world_map.json', - shapeDataField: 'continent', - ); - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Padding( - padding: EdgeInsets.all(15), - child: SfMapsTheme( - data: SfMapsThemeData( - shapeHoverColor: Colors.red[800], - shapeHoverStrokeColor: Colors.black, - shapeHoverStrokeWidth: 2, - ), - child: SfMaps( - layers: [ - MapShapeLayer( - source: dataSource, - ), - ], - ), - ), - ), - ); - } -} - -{% endhighlight %} -{% endtabs %} - -## Applying colors based on the data - -To learn more about how to customize the colors in Flutter Maps, you can watch this video. - - - - -If you return a color from the [`shapeColorValueMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeColorValueMapper.html), then the color will be applied to the respective shape straightaway. - -If you return a value of different type other than the color from the [`shapeColorValueMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeColorValueMapper.html), then you must set the [`MapShapeSource.shapeColorMappers`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeColorMappers.html) property which is a collection of [`MapColorMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapColorMapper-class.html) to apply colors for the respective shapes. - -N> You can show legend using the [`MapShapeLayer.legend`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/legend.html) property. The icons color of the legend is applied based on the colors returned in the [`MapShapeSource.shapeColorValueMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeColorValueMapper.html) property and the text will be taken from the [`primaryValueMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/primaryValueMapper.html). It is possible to customize the legend icons color and text using the [`MapShapeSource.shapeColorMappers`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeColorMappers.html) property. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late List data; - late MapShapeSource dataSource; - - @override - void initState() { - data = const [ - Model('Asia', Color.fromRGBO(60, 120, 255, 0.8)), - Model('Africa', Color.fromRGBO(51, 102, 255, 0.8)), - Model('Europe', Color.fromRGBO(0, 57, 230, 0.8)), - Model('South America', Color.fromRGBO(0, 51, 204, 0.8)), - Model('Australia', Color.fromRGBO(0, 45, 179, 0.8)), - Model('North America', Color.fromRGBO(0, 38, 153, 0.8)) - ]; - - dataSource = MapShapeSource.asset( - 'assets/world_map.json', - shapeDataField: 'continent', - dataCount: data.length, - primaryValueMapper: (int index) => data[index].country, - shapeColorValueMapper: (int index) => data[index].color, - ); - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: Container( - height: 350, - child: Padding( - padding: EdgeInsets.only(left: 15, right: 15), - child: SfMaps( - layers: [ - MapShapeLayer( - source: dataSource, - ), - ], - ), - ), - )), - ); - } -} - -class Model { - const Model(this.country, this.color); - - final String country; - final Color color; -} - -{% endhighlight %} -{% endtabs %} - -![Shape color](images/shape-colors/shape_color_default.png) - -## Equal color mapping - -You can apply color to the shape by comparing a value that returns from the [`shapeColorValueMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeColorValueMapper.html) with the [`MapColorMapper.value`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapColorMapper/value.html). For the matched values, the [`MapColorMapper.color`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapColorMapper/color.html) will be applied to the respective shapes. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late List data; - late MapShapeSource dataSource; - - @override - void initState() { - data = [ - Model('India', "Low"), - Model('United States of America', "High"), - Model('Pakistan', "Low"), - ]; - - dataSource = MapShapeSource.asset( - "assets/world_map.json", - shapeDataField: "name", - dataCount: data.length, - primaryValueMapper: (int index) { - return data[index].country; - }, - shapeColorValueMapper: (int index) { - return data[index].storage; - }, - shapeColorMappers: [ - MapColorMapper(value: "Low", color: Colors.red), - MapColorMapper(value: "High", color: Colors.green) - ], - ); - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Padding( - padding: EdgeInsets.only(left: 15, right: 15), - child: SfMaps( - layers: [ - MapShapeLayer(source: dataSource), - ], - ), - ), - ); - } -} - -class Model { - const Model(this.country, this.storage); - - final String country; - final String storage; -} - -{% endhighlight %} -{% endtabs %} - -![Equal color mapping](images/shape-colors/equal_color_mapping.png) - -## Range color mapping - -You can apply color to the shape based on whether the value returned from [`shapeColorValueMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeColorValueMapper.html) falls within the [`MapColorMapper.from`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapColorMapper/from.html) and [`MapColorMapper.to`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapColorMapper/to.html) range. Then, the [`MapColorMapper.color`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapColorMapper/color.html) will be applied to the respective shapes. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late List data; - late MapShapeSource dataSource; - - @override - void initState() { - data = [ - Model('India', 280), - Model('United States of America', 190), - Model('Kazakhstan', 37), - ]; - - dataSource = MapShapeSource.asset( - "assets/world_map.json", - shapeDataField: "name", - dataCount: data.length, - primaryValueMapper: (int index) => data[index].country, - shapeColorValueMapper: (int index) => data[index].count, - shapeColorMappers: [ - MapColorMapper(from: 0, to: 100, color: Colors.red), - MapColorMapper(from: 101, to: 300, color: Colors.green) - ], - ); - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Padding( - padding: EdgeInsets.only(left: 15, right: 15), - child: SfMaps( - layers: [ - MapShapeLayer(source: dataSource), - ], - ), - ), - ); - } -} - -class Model { - const Model(this.country, this.count); - - final String country; - final double count; -} - -{% endhighlight %} -{% endtabs %} - -![Range color mapping](images/shape-colors/range_color_mapping.png) - -## Opacity - -You can apply the maximum and minimum opacity to the shape or [`bubbles`](https://help.syncfusion.com/flutter/maps/bubble) while using [`MapColorMapper.from`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapColorMapper/from.html) and [`MapColorMapper.to`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapColorMapper/to.html) properties. - -The shapes or bubbles with the lowest value (from) will be applied [`minOpacity`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapColorMapper/minOpacity.html) and the shapes or bubbles with the highest value (to) will be applied [`maxOpacity`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapColorMapper/maxOpacity.html). The shapes or bubbles with values in-between the range will get an opacity based on their respective value. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late List data; - late MapShapeSource dataSource; - - @override - void initState() { - data = [ - Model('India', 280), - Model('United States of America', 190), - Model('Kazakhstan', 37), - ]; - - dataSource = MapShapeSource.asset( - "assets/world_map.json", - shapeDataField: "name", - dataCount: data.length, - primaryValueMapper: (int index) => data[index].country, - shapeColorValueMapper: (int index) => data[index].count, - shapeColorMappers: [ - MapColorMapper( - from: 0, - to: 100, - color: Colors.red, - minOpacity: 0.2, - maxOpacity: 0.4, - ), - MapColorMapper( - from: 101, - to: 300, - color: Colors.green, - minOpacity: 0.4, - maxOpacity: 0.6, - ), - ], - ); - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Padding( - padding: EdgeInsets.only(left: 15, right: 15), - child: SfMaps( - layers: [ - MapShapeLayer(source: dataSource), - ], - ), - ), - ); - } -} - -class Model { - const Model(this.country, this.count); - - final String country; - final double count; -} - -{% endhighlight %} -{% endtabs %} - -![Shape color opacity](images/shape-colors/shape-color-opacity.png) - -N> -* Refer to the [`MapShapeSource.bubbleColorMappers`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/bubbleColorMappers.html) property for setting the bubble colors based on specific values. You can refer to our [Flutter Maps](https://www.syncfusion.com/flutter-widgets/flutter-maps) feature tour page for its groundbreaking feature representations. You can also explore our [Flutter Maps Shapes example](https://flutter.syncfusion.com/#/maps/shape-layer/range-color-mapping) that shows how to configure a Maps in Flutter. +--- +layout: post +title: Shape Colors in Flutter Maps | Syncfusion® +description: Learn about shape color customization in Syncfusion® Flutter Maps (SfMaps), including fill colors, color mapping, selection colors, and styling options. +platform: flutter +control: SfMaps +documentation: ug +--- + +# Shape Colors in Flutter Maps (SfMaps) + +This section explains about shapes and how to apply colors to the shapes based on specific values in the Flutter Maps. + +## Loading progress indicator + +You can notify the user that the Flutter Maps is being loaded using the [`MapShapeLayer.loadingBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/loadingBuilder.html). It returns the widget which will be visible until the map is loaded. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late MapShapeSource dataSource; + + @override + void initState() { + dataSource = MapShapeSource.asset( + 'assets/world_map.json', + shapeDataField: 'continent', + ); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Padding( + padding: EdgeInsets.all(15), + child: SfMaps( + layers: [ + MapShapeLayer( + source: dataSource, + loadingBuilder: (BuildContext context) { + return Container( + height: 25, + width: 25, + child: const CircularProgressIndicator( + strokeWidth: 3, + ), + ); + }, + ), + ], + ), + ), + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Loading builder](images/shape-colors/loading-builder.gif) + +## Shape color + +You can apply color, stroke color and stroke width to the shapes using the [`MapShapeLayer.color`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/color.html), [`MapShapeLayer.strokeColor`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/strokeColor.html) and [`MapShapeLayer.strokeWidth`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/strokeWidth.html) properties respectively. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late MapShapeSource dataSource; + + @override + void initState() { + dataSource = MapShapeSource.asset( + 'assets/world_map.json', + shapeDataField: 'continent', + ); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Padding( + padding: EdgeInsets.all(15), + child: SfMaps( + layers: [ + MapShapeLayer( + source: dataSource, + color: Colors.blue[100], + strokeColor: Colors.blue, + strokeWidth: 2, + ), + ], + ), + ), + ); + } +} + +{% endhighlight %} +{% endtabs %} + +Using SfMapsTheme + +You can also customize the appearance of the shape using [`SfMapsTheme`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsTheme-class.html): + +* **Color** - Change the color of the shapes using the [`SfMapsThemeData.layerColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsThemeData/layerColor.html) property. +* **Stroke color** - Change the stroke color of the shapes using the [`SfMapsThemeData.layerStrokeColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsThemeData/layerStrokeColor.html) property. +* **Stroke width** - Change the stroke width of the shapes using the [`SfMapsThemeData.layerStrokeWidth`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsThemeData/layerStrokeWidth.html) property. + +N> You must import the `theme.dart` library from the [`Core`](https://pub.dev/packages/syncfusion_flutter_core) package to use [`SfMapsTheme`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsTheme-class.html). + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late MapShapeSource dataSource; + + @override + void initState() { + dataSource = MapShapeSource.asset( + 'assets/world_map.json', + shapeDataField: 'continent', + ); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Padding( + padding: EdgeInsets.all(15), + child: SfMapsTheme( + data: SfMapsThemeData( + layerColor: Colors.blue[100], + layerStrokeColor: Colors.blue, + layerStrokeWidth: 2, + ), + child: SfMaps( + layers: [ + MapShapeLayer( + source: dataSource, + ), + ], + ), + ), + ), + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Shapes color](images/shape-colors/shapes-stroke-color.png) + +## Hover color + +You can apply hover color, stroke color and stroke width to the shapes in the web platform using the [`SfMapsThemeData.shapeHoverColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsThemeData/shapeHoverColor.html), [`SfMapsThemeData.shapeHoverStrokeColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsThemeData/shapeHoverStrokeColor.html) and [`SfMapsThemeData.shapeHoverStrokeWidth`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsThemeData/shapeHoverStrokeWidth.html) properties respectively. + +N> You must import the `theme.dart` library from the [`Core`](https://pub.dev/packages/syncfusion_flutter_core) package to use [`SfMapsTheme`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsTheme-class.html). + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late MapShapeSource dataSource; + + @override + void initState() { + dataSource = MapShapeSource.asset( + 'assets/world_map.json', + shapeDataField: 'continent', + ); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Padding( + padding: EdgeInsets.all(15), + child: SfMapsTheme( + data: SfMapsThemeData( + shapeHoverColor: Colors.red[800], + shapeHoverStrokeColor: Colors.black, + shapeHoverStrokeWidth: 2, + ), + child: SfMaps( + layers: [ + MapShapeLayer( + source: dataSource, + ), + ], + ), + ), + ), + ); + } +} + +{% endhighlight %} +{% endtabs %} + +## Applying colors based on the data + +To learn more about how to customize the colors in Flutter Maps, you can watch this video. + + + + +If you return a color from the [`shapeColorValueMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeColorValueMapper.html), then the color will be applied to the respective shape straightaway. + +If you return a value of different type other than the color from the [`shapeColorValueMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeColorValueMapper.html), then you must set the [`MapShapeSource.shapeColorMappers`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeColorMappers.html) property which is a collection of [`MapColorMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapColorMapper-class.html) to apply colors for the respective shapes. + +N> You can show legend using the [`MapShapeLayer.legend`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/legend.html) property. The icons color of the legend is applied based on the colors returned in the [`MapShapeSource.shapeColorValueMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeColorValueMapper.html) property and the text will be taken from the [`primaryValueMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/primaryValueMapper.html). It is possible to customize the legend icons color and text using the [`MapShapeSource.shapeColorMappers`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeColorMappers.html) property. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late List data; + late MapShapeSource dataSource; + + @override + void initState() { + data = const [ + Model('Asia', Color.fromRGBO(60, 120, 255, 0.8)), + Model('Africa', Color.fromRGBO(51, 102, 255, 0.8)), + Model('Europe', Color.fromRGBO(0, 57, 230, 0.8)), + Model('South America', Color.fromRGBO(0, 51, 204, 0.8)), + Model('Australia', Color.fromRGBO(0, 45, 179, 0.8)), + Model('North America', Color.fromRGBO(0, 38, 153, 0.8)) + ]; + + dataSource = MapShapeSource.asset( + 'assets/world_map.json', + shapeDataField: 'continent', + dataCount: data.length, + primaryValueMapper: (int index) => data[index].country, + shapeColorValueMapper: (int index) => data[index].color, + ); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Container( + height: 350, + child: Padding( + padding: EdgeInsets.only(left: 15, right: 15), + child: SfMaps( + layers: [ + MapShapeLayer( + source: dataSource, + ), + ], + ), + ), + )), + ); + } +} + +class Model { + const Model(this.country, this.color); + + final String country; + final Color color; +} + +{% endhighlight %} +{% endtabs %} + +![Shape color](images/shape-colors/shape_color_default.png) + +## Equal color mapping + +You can apply color to the shape by comparing a value that returns from the [`shapeColorValueMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeColorValueMapper.html) with the [`MapColorMapper.value`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapColorMapper/value.html). For the matched values, the [`MapColorMapper.color`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapColorMapper/color.html) will be applied to the respective shapes. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late List data; + late MapShapeSource dataSource; + + @override + void initState() { + data = [ + Model('India', "Low"), + Model('United States of America', "High"), + Model('Pakistan', "Low"), + ]; + + dataSource = MapShapeSource.asset( + "assets/world_map.json", + shapeDataField: "name", + dataCount: data.length, + primaryValueMapper: (int index) { + return data[index].country; + }, + shapeColorValueMapper: (int index) { + return data[index].storage; + }, + shapeColorMappers: [ + MapColorMapper(value: "Low", color: Colors.red), + MapColorMapper(value: "High", color: Colors.green) + ], + ); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Padding( + padding: EdgeInsets.only(left: 15, right: 15), + child: SfMaps( + layers: [ + MapShapeLayer(source: dataSource), + ], + ), + ), + ); + } +} + +class Model { + const Model(this.country, this.storage); + + final String country; + final String storage; +} + +{% endhighlight %} +{% endtabs %} + +![Equal color mapping](images/shape-colors/equal_color_mapping.png) + +## Range color mapping + +You can apply color to the shape based on whether the value returned from [`shapeColorValueMapper`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/shapeColorValueMapper.html) falls within the [`MapColorMapper.from`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapColorMapper/from.html) and [`MapColorMapper.to`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapColorMapper/to.html) range. Then, the [`MapColorMapper.color`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapColorMapper/color.html) will be applied to the respective shapes. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late List data; + late MapShapeSource dataSource; + + @override + void initState() { + data = [ + Model('India', 280), + Model('United States of America', 190), + Model('Kazakhstan', 37), + ]; + + dataSource = MapShapeSource.asset( + "assets/world_map.json", + shapeDataField: "name", + dataCount: data.length, + primaryValueMapper: (int index) => data[index].country, + shapeColorValueMapper: (int index) => data[index].count, + shapeColorMappers: [ + MapColorMapper(from: 0, to: 100, color: Colors.red), + MapColorMapper(from: 101, to: 300, color: Colors.green) + ], + ); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Padding( + padding: EdgeInsets.only(left: 15, right: 15), + child: SfMaps( + layers: [ + MapShapeLayer(source: dataSource), + ], + ), + ), + ); + } +} + +class Model { + const Model(this.country, this.count); + + final String country; + final double count; +} + +{% endhighlight %} +{% endtabs %} + +![Range color mapping](images/shape-colors/range_color_mapping.png) + +## Opacity + +You can apply the maximum and minimum opacity to the shape or [`bubbles`](https://help.syncfusion.com/flutter/maps/bubble) while using [`MapColorMapper.from`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapColorMapper/from.html) and [`MapColorMapper.to`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapColorMapper/to.html) properties. + +The shapes or bubbles with the lowest value (from) will be applied [`minOpacity`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapColorMapper/minOpacity.html) and the shapes or bubbles with the highest value (to) will be applied [`maxOpacity`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapColorMapper/maxOpacity.html). The shapes or bubbles with values in-between the range will get an opacity based on their respective value. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late List data; + late MapShapeSource dataSource; + + @override + void initState() { + data = [ + Model('India', 280), + Model('United States of America', 190), + Model('Kazakhstan', 37), + ]; + + dataSource = MapShapeSource.asset( + "assets/world_map.json", + shapeDataField: "name", + dataCount: data.length, + primaryValueMapper: (int index) => data[index].country, + shapeColorValueMapper: (int index) => data[index].count, + shapeColorMappers: [ + MapColorMapper( + from: 0, + to: 100, + color: Colors.red, + minOpacity: 0.2, + maxOpacity: 0.4, + ), + MapColorMapper( + from: 101, + to: 300, + color: Colors.green, + minOpacity: 0.4, + maxOpacity: 0.6, + ), + ], + ); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Padding( + padding: EdgeInsets.only(left: 15, right: 15), + child: SfMaps( + layers: [ + MapShapeLayer(source: dataSource), + ], + ), + ), + ); + } +} + +class Model { + const Model(this.country, this.count); + + final String country; + final double count; +} + +{% endhighlight %} +{% endtabs %} + +![Shape color opacity](images/shape-colors/shape-color-opacity.png) + +N> +* Refer to the [`MapShapeSource.bubbleColorMappers`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeSource/bubbleColorMappers.html) property for setting the bubble colors based on specific values. You can refer to our [Flutter Maps](https://www.syncfusion.com/flutter-widgets/flutter-maps) feature tour page for its groundbreaking feature representations. You can also explore our [Flutter Maps Shapes example](https://flutter.syncfusion.com/#/maps/shape-layer/range-color-mapping) that shows how to configure a Maps in Flutter. diff --git a/Flutter/maps/tooltip.md b/Flutter/maps/tooltip.md index 6d3e5f259..af1ca511b 100644 --- a/Flutter/maps/tooltip.md +++ b/Flutter/maps/tooltip.md @@ -1,675 +1,675 @@ ---- -layout: post -title: Tooltip in Flutter Maps widget | Syncfusion -description: Learn here all about adding the Tooltip feature of Syncfusion Flutter Maps (SfMaps) widget and more. -platform: flutter -control: SfMaps -documentation: ug ---- - -# Tooltip in Flutter Maps (SfMaps) - -Tooltip is used to indicate shape, bubble, and marker information during tap or click interactions. This section helps you learn how to show tooltips for shapes, bubbles, and markers in maps and customize them. - -## Tooltip for the shapes - -Tooltips clearly indicate shape information on tap or click. To show a tooltip for a shape, return a widget in [`MapShapeLayer.shapeTooltipBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/shapeTooltipBuilder.html). This widget will be wrapped in a built-in shape which comes with a nose at the bottom. - -The [`MapShapeLayer.shapeTooltipBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/shapeTooltipBuilder.html) will be called with the corresponding index every time you interact with the shapes i.e., while tapping in touch devices and hover enter in mouse-enabled devices. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late List _data; - late MapShapeSource _shapeSource; - - @override - void initState() { - super.initState(); - - _data = [ - Model('Asia', 50, '44,579,000 sq. km.'), - Model('Africa', 54, '30,370,000 sq. km.'), - Model('Europe', 51, '10,180,000 sq. km.'), - Model('North America', 23, '24,709,000 sq. km.'), - Model('South America', 12, '17,840,000 sq. km.'), - Model('Australia', 14, '8,600,000 sq. km.'), - ]; - - _shapeSource = MapShapeSource.asset( - "assets/world_map.json", - shapeDataField: "continent", - dataCount: _data.length, - primaryValueMapper: (int index) => _data[index].continent, - ); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Padding( - padding: const EdgeInsets.only(left: 15, right: 15), - child: SfMaps( - layers: [ - MapShapeLayer( - source: _shapeSource, - shapeTooltipBuilder: (BuildContext context, int index) { - return Container( - width: 180, - padding: const EdgeInsets.all(10), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Stack( - children: [ - Center( - child: Text( - _data[index].continent, - style: TextStyle( - color: Colors.white, - fontSize: Theme.of(context) - .textTheme - .bodyMedium! - .fontSize), - ), - ), - const Icon( - Icons.map, - color: Colors.white, - size: 16, - ), - ], - ), - const Divider( - color: Colors.white, - height: 10, - thickness: 1.2, - ), - Text( - 'Area : ' + _data[index].area, - style: TextStyle( - color: Colors.white, - fontSize: - Theme.of(context).textTheme.bodyMedium!.fontSize), - ), - ], - ), - ); - }, - tooltipSettings: const MapTooltipSettings( - color: Colors.blue, - strokeColor: Color.fromRGBO(252, 187, 15, 1), - strokeWidth: 1.5), - ), - ], - ), - ), - ); - } -} - -class Model { - const Model(this.continent, this.countriesCount, this.area); - - final String continent; - final double countriesCount; - final String area; -} - -{% endhighlight %} -{% endtabs %} - -![Maps shape tooltip builder](images/tooltip/shape_tooltip_builder.png) - -N> -* Refer to the [`MapTooltipSettings`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTooltipSettings-class.html) class for customizing the tooltip. - -## Tooltip for the bubbles - -Tooltips clearly indicate bubble information on tap or click. To show a tooltip for a bubble, return a widget in [`MapShapeLayer.bubbleTooltipBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/bubbleTooltipBuilder.html). This widget will be wrapped in a built-in shape which comes with a nose at the bottom. - -The [`MapShapeLayer.bubbleTooltipBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/bubbleTooltipBuilder.html) will be called with the corresponding index every time you interact with the bubbles i.e., while tapping in touch devices and hover enter in mouse-enabled devices. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late List _data; - late MapShapeSource _shapeSource; - - @override - void initState() { - super.initState(); - - _data = [ - Model('Asia', 50, '44,579,000 sq. km.'), - Model('Africa', 54, '30,370,000 sq. km.'), - Model('Europe', 51, '10,180,000 sq. km.'), - Model('North America', 23, '24,709,000 sq. km.'), - Model('South America', 12, '17,840,000 sq. km.'), - Model('Australia', 14, '8,600,000 sq. km.'), - ]; - - _shapeSource = MapShapeSource.asset( - "assets/world_map.json", - shapeDataField: "continent", - dataCount: _data.length, - primaryValueMapper: (int index) => _data[index].continent, - bubbleSizeMapper: (int index) => _data[index].countriesCount, - ); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Padding( - padding: const EdgeInsets.only(left: 15, right: 15), - child: SfMaps( - layers: [ - MapShapeLayer( - source: _shapeSource, - bubbleTooltipBuilder: (BuildContext context, int index) { - return Container( - width: 150, - padding: const EdgeInsets.all(10), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Stack( - children: [ - Center( - child: Text( - _data[index].continent, - style: TextStyle( - color: Colors.white, - fontSize: Theme.of(context) - .textTheme - .bodyMedium! - .fontSize), - ), - ), - const Icon( - Icons.flag, - color: Colors.white, - size: 16, - ), - ], - ), - const Divider( - color: Colors.white, - height: 10, - thickness: 1.2, - ), - Text( - 'Total Countries : ' + - _data[index].countriesCount.toInt().toString(), - style: TextStyle( - color: Colors.white, - fontSize: - Theme.of(context).textTheme.bodyMedium!.fontSize), - ), - ], - ), - ); - }, - bubbleSettings: const MapBubbleSettings( - minRadius: 15, - maxRadius: 35, - ), - tooltipSettings: const MapTooltipSettings( - color: Color.fromRGBO(98, 0, 238, 1), - strokeColor: Color.fromRGBO(252, 187, 15, 1), - strokeWidth: 1.5), - ), - ], - ), - ), - ); - } -} - -class Model { - const Model(this.continent, this.countriesCount, this.area); - - final String continent; - final double countriesCount; - final String area; -} - -{% endhighlight %} -{% endtabs %} - -![Maps bubble tooltip builder](images/tooltip/bubble_tooltip_builder.png) - -N> -* Refer to the [`MapTooltipSettings`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTooltipSettings-class.html) class for customizing the tooltip. - -## Tooltip for the markers - -Tooltips clearly indicate marker information on tap or click. To show a tooltip for a marker, return a widget in [`MapLayer.markerTooltipBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/markerTooltipBuilder.html). This widget will be wrapped in a built-in shape which comes with a nose at the bottom. - -The [`MapLayer.markerTooltipBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/markerTooltipBuilder.html) will be called with the corresponding index every time you interact with the markers i.e., while tapping in touch devices and hover enter in mouse-enabled devices. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late List _data; - late MapShapeSource _shapeSource; - - @override - void initState() { - super.initState(); - - _data = [ - WorldWonderModel( - place: 'Chichen Itza', - country: 'Mexico', - latitude: 20.6843, - longitude: -88.5678), - WorldWonderModel( - place: 'Machu Picchu', - country: 'Peru', - latitude: -13.1631, - longitude: -72.5450), - WorldWonderModel( - place: 'Christ the Redeemer', - country: 'Brazil', - latitude: -22.9519, - longitude: -43.2105), - WorldWonderModel( - place: 'Colosseum', - country: 'Rome', - latitude: 41.8902, - longitude: 12.4922), - WorldWonderModel( - place: 'Petra', - country: 'Jordan', - latitude: 30.3285, - longitude: 35.4444), - WorldWonderModel( - place: 'Taj Mahal', - country: 'India', - latitude: 27.1751, - longitude: 78.0421), - WorldWonderModel( - place: 'Great Wall of China', - country: 'China', - latitude: 40.4319, - longitude: 116.5704) - ]; - - _shapeSource = MapShapeSource.asset( - "assets/world_map.json", - shapeDataField: "country", - ); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Padding( - padding: EdgeInsets.only(left: 15, right: 15), - child: SfMaps( - layers: [ - MapShapeLayer( - source: _shapeSource, - initialMarkersCount: _data.length, - markerBuilder: (BuildContext context, int index) { - return MapMarker( - latitude: _data[index].latitude, - longitude: _data[index].longitude, - child: const Icon( - Icons.location_on, - color: Colors.red, - ), - ); - }, - markerTooltipBuilder: (BuildContext context, int index) { - return Container( - width: 150, - padding: const EdgeInsets.all(10), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Stack( - children: [ - Center( - child: Text( - _data[index].country, - style: TextStyle( - color: Colors.white, - fontSize: Theme.of(context) - .textTheme - .bodyMedium! - .fontSize), - ), - ), - const Icon( - Icons.tour, - color: Colors.white, - size: 16, - ), - ], - ), - const Divider( - color: Colors.white, - height: 10, - thickness: 1.2, - ), - Text( - _data[index].place, - style: TextStyle( - color: Colors.white, - fontSize: - Theme.of(context).textTheme.bodyMedium!.fontSize), - ), - ], - ), - ); - }, - tooltipSettings: const MapTooltipSettings( - color: Colors.red, - strokeColor: Colors.black, - strokeWidth: 1.5), - ), - ], - ), - ), - ); - } -} - - -class WorldWonderModel { - const WorldWonderModel( - {required this.place, - required this.country, - required this.latitude, - required this.longitude}); - - final String place; - final String country; - final double latitude; - final double longitude; -} - -{% endhighlight %} -{% endtabs %} - -![Maps marker tooltip builder](images/tooltip/marker_tooltip_builder.png) - -N> -* Refer to the [`MapTooltipSettings`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTooltipSettings-class.html) class for customizing the tooltip. - -## Appearance customization - -You can customize the following aspects of the tooltip: - -* **Background color** - Change the background color of the tooltip using the [`MapTooltipSettings.color`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTooltipSettings/color.html) property. -* **Stroke color** - Change the stroke color of the tooltip using the [`MapTooltipSettings.strokeColor`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTooltipSettings/strokeColor.html) property. -* **Stroke width** - Change the stroke width of the tooltip using the [`MapTooltipSettings.strokeWidth`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTooltipSettings/strokeWidth.html) property. -* **Visibility** - Change the duration of the tooltip visibility using the [`hideDelay`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTooltipSettings/hideDelay.html) property. The default value of the [`hideDelay`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTooltipSettings/hideDelay.html) property is 3. By default, tooltip will hide automatically after 3 seconds of inactivity for mobile platforms. You can increase or decrease the tooltip duration or show tooltip always by setting `double.infinity` to the [`hideDelay`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTooltipSettings/hideDelay.html) property. - -N> For mobile platforms, the [`hideDelay`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTooltipSettings/hideDelay.html) option is supported. When you hover over the shape, bubble, or marker on the web or desktop, a tooltip will appear. When you remove hover from the shape, it will disappear. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late List _data; - late MapShapeSource _shapeSource; - - @override - void initState() { - super.initState(); - - _data = [ - Model('Asia', 50, '44,579,000 sq. km.'), - Model('Africa', 54, '30,370,000 sq. km.'), - Model('Europe', 51, '10,180,000 sq. km.'), - Model('North America', 23, '24,709,000 sq. km.'), - Model('South America', 12, '17,840,000 sq. km.'), - Model('Australia', 14, '8,600,000 sq. km.'), - ]; - - _shapeSource = MapShapeSource.asset( - "assets/world_map.json", - shapeDataField: "continent", - dataCount: _data.length, - primaryValueMapper: (int index) => _data[index].continent, - bubbleSizeMapper: (int index) => _data[index].countriesCount, - ); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Padding( - padding: const EdgeInsets.only(left: 15, right: 15), - child: SfMaps( - layers: [ - MapShapeLayer( - source: _shapeSource, - shapeTooltipBuilder: (BuildContext context, int index) { - return Padding( - padding: const EdgeInsets.all(7), - child: Text( - 'Continent : ' + - _data[index].continent + - '\nArea : ' + - _data[index].area, - style: const TextStyle( - color: Colors.white, - fontSize: 14, - fontStyle: FontStyle.italic, - fontFamily: 'Times', - ), - ), - ); - }, - bubbleTooltipBuilder: (BuildContext context, int index) { - return Padding( - padding: const EdgeInsets.all(7), - child: Text( - 'Continent : ' + - _data[index].continent + - '\nTotal Countries : ' + - _data[index].countriesCount.toStringAsFixed(0), - style: const TextStyle( - color: Colors.white, - fontSize: 14, - fontStyle: FontStyle.italic, - fontFamily: 'Times', - ), - ), - ); - }, - tooltipSettings: const MapTooltipSettings( - color: const Color.fromRGBO(98, 0, 238, 1), - strokeColor: const Color.fromRGBO(252, 187, 15, 1), - strokeWidth: 3, - hideDelay: 10, - ), - ), - ], - ), - ), - ); - } -} - -class Model { - const Model(this.continent, this.countriesCount, this.area); - - final String continent; - final double countriesCount; - final String area; -} - -{% endhighlight %} -{% endtabs %} - -Using SfMapsTheme - -You can also customize the appearance of the tooltip using [`SfMapsTheme`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsTheme-class.html): - -* **Background color** - Change the background color of the tooltip using the [`SfMapsThemeData.tooltipColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsThemeData/tooltipColor.html) property. -* **Stroke color** - Change the stroke color of the tooltip using the [`SfMapsThemeData.tooltipStrokeColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsThemeData/tooltipStrokeColor.html) property. -* **Stroke width** - Change the stroke width of the tooltip using the [`SfMapsThemeData.tooltipStrokeWidth`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsThemeData/tooltipStrokeWidth.html) property. -* **Border radius** - Change the appearance of the tooltip borders using the [`SfMapsThemeData.tooltipBorderRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsThemeData/tooltipBorderRadius.html) property. - -N> You must import the `theme.dart` library from the [`Core`](https://pub.dev/packages/syncfusion_flutter_core) package to use [`SfMapsTheme`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsTheme-class.html). - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late List _data; - late MapShapeSource _shapeSource; - - @override - void initState() { - super.initState(); - - _data = [ - Model('Asia', 50, '44,579,000 sq. km.'), - Model('Africa', 54, '30,370,000 sq. km.'), - Model('Europe', 51, '10,180,000 sq. km.'), - Model('North America', 23, '24,709,000 sq. km.'), - Model('South America', 12, '17,840,000 sq. km.'), - Model('Australia', 14, '8,600,000 sq. km.'), - ]; - - _shapeSource = MapShapeSource.asset( - "assets/world_map.json", - shapeDataField: "continent", - dataCount: _data.length, - primaryValueMapper: (int index) => _data[index].continent, - bubbleSizeMapper: (int index) => _data[index].countriesCount, - ); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Padding( - padding: EdgeInsets.only(left: 15, right: 15), - child: SfMapsTheme( - data: SfMapsThemeData( - tooltipColor: const Color.fromRGBO(98, 0, 238, 1), - tooltipStrokeColor: const Color.fromRGBO(252, 187, 15, 1), - tooltipStrokeWidth: 3, - tooltipBorderRadius: const BorderRadiusDirectional.only( - topStart: Radius.circular(20), - bottomEnd: Radius.circular(20), - ), - ), - child: SfMaps( - layers: [ - MapShapeLayer( - source: _shapeSource, - shapeTooltipBuilder: (BuildContext context, int index) { - return Padding( - padding: const EdgeInsets.all(7), - child: Text( - 'Continent : ' + - _data[index].continent + - '\nArea : ' + - _data[index].area, - style: const TextStyle( - color: Colors.white, - fontSize: 14, - fontStyle: FontStyle.italic, - fontFamily: 'Times', - ), - ), - ); - }, - bubbleTooltipBuilder: (BuildContext context, int index) { - return Padding( - padding: const EdgeInsets.all(7), - child: Text( - 'Continent : ' + - _data[index].continent + - '\nTotal Countries : ' + - _data[index].countriesCount.toStringAsFixed(0), - style: const TextStyle( - color: Colors.white, - fontSize: 14, - fontStyle: FontStyle.italic, - fontFamily: 'Times', - ), - ), - ); - }, - ), - ], - ), - ), - ), - ); - } -} - -class Model { - const Model(this.continent, this.countriesCount, this.area); - - final String continent; - final double countriesCount; - final String area; -} - -{% endhighlight %} -{% endtabs %} - -![Maps tooltip appearance customization](images/tooltip/tooltip_textStyle.png) - -N> -* Refer to the [`MapShapeLayer.shapeTooltipBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/shapeTooltipBuilder.html) property for enabling tooltip for shapes. -* Refer to the [`MapShapeLayer.bubbleTooltipBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/bubbleTooltipBuilder.html) property for enabling tooltip for bubbles. -* Refer to the [`MapLayer.markerTooltipBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/markerTooltipBuilder.html) property for enabling tooltip for markers. - +--- +layout: post +title: Tooltip in Flutter Maps widget | Syncfusion +description: Learn here all about adding the Tooltip feature of Syncfusion Flutter Maps (SfMaps) widget and more. +platform: flutter +control: SfMaps +documentation: ug +--- + +# Tooltip in Flutter Maps (SfMaps) + +Tooltip is used to indicate shape, bubble, and marker information during tap or click interactions. This section helps you learn how to show tooltips for shapes, bubbles, and markers in Flutter Maps and customize them. + +## Tooltip for the shapes + +Tooltips clearly indicate shape information on tap or click. To show a tooltip for a shape, return a widget in [`MapShapeLayer.shapeTooltipBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/shapeTooltipBuilder.html). This widget will be wrapped in a built-in shape which comes with a nose at the bottom. + +The [`MapShapeLayer.shapeTooltipBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/shapeTooltipBuilder.html) will be called with the corresponding index every time you interact with the shapes i.e., while tapping in touch devices and hover enter in mouse-enabled devices. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late List _data; + late MapShapeSource _shapeSource; + + @override + void initState() { + super.initState(); + + _data = [ + Model('Asia', 50, '44,579,000 sq. km.'), + Model('Africa', 54, '30,370,000 sq. km.'), + Model('Europe', 51, '10,180,000 sq. km.'), + Model('North America', 23, '24,709,000 sq. km.'), + Model('South America', 12, '17,840,000 sq. km.'), + Model('Australia', 14, '8,600,000 sq. km.'), + ]; + + _shapeSource = MapShapeSource.asset( + "assets/world_map.json", + shapeDataField: "continent", + dataCount: _data.length, + primaryValueMapper: (int index) => _data[index].continent, + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Padding( + padding: const EdgeInsets.only(left: 15, right: 15), + child: SfMaps( + layers: [ + MapShapeLayer( + source: _shapeSource, + shapeTooltipBuilder: (BuildContext context, int index) { + return Container( + width: 180, + padding: const EdgeInsets.all(10), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Stack( + children: [ + Center( + child: Text( + _data[index].continent, + style: TextStyle( + color: Colors.white, + fontSize: Theme.of(context) + .textTheme + .bodyMedium! + .fontSize), + ), + ), + const Icon( + Icons.map, + color: Colors.white, + size: 16, + ), + ], + ), + const Divider( + color: Colors.white, + height: 10, + thickness: 1.2, + ), + Text( + 'Area : ' + _data[index].area, + style: TextStyle( + color: Colors.white, + fontSize: + Theme.of(context).textTheme.bodyMedium!.fontSize), + ), + ], + ), + ); + }, + tooltipSettings: const MapTooltipSettings( + color: Colors.blue, + strokeColor: Color.fromRGBO(252, 187, 15, 1), + strokeWidth: 1.5), + ), + ], + ), + ), + ); + } +} + +class Model { + const Model(this.continent, this.countriesCount, this.area); + + final String continent; + final double countriesCount; + final String area; +} + +{% endhighlight %} +{% endtabs %} + +![Maps shape tooltip builder](images/tooltip/shape_tooltip_builder.png) + +N> +* Refer to the [`MapTooltipSettings`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTooltipSettings-class.html) class for customizing the tooltip. + +## Tooltip for the bubbles + +Tooltips clearly indicate bubble information on tap or click. To show a tooltip for a bubble, return a widget in [`MapShapeLayer.bubbleTooltipBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/bubbleTooltipBuilder.html). This widget will be wrapped in a built-in shape which comes with a nose at the bottom. + +The [`MapShapeLayer.bubbleTooltipBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/bubbleTooltipBuilder.html) will be called with the corresponding index every time you interact with the bubbles i.e., while tapping in touch devices and hover enter in mouse-enabled devices. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late List _data; + late MapShapeSource _shapeSource; + + @override + void initState() { + super.initState(); + + _data = [ + Model('Asia', 50, '44,579,000 sq. km.'), + Model('Africa', 54, '30,370,000 sq. km.'), + Model('Europe', 51, '10,180,000 sq. km.'), + Model('North America', 23, '24,709,000 sq. km.'), + Model('South America', 12, '17,840,000 sq. km.'), + Model('Australia', 14, '8,600,000 sq. km.'), + ]; + + _shapeSource = MapShapeSource.asset( + "assets/world_map.json", + shapeDataField: "continent", + dataCount: _data.length, + primaryValueMapper: (int index) => _data[index].continent, + bubbleSizeMapper: (int index) => _data[index].countriesCount, + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Padding( + padding: const EdgeInsets.only(left: 15, right: 15), + child: SfMaps( + layers: [ + MapShapeLayer( + source: _shapeSource, + bubbleTooltipBuilder: (BuildContext context, int index) { + return Container( + width: 150, + padding: const EdgeInsets.all(10), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Stack( + children: [ + Center( + child: Text( + _data[index].continent, + style: TextStyle( + color: Colors.white, + fontSize: Theme.of(context) + .textTheme + .bodyMedium! + .fontSize), + ), + ), + const Icon( + Icons.flag, + color: Colors.white, + size: 16, + ), + ], + ), + const Divider( + color: Colors.white, + height: 10, + thickness: 1.2, + ), + Text( + 'Total Countries : ' + + _data[index].countriesCount.toInt().toString(), + style: TextStyle( + color: Colors.white, + fontSize: + Theme.of(context).textTheme.bodyMedium!.fontSize), + ), + ], + ), + ); + }, + bubbleSettings: const MapBubbleSettings( + minRadius: 15, + maxRadius: 35, + ), + tooltipSettings: const MapTooltipSettings( + color: Color.fromRGBO(98, 0, 238, 1), + strokeColor: Color.fromRGBO(252, 187, 15, 1), + strokeWidth: 1.5), + ), + ], + ), + ), + ); + } +} + +class Model { + const Model(this.continent, this.countriesCount, this.area); + + final String continent; + final double countriesCount; + final String area; +} + +{% endhighlight %} +{% endtabs %} + +![Maps bubble tooltip builder](images/tooltip/bubble_tooltip_builder.png) + +N> +* Refer to the [`MapTooltipSettings`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTooltipSettings-class.html) class for customizing the tooltip. + +## Tooltip for the markers + +Tooltips clearly indicate marker information on tap or click. To show a tooltip for a marker, return a widget in [`MapLayer.markerTooltipBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/markerTooltipBuilder.html). This widget will be wrapped in a built-in shape which comes with a nose at the bottom. + +The [`MapLayer.markerTooltipBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/markerTooltipBuilder.html) will be called with the corresponding index every time you interact with the markers i.e., while tapping in touch devices and hover enter in mouse-enabled devices. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late List _data; + late MapShapeSource _shapeSource; + + @override + void initState() { + super.initState(); + + _data = [ + WorldWonderModel( + place: 'Chichen Itza', + country: 'Mexico', + latitude: 20.6843, + longitude: -88.5678), + WorldWonderModel( + place: 'Machu Picchu', + country: 'Peru', + latitude: -13.1631, + longitude: -72.5450), + WorldWonderModel( + place: 'Christ the Redeemer', + country: 'Brazil', + latitude: -22.9519, + longitude: -43.2105), + WorldWonderModel( + place: 'Colosseum', + country: 'Rome', + latitude: 41.8902, + longitude: 12.4922), + WorldWonderModel( + place: 'Petra', + country: 'Jordan', + latitude: 30.3285, + longitude: 35.4444), + WorldWonderModel( + place: 'Taj Mahal', + country: 'India', + latitude: 27.1751, + longitude: 78.0421), + WorldWonderModel( + place: 'Great Wall of China', + country: 'China', + latitude: 40.4319, + longitude: 116.5704) + ]; + + _shapeSource = MapShapeSource.asset( + "assets/world_map.json", + shapeDataField: "country", + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Padding( + padding: EdgeInsets.only(left: 15, right: 15), + child: SfMaps( + layers: [ + MapShapeLayer( + source: _shapeSource, + initialMarkersCount: _data.length, + markerBuilder: (BuildContext context, int index) { + return MapMarker( + latitude: _data[index].latitude, + longitude: _data[index].longitude, + child: const Icon( + Icons.location_on, + color: Colors.red, + ), + ); + }, + markerTooltipBuilder: (BuildContext context, int index) { + return Container( + width: 150, + padding: const EdgeInsets.all(10), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Stack( + children: [ + Center( + child: Text( + _data[index].country, + style: TextStyle( + color: Colors.white, + fontSize: Theme.of(context) + .textTheme + .bodyMedium! + .fontSize), + ), + ), + const Icon( + Icons.tour, + color: Colors.white, + size: 16, + ), + ], + ), + const Divider( + color: Colors.white, + height: 10, + thickness: 1.2, + ), + Text( + _data[index].place, + style: TextStyle( + color: Colors.white, + fontSize: + Theme.of(context).textTheme.bodyMedium!.fontSize), + ), + ], + ), + ); + }, + tooltipSettings: const MapTooltipSettings( + color: Colors.red, + strokeColor: Colors.black, + strokeWidth: 1.5), + ), + ], + ), + ), + ); + } +} + + +class WorldWonderModel { + const WorldWonderModel( + {required this.place, + required this.country, + required this.latitude, + required this.longitude}); + + final String place; + final String country; + final double latitude; + final double longitude; +} + +{% endhighlight %} +{% endtabs %} + +![Maps marker tooltip builder](images/tooltip/marker_tooltip_builder.png) + +N> +* Refer to the [`MapTooltipSettings`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTooltipSettings-class.html) class for customizing the tooltip. + +## Appearance customization + +You can customize the following aspects of the tooltip: + +* **Background color** - Change the background color of the tooltip using the [`MapTooltipSettings.color`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTooltipSettings/color.html) property. +* **Stroke color** - Change the stroke color of the tooltip using the [`MapTooltipSettings.strokeColor`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTooltipSettings/strokeColor.html) property. +* **Stroke width** - Change the stroke width of the tooltip using the [`MapTooltipSettings.strokeWidth`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTooltipSettings/strokeWidth.html) property. +* **Visibility** - Change the duration of the tooltip visibility using the [`hideDelay`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTooltipSettings/hideDelay.html) property. The default value of the [`hideDelay`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTooltipSettings/hideDelay.html) property is 3. By default, tooltip will hide automatically after 3 seconds of inactivity for mobile platforms. You can increase or decrease the tooltip duration or show tooltip always by setting `double.infinity` to the [`hideDelay`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTooltipSettings/hideDelay.html) property. + +N> For mobile platforms, the [`hideDelay`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTooltipSettings/hideDelay.html) option is supported. When you hover over the shape, bubble, or marker on the web or desktop, a tooltip will appear. When you remove hover from the shape, it will disappear. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late List _data; + late MapShapeSource _shapeSource; + + @override + void initState() { + super.initState(); + + _data = [ + Model('Asia', 50, '44,579,000 sq. km.'), + Model('Africa', 54, '30,370,000 sq. km.'), + Model('Europe', 51, '10,180,000 sq. km.'), + Model('North America', 23, '24,709,000 sq. km.'), + Model('South America', 12, '17,840,000 sq. km.'), + Model('Australia', 14, '8,600,000 sq. km.'), + ]; + + _shapeSource = MapShapeSource.asset( + "assets/world_map.json", + shapeDataField: "continent", + dataCount: _data.length, + primaryValueMapper: (int index) => _data[index].continent, + bubbleSizeMapper: (int index) => _data[index].countriesCount, + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Padding( + padding: const EdgeInsets.only(left: 15, right: 15), + child: SfMaps( + layers: [ + MapShapeLayer( + source: _shapeSource, + shapeTooltipBuilder: (BuildContext context, int index) { + return Padding( + padding: const EdgeInsets.all(7), + child: Text( + 'Continent : ' + + _data[index].continent + + '\nArea : ' + + _data[index].area, + style: const TextStyle( + color: Colors.white, + fontSize: 14, + fontStyle: FontStyle.italic, + fontFamily: 'Times', + ), + ), + ); + }, + bubbleTooltipBuilder: (BuildContext context, int index) { + return Padding( + padding: const EdgeInsets.all(7), + child: Text( + 'Continent : ' + + _data[index].continent + + '\nTotal Countries : ' + + _data[index].countriesCount.toStringAsFixed(0), + style: const TextStyle( + color: Colors.white, + fontSize: 14, + fontStyle: FontStyle.italic, + fontFamily: 'Times', + ), + ), + ); + }, + tooltipSettings: const MapTooltipSettings( + color: const Color.fromRGBO(98, 0, 238, 1), + strokeColor: const Color.fromRGBO(252, 187, 15, 1), + strokeWidth: 3, + hideDelay: 10, + ), + ), + ], + ), + ), + ); + } +} + +class Model { + const Model(this.continent, this.countriesCount, this.area); + + final String continent; + final double countriesCount; + final String area; +} + +{% endhighlight %} +{% endtabs %} + +Using SfMapsTheme + +You can also customize the appearance of the tooltip using [`SfMapsTheme`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsTheme-class.html): + +* **Background color** - Change the background color of the tooltip using the [`SfMapsThemeData.tooltipColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsThemeData/tooltipColor.html) property. +* **Stroke color** - Change the stroke color of the tooltip using the [`SfMapsThemeData.tooltipStrokeColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsThemeData/tooltipStrokeColor.html) property. +* **Stroke width** - Change the stroke width of the tooltip using the [`SfMapsThemeData.tooltipStrokeWidth`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsThemeData/tooltipStrokeWidth.html) property. +* **Border radius** - Change the appearance of the tooltip borders using the [`SfMapsThemeData.tooltipBorderRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsThemeData/tooltipBorderRadius.html) property. + +N> You must import the `theme.dart` library from the [`Core`](https://pub.dev/packages/syncfusion_flutter_core) package to use [`SfMapsTheme`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfMapsTheme-class.html). + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late List _data; + late MapShapeSource _shapeSource; + + @override + void initState() { + super.initState(); + + _data = [ + Model('Asia', 50, '44,579,000 sq. km.'), + Model('Africa', 54, '30,370,000 sq. km.'), + Model('Europe', 51, '10,180,000 sq. km.'), + Model('North America', 23, '24,709,000 sq. km.'), + Model('South America', 12, '17,840,000 sq. km.'), + Model('Australia', 14, '8,600,000 sq. km.'), + ]; + + _shapeSource = MapShapeSource.asset( + "assets/world_map.json", + shapeDataField: "continent", + dataCount: _data.length, + primaryValueMapper: (int index) => _data[index].continent, + bubbleSizeMapper: (int index) => _data[index].countriesCount, + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Padding( + padding: EdgeInsets.only(left: 15, right: 15), + child: SfMapsTheme( + data: SfMapsThemeData( + tooltipColor: const Color.fromRGBO(98, 0, 238, 1), + tooltipStrokeColor: const Color.fromRGBO(252, 187, 15, 1), + tooltipStrokeWidth: 3, + tooltipBorderRadius: const BorderRadiusDirectional.only( + topStart: Radius.circular(20), + bottomEnd: Radius.circular(20), + ), + ), + child: SfMaps( + layers: [ + MapShapeLayer( + source: _shapeSource, + shapeTooltipBuilder: (BuildContext context, int index) { + return Padding( + padding: const EdgeInsets.all(7), + child: Text( + 'Continent : ' + + _data[index].continent + + '\nArea : ' + + _data[index].area, + style: const TextStyle( + color: Colors.white, + fontSize: 14, + fontStyle: FontStyle.italic, + fontFamily: 'Times', + ), + ), + ); + }, + bubbleTooltipBuilder: (BuildContext context, int index) { + return Padding( + padding: const EdgeInsets.all(7), + child: Text( + 'Continent : ' + + _data[index].continent + + '\nTotal Countries : ' + + _data[index].countriesCount.toStringAsFixed(0), + style: const TextStyle( + color: Colors.white, + fontSize: 14, + fontStyle: FontStyle.italic, + fontFamily: 'Times', + ), + ), + ); + }, + ), + ], + ), + ), + ), + ); + } +} + +class Model { + const Model(this.continent, this.countriesCount, this.area); + + final String continent; + final double countriesCount; + final String area; +} + +{% endhighlight %} +{% endtabs %} + +![Maps tooltip appearance customization](images/tooltip/tooltip_textStyle.png) + +N> +* Refer to the [`MapShapeLayer.shapeTooltipBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/shapeTooltipBuilder.html) property for enabling tooltip for shapes. +* Refer to the [`MapShapeLayer.bubbleTooltipBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer/bubbleTooltipBuilder.html) property for enabling tooltip for bubbles. +* Refer to the [`MapLayer.markerTooltipBuilder`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/markerTooltipBuilder.html) property for enabling tooltip for markers. + N> You can refer to our [Flutter Maps](https://www.syncfusion.com/flutter-widgets/flutter-maps) feature tour page for its groundbreaking feature representations. You can also explore our [Flutter Maps Tooltip example](https://flutter.syncfusion.com/#/maps/shape-layer/tooltip) that shows how to configure a Maps in Flutter. \ No newline at end of file diff --git a/Flutter/maps/zoom-pan.md b/Flutter/maps/zoom-pan.md index abc2defee..aefedb71a 100644 --- a/Flutter/maps/zoom-pan.md +++ b/Flutter/maps/zoom-pan.md @@ -1,968 +1,968 @@ ---- -layout: post -title: Zooming and Panning in Flutter Maps | Syncfusion® -description: Learn about zooming and panning in Syncfusion® Flutter Maps (SfMaps), including zoom levels, focal points, toolbar support, and interaction settings. -platform: flutter -control: SfMaps -documentation: ug ---- - -# Zooming and Panning in Flutter Maps (SfMaps) - -It is possible to zoom in and out for any layer to take a closer look at a specific region by pinching the map, scrolling the mouse wheel or track-pad, or using the toolbar on the web. You can also pan the map to navigate across regions and customize the zoom level and center point of the initial rendering. - -The procedure for zooming and panning is very similar for both layers. - -**Shape layer** - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late MapZoomPanBehavior _zoomPanBehavior; - late MapShapeSource _dataSource; - - @override - void initState() { - super.initState(); - _dataSource = MapShapeSource.asset( - 'assets/world_map.json', - shapeDataField: 'continent', - ); - _zoomPanBehavior = MapZoomPanBehavior(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: SfMaps( - layers: [ - MapShapeLayer( - source: _dataSource, - zoomPanBehavior: _zoomPanBehavior, - ), - ], - ), - ); - } -} - -{% endhighlight %} -{% endtabs %} - -**Tile layer** - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late MapZoomPanBehavior _zoomPanBehavior; - - @override - void initState() { - super.initState(); - _zoomPanBehavior = MapZoomPanBehavior(); - } - - @override - Widget build(BuildContext context) { - return FutureBuilder( - future: getBingUrlTemplate( - 'https://dev.virtualearth.net/REST/V1/Imagery/Metadata/AerialWithLabels?output=json&uriScheme=https&include=ImageryProviders&key=YOUR_KEY'), - builder: (context, snapshot) { - if (snapshot.hasData) { - return SfMaps( - layers: [ - MapTileLayer( - urlTemplate: snapshot.data as String, - zoomPanBehavior: _zoomPanBehavior, - ), - ], - ); - } - return CircularProgressIndicator(); - } - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Bing maps aerial default](images/zoom-pan/bing_maps_aerial.png) - -## Customizing the center latitude and longitude - -The [`MapZoomPanBehavior.focalLatLng`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/focalLatLng.html) is the focal point of the map layer based on which zooming happens. It represents the focal latitude and longitude position of the map layer. You can also get the current focalLatLng after interaction using the [`MapZoomPanBehavior.focalLatLng`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/focalLatLng.html) property. - -To enable panning, set the instance of [`MapZoomPanBehavior`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior-class.html) to [`MapTileLayer.zoomPanBehavior`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/zoomPanBehavior.html). By default, panning is enabled. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late MapZoomPanBehavior _zoomPanBehavior; - - @override - void initState() { - super.initState(); - _zoomPanBehavior = MapZoomPanBehavior( - focalLatLng: MapLatLng(27.1751, 50.0421), - ); - } - - @override - Widget build(BuildContext context) { - return FutureBuilder( - future: getBingUrlTemplate( - 'https://dev.virtualearth.net/REST/V1/Imagery/Metadata/AerialWithLabels?output=json&uriScheme=https&include=ImageryProviders&key=YOUR_KEY'), - builder: (context, snapshot) { - if (snapshot.hasData) { - return SfMaps( - layers: [ - MapTileLayer( - urlTemplate: snapshot.data as String, - zoomPanBehavior: _zoomPanBehavior, - ), - ], - ); - } - return CircularProgressIndicator(); - } - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Bing maps aerial focalLatLng](images/zoom-pan/bing_maps_focallatlng.png) - -## Update the center latitude and longitude programmatically - -You can change the center latitude and longitude of the shape layer programmatically using the [`MapZoomPanBehavior.focalLatLng`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/focalLatLng.html) property. - -N> This is applicable for both shape layer and tile layer. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late MapZoomPanBehavior _zoomPanBehavior; - late MapShapeSource _dataSource; - - @override - void initState() { - super.initState(); - _dataSource = MapShapeSource.asset( - 'assets/world_map.json', - shapeDataField: 'continent', - ); - - _zoomPanBehavior = MapZoomPanBehavior( - focalLatLng: MapLatLng(27.1751, 78.0421), - zoomLevel: 4, - ); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Column( - children: [ - Container( - height: 600, - child: SfMaps( - layers: [ - MapShapeLayer( - source: _dataSource, - zoomPanBehavior: _zoomPanBehavior, - ), - ], - ), - ), - SizedBox(height: 20), - ElevatedButton( - child: Text('Change focalLatLng'), - onPressed: () { - _zoomPanBehavior.focalLatLng = MapLatLng(56.1304, -106.3468); - }, - ), - ], - ), - ); - } -} - -{% endhighlight %} -{% endtabs %} - -## Customizing the zoom level - -You can set the current zoom level of the map layer by using the [`MapZoomPanBehavior.zoomLevel`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/zoomLevel.html) property. - -The default [`MapZoomPanBehavior.zoomLevel`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/zoomLevel.html) value is 1, which will show the whole map in the viewport for [`MapShapeLayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer-class.html) and the possible bounds for the [`MapShapeLayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer-class.html) based on the [`MapZoomPanBehavior.focalLatLng`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/focalLatLng.html). You can also get the current zoom level after interaction using the [`MapZoomPanBehavior.zoomLevel`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/zoomLevel.html) property. - -To enable zooming, set the instance of [`MapZoomPanBehavior`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior-class.html) to [`MapTileLayer.zoomPanBehavior`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/zoomPanBehavior.html). By default, zooming is enabled. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late MapZoomPanBehavior _zoomPanBehavior; - - @override - void initState() { - super.initState(); - _zoomPanBehavior = MapZoomPanBehavior( - focalLatLng: MapLatLng(27.1751, 78.0421), - zoomLevel: 5, - ); - } - - @override - Widget build(BuildContext context) { - return FutureBuilder( - future: getBingUrlTemplate( - 'https://dev.virtualearth.net/REST/V1/Imagery/Metadata/AerialWithLabels?output=json&uriScheme=https&include=ImageryProviders&key=YOUR_KEY'), - builder: (context, snapshot) { - if (snapshot.hasData) { - return SfMaps( - layers: [ - MapTileLayer( - urlTemplate: snapshot.data as String, - zoomPanBehavior: _zoomPanBehavior, - ), - ], - ); - } - return CircularProgressIndicator(); - } - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Bing maps aerial zoomlevel](images/zoom-pan/bing_maps_zoomlevel.png) - -## Update the zoom level programmatically - -You can change the zoom level of the shape layer programmatically using the [`MapZoomPanBehavior.zoomLevel`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/zoomLevel.html) property. - -N> This is applicable for both shape layer and tile layer. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late MapZoomPanBehavior _zoomPanBehavior; - late MapShapeSource _dataSource; - - @override - void initState() { - _dataSource = MapShapeSource.asset( - 'assets/world_map.json', - shapeDataField: 'continent', - ); - _zoomPanBehavior = MapZoomPanBehavior( - focalLatLng: MapLatLng(27.1751, 78.0421), - zoomLevel: 2, - ); - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Column( - children: [ - Container( - height: 600, - child: SfMaps( - layers: [ - MapShapeLayer( - source: _dataSource, - zoomPanBehavior: _zoomPanBehavior, - ), - ], - ), - ), - SizedBox(height: 20), - ElevatedButton( - child: Text('Change zoomLevel'), - onPressed: () { - _zoomPanBehavior.zoomLevel = 7; - }, - ), - ], - ), - ); - } -} - -{% endhighlight %} -{% endtabs %} - -## Customizing min and max zoom level - -You can set the minimum and maximum zoom level of the map layer by setting values to the [`MapZoomPanBehavior.minZoomLevel`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/minZoomLevel.html) and [`MapZoomPanBehavior.maxZoomLevel`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/maxZoomLevel.html) properties. The minimum and maximum zooming levels can be restricted using these properties respectively. The default values of [`MapZoomPanBehavior.minZoomLevel`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/minZoomLevel.html) and [`MapZoomPanBehavior.maxZoomLevel`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/maxZoomLevel.html) are 1 and 15 respectively. - -However, for [`MapTileLayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTileLayer-class.html), [`MapZoomPanBehavior.maxZoomLevel`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/maxZoomLevel.html) may slightly vary depending on the providers. Please check the respective official website of the map tile providers to know about the maximum zoom level they support. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late MapZoomPanBehavior _zoomPanBehavior; - - @override - void initState() { - super.initState(); - _zoomPanBehavior = MapZoomPanBehavior( - focalLatLng: MapLatLng(27.1751, 78.0421), - zoomLevel: 5, - minZoomLevel: 3, - maxZoomLevel: 10, - ); - } - - @override - Widget build(BuildContext context) { - return FutureBuilder( - future: getBingUrlTemplate( - 'https://dev.virtualearth.net/REST/V1/Imagery/Metadata/AerialWithLabels?output=json&uriScheme=https&include=ImageryProviders&key=YOUR_KEY'), - builder: (context, snapshot) { - if (snapshot.hasData) { - return SfMaps( - layers: [ - MapTileLayer( - urlTemplate: snapshot.data as String, - zoomPanBehavior: _zoomPanBehavior, - ), - ], - ); - } - return CircularProgressIndicator(); - } - ); - } -} - -{% endhighlight %} -{% endtabs %} - -## Double tap zooming - -Double tap zooming can be enabled using the [`enableDoubleTapZooming`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/enableDoubleTapZooming.html) property. The default value of the [`enableDoubleTapZooming`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/enableDoubleTapZooming.html) is `false`. - -N> This is applicable for both tile layer and shape layer. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late MapZoomPanBehavior _zoomPanBehavior; - - @override - void initState() { - _zoomPanBehavior = MapZoomPanBehavior(enableDoubleTapZooming: true); - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: SfMaps( - layers: [ - MapTileLayer( - urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', - zoomPanBehavior: _zoomPanBehavior, - ), - ], - ), - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Double tap zooming](images/zoom-pan/double_tap_zoom.gif) - -## Toolbar - -The toolbar can be used to perform zoom in, zoom out, and reset operations in the web and desktop platforms. By default, the [`MapZoomPanBehavior.showToolbar`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/showToolbar.html) property is `true`. - -## Toolbar customization - -You can customize the toolbar items using the following properties: - -* **Position** - Used to position the toolbar item at the four corners of the map visual bounds using the [`position`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapToolbarSettings/position.html) property. The default value of the [`position`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapToolbarSettings/position.html) property is `MapToolbarPosition.topRight`. The possible values are [`topRight`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapToolbarPosition.html#topRight), [`topLeft`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapToolbarPosition.html#topLeft), [`bottomLeft`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapToolbarPosition.html#bottomLeft), and [`bottomRight`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapToolbarPosition.html#bottomRight). - -* **Icon color** - Used to set color to the three icons using the [`iconColor`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapToolbarSettings/iconColor.html) property. - -* **Item background color** - Used to set background color of the toolbar icons using the [`itemBackgroundColor`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapToolbarSettings/itemBackgroundColor.html) property. - -* **Item hover color** - Used to set color while hovering over the icon using the [`itemHoverColor`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapToolbarSettings/itemHoverColor.html) property. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late MapZoomPanBehavior _zoomPanBehavior; - - @override - void initState() { - _zoomPanBehavior = MapZoomPanBehavior( - focalLatLng: MapLatLng(27.1751, 78.0421), - zoomLevel: 3, - showToolbar: true, - toolbarSettings: MapToolbarSettings( - position: MapToolbarPosition.topLeft, - iconColor: Colors.red, - itemBackgroundColor: Colors.green, - itemHoverColor: Colors.blue, - ), - ); - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Container( - height: 350, - width: 350, - child: SfMaps( - layers: [ - MapTileLayer( - urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', - zoomPanBehavior: _zoomPanBehavior, - ), - ], - ), - ), - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Toolbar customization](images/zoom-pan/toolbar_customization.gif) - -## Zooming callback - -Whenever zooming happens, this callback is called. If it returns false, zooming will not happen. - -[`MapZoomDetails`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomDetails-class.html) contains the following properties: - -* [`MapZoomDetails.previousVisibleBounds`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomDetails/previousVisibleBounds.html) - Provides the visible bounds before the current zooming operation completes i.e. current visible bounds. -* [`MapZoomDetails.newVisibleBounds`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomDetails/newVisibleBounds.html) - Provides the new visible bounds when the current zoom completes. Hence, if it returns false, there will be no changes in the UI. -* [`MapZoomDetails.previousZoomLevel`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomDetails/previousZoomLevel.html) - Provides the zoom level before the current zooming operation completes i.e. current zoom level. -* [`MapZoomDetails.newZoomLevel`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomDetails/newZoomLevel.html) - Provides the new zoom level when the current zoom completes. Hence, if it returns false, there will be no changes in the UI. -* [`MapZoomDetails.globalFocalPoint`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomDetails/globalFocalPoint.html) - The global focal point of the pointers in contact with the screen. -* [`MapZoomDetails.localFocalPoint`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomDetails/localFocalPoint.html) - The local focal point of the pointers in contact with the screen. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late MapZoomPanBehavior _zoomPanBehavior; - - @override - void initState() { - super.initState(); - _zoomPanBehavior = MapZoomPanBehavior(); - } - - @override - Widget build(BuildContext context) { - return FutureBuilder( - future: getBingUrlTemplate( - 'https://dev.virtualearth.net/REST/V1/Imagery/Metadata/AerialWithLabels?output=json&uriScheme=https&include=ImageryProviders&key=YOUR_KEY'), - builder: (context, snapshot) { - if (snapshot.hasData) { - return SfMaps( - layers: [ - MapTileLayer( - urlTemplate: snapshot.data as String, - zoomPanBehavior: _zoomPanBehavior, - onWillZoom: (MapZoomDetails detail) { - return true; - }, - ), - ], - ); - } - return CircularProgressIndicator(); - } - ); - } -} - -{% endhighlight %} -{% endtabs %} - -## Panning callback - -Whenever panning happens, this callback is called. If it returns false, panning will not happen. - -[`MapPanDetails`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapPanDetails-class.html) contains the following properties: - -* [`MapPanDetails.previousVisibleBounds`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapPanDetails/previousVisibleBounds.html) - Provides the visible bounds before the current panning operation completes i.e. current visible bounds. -* [`MapPanDetails.newVisibleBounds`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapPanDetails/newVisibleBounds.html) - Provides the new visible bounds when the current pan completes. Hence, if it returns false, there will be no changes in the UI. -* [`MapPanDetails.zoomLevel`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapPanDetails/zoomLevel.html) - Provides the current zoom level. -* [`MapPanDetails.delta`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapPanDetails/delta.html) - The difference in pixels between touch start and current touch position. -* [`MapPanDetails.globalFocalPoint`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapPanDetails/globalFocalPoint.html) - The global focal point of the pointers in contact with the screen. -* [`MapPanDetails.localFocalPoint`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapPanDetails/localFocalPoint.html) - The local focal point of the pointers in contact with the screen. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late MapZoomPanBehavior _zoomPanBehavior; - - @override - void initState() { - super.initState(); - _zoomPanBehavior = MapZoomPanBehavior(); - } - - @override - Widget build(BuildContext context) { - return FutureBuilder( - future: getBingUrlTemplate( - 'https://dev.virtualearth.net/REST/V1/Imagery/Metadata/AerialWithLabels?output=json&uriScheme=https&include=ImageryProviders&key=YOUR_KEY'), - builder: (context, snapshot) { - if (snapshot.hasData) { - return SfMaps( - layers: [ - MapTileLayer( - urlTemplate: snapshot.data as String, - zoomPanBehavior: _zoomPanBehavior, - onWillPan: (MapPanDetails detail) { - return true; - }, - ), - ], - ); - } - return CircularProgressIndicator(); - } - ); - } -} - -{% endhighlight %} -{% endtabs %} - -## Overriding the zoom pan behavior - -### Zooming - -Whenever zooming happens, this method is called. Subclasses can override this method to do any custom operations based on the details provided in the [`MapZoomDetails`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomDetails-class.html). - -[`MapZoomDetails`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomDetails-class.html) contains the following properties: - -* [`MapZoomDetails.previousVisibleBounds`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomDetails/previousVisibleBounds.html) - Provides the visible bounds before the current zooming operation completes i.e. current visible bounds. -* [`MapZoomDetails.newVisibleBounds`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomDetails/newVisibleBounds.html) - Provides the new visible bounds when the current zoom completes. Hence, if the `super.onZooming(details)` is not called, there will be no changes in the UI. -* [`MapZoomDetails.previousZoomLevel`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomDetails/previousZoomLevel.html) - Provides the zoom level before the current zooming operation completes i.e. current zoom level. -* [`MapZoomDetails.newZoomLevel`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomDetails/newZoomLevel.html) - Provides the new zoom level when the current zoom completes. Hence, if the `super.onZooming(details)` is not called, there will be no changes in the UI. -* [`MapZoomDetails.globalFocalPoint`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomDetails/globalFocalPoint.html) - The global focal point of the pointers in contact with the screen. -* [`MapZoomDetails.localFocalPoint`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomDetails/localFocalPoint.html) - The local focal point of the pointers in contact with the screen. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late MapZoomPanBehavior _zoomPanBehavior; - - @override - void initState() { - super.initState(); - _zoomPanBehavior = _CustomZoomPanBehavior(); - } - - @override - Widget build(BuildContext context) { - return FutureBuilder( - future: getBingUrlTemplate( - 'https://dev.virtualearth.net/REST/V1/Imagery/Metadata/AerialWithLabels?output=json&uriScheme=https&include=ImageryProviders&key=YOUR_KEY'), - builder: (context, snapshot) { - if (snapshot.hasData) { - return SfMaps( - layers: [ - MapTileLayer( - urlTemplate: snapshot.data as String, - zoomPanBehavior: _zoomPanBehavior, - ), - ], - ); - } - return CircularProgressIndicator(); - } - ); - } -} - -class _CustomZoomPanBehavior extends MapZoomPanBehavior { - - @override - void onZooming(MapZoomDetails details) { - super.onZooming(details); - // Add the code here. - } -} - -{% endhighlight %} -{% endtabs %} - -N> -* When `super.onZooming(details)` is not called, zooming will not happen. - -### Panning - -Whenever panning happens, this method is called. Subclasses can override this method to do any custom operations based on the details provided in the [`MapPanDetails`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapPanDetails-class.html). - -[`MapPanDetails`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapPanDetails-class.html) contains the following properties: - -* [`MapPanDetails.previousVisibleBounds`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapPanDetails/previousVisibleBounds.html) - Provides the visible bounds before the current panning operation completes i.e. current visible bounds. -* [`MapPanDetails.newVisibleBounds`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapPanDetails/newVisibleBounds.html) - Provides the new visible bounds when the current pan completes. Hence, if the `super.onPanning(details)` is not called, there will be no changes in the UI. -* [`MapPanDetails.zoomLevel`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapPanDetails/zoomLevel.html) - Provides the current zoom level. -* [`MapPanDetails.delta`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapPanDetails/delta.html) - The difference in pixels between touch start and current touch position. -* [`MapPanDetails.globalFocalPoint`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapPanDetails/globalFocalPoint.html) - The global focal point of the pointers in contact with the screen. -* [`MapPanDetails.localFocalPoint`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapPanDetails/localFocalPoint.html) - The local focal point of the pointers in contact with the screen. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late MapZoomPanBehavior _zoomPanBehavior; - - @override - void initState() { - super.initState(); - _zoomPanBehavior = _CustomZoomPanBehavior(); - } - - @override - Widget build(BuildContext context) { - return FutureBuilder( - future: getBingUrlTemplate( - 'https://dev.virtualearth.net/REST/V1/Imagery/Metadata/AerialWithLabels?output=json&uriScheme=https&include=ImageryProviders&key=YOUR_KEY'), - builder: (context, snapshot) { - if (snapshot.hasData) { - return SfMaps( - layers: [ - MapTileLayer( - urlTemplate: snapshot.data as String, - zoomPanBehavior: _zoomPanBehavior, - ), - ], - ); - } - return CircularProgressIndicator(); - } - ); - } -} - -class _CustomZoomPanBehavior extends MapZoomPanBehavior { - - @override - void onPanning(MapPanDetails details) { - super.onPanning(details); - // Add the code here - } -} - -{% endhighlight %} -{% endtabs %} - -N> -* When `super.onPanning(details)` is not called, panning will not happen. - -### Reset - -You can [`reset`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/reset.html) the map to the [`MapZoomPanBehavior.minZoomLevel`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/minZoomLevel.html) by calling this method. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late MapZoomPanBehavior _zoomPanBehavior; - - @override - void initState() { - super.initState(); - _zoomPanBehavior = MapZoomPanBehavior(); - } - - @override - Widget build(BuildContext context) { - return Column( - children: [ - FutureBuilder( - future: getBingUrlTemplate( - 'https://dev.virtualearth.net/REST/V1/Imagery/Metadata/AerialWithLabels?output=json&uriScheme=https&include=ImageryProviders&key=YOUR_KEY'), - builder: (context, snapshot) { - if (snapshot.hasData) { - return SfMaps( - layers: [ - MapTileLayer( - urlTemplate: snapshot.data as String, - zoomPanBehavior: _zoomPanBehavior, - ), - ], - ); - } - return CircularProgressIndicator(); - }, - ), - ElevatedButton( - onPressed: () { - _zoomPanBehavior.reset(); - }, - child: Text('Reset Zoom Level'), - ), - ], - ); - } -} - -{% endhighlight %} -{% endtabs %} - -### HandleEvent - -You can override this method to handle pointer events that hit this render object. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late MapZoomPanBehavior _zoomPanBehavior; - - @override - void initState() { - super.initState(); - _zoomPanBehavior = _CustomZoomPanBehavior(); - } - - @override - Widget build(BuildContext context) { - return FutureBuilder( - future: getBingUrlTemplate( - 'https://dev.virtualearth.net/REST/V1/Imagery/Metadata/AerialWithLabels?output=json&uriScheme=https&include=ImageryProviders&key=YOUR_KEY'), - builder: (context, snapshot) { - if (snapshot.hasData) { - return SfMaps( - layers: [ - MapTileLayer( - urlTemplate: snapshot.data as String, - zoomPanBehavior: _zoomPanBehavior, - ), - ], - ); - } - return CircularProgressIndicator(); - } - ); - } -} - -class _CustomZoomPanBehavior extends MapZoomPanBehavior { - - @override - void handleEvent(PointerEvent event, HitTestEntry entry) { - super.handleEvent(event, entry); - // Add the code here - } -} - -{% endhighlight %} -{% endtabs %} - -### Paint - -You can paint this render object into the given context at the given offset. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_maps/maps.dart'; - -class MapsExample extends StatefulWidget { - @override - _MapsExampleState createState() => _MapsExampleState(); -} - -class _MapsExampleState extends State { - late MapZoomPanBehavior _zoomPanBehavior; - - @override - void initState() { - super.initState(); - _zoomPanBehavior = _CustomZoomPanBehavior(); - } - - @override - Widget build(BuildContext context) { - return FutureBuilder( - future: getBingUrlTemplate( - 'https://dev.virtualearth.net/REST/V1/Imagery/Metadata/AerialWithLabels?output=json&uriScheme=https&include=ImageryProviders&key=YOUR_KEY'), - builder: (context, snapshot) { - if (snapshot.hasData) { - return SfMaps( - layers: [ - MapTileLayer( - urlTemplate: snapshot.data as String, - zoomPanBehavior: _zoomPanBehavior, - ), - ], - ); - } - return CircularProgressIndicator(); - } - ); - } -} - -class _CustomZoomPanBehavior extends MapZoomPanBehavior { - - @override - void paint(PaintingContext context, Offset offset) { - super.paint(context, offset); - // Add the code here - } - -} - -{% endhighlight %} -{% endtabs %} - -N> You can refer to our [Flutter Maps](https://www.syncfusion.com/flutter-widgets/flutter-maps) feature tour page for its groundbreaking feature representations. You can also explore our [Flutter Maps Zoom & Pan example](https://flutter.syncfusion.com/#/maps/shape-layer/zooming) that shows how to configure a Maps in Flutter. +--- +layout: post +title: Zooming and Panning in Flutter Maps | Syncfusion® +description: Learn about zooming and panning in Syncfusion® Flutter Maps (SfMaps), including zoom levels, focal points, toolbar support, and interaction settings. +platform: flutter +control: SfMaps +documentation: ug +--- + +# Zooming and Panning in Flutter Maps (SfMaps) + +It is possible to zoom in and out for any layer to take a closer look at a specific region by pinching the map, scrolling the mouse wheel or track-pad, or using the toolbar on the web. You can also pan the Flutter Maps to navigate across regions and customize the zoom level and center point of the initial rendering. + +The procedure for zooming and panning is very similar for both layers. + +**Shape layer** + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late MapZoomPanBehavior _zoomPanBehavior; + late MapShapeSource _dataSource; + + @override + void initState() { + super.initState(); + _dataSource = MapShapeSource.asset( + 'assets/world_map.json', + shapeDataField: 'continent', + ); + _zoomPanBehavior = MapZoomPanBehavior(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SfMaps( + layers: [ + MapShapeLayer( + source: _dataSource, + zoomPanBehavior: _zoomPanBehavior, + ), + ], + ), + ); + } +} + +{% endhighlight %} +{% endtabs %} + +**Tile layer** + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late MapZoomPanBehavior _zoomPanBehavior; + + @override + void initState() { + super.initState(); + _zoomPanBehavior = MapZoomPanBehavior(); + } + + @override + Widget build(BuildContext context) { + return FutureBuilder( + future: getBingUrlTemplate( + 'https://dev.virtualearth.net/REST/V1/Imagery/Metadata/AerialWithLabels?output=json&uriScheme=https&include=ImageryProviders&key=YOUR_KEY'), + builder: (context, snapshot) { + if (snapshot.hasData) { + return SfMaps( + layers: [ + MapTileLayer( + urlTemplate: snapshot.data as String, + zoomPanBehavior: _zoomPanBehavior, + ), + ], + ); + } + return CircularProgressIndicator(); + } + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Bing maps aerial default](images/zoom-pan/bing_maps_aerial.png) + +## Customizing the center latitude and longitude + +The [`MapZoomPanBehavior.focalLatLng`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/focalLatLng.html) is the focal point of the map layer based on which zooming happens. It represents the focal latitude and longitude position of the map layer. You can also get the current focalLatLng after interaction using the [`MapZoomPanBehavior.focalLatLng`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/focalLatLng.html) property. + +To enable panning, set the instance of [`MapZoomPanBehavior`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior-class.html) to [`MapTileLayer.zoomPanBehavior`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/zoomPanBehavior.html). By default, panning is enabled. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late MapZoomPanBehavior _zoomPanBehavior; + + @override + void initState() { + super.initState(); + _zoomPanBehavior = MapZoomPanBehavior( + focalLatLng: MapLatLng(27.1751, 50.0421), + ); + } + + @override + Widget build(BuildContext context) { + return FutureBuilder( + future: getBingUrlTemplate( + 'https://dev.virtualearth.net/REST/V1/Imagery/Metadata/AerialWithLabels?output=json&uriScheme=https&include=ImageryProviders&key=YOUR_KEY'), + builder: (context, snapshot) { + if (snapshot.hasData) { + return SfMaps( + layers: [ + MapTileLayer( + urlTemplate: snapshot.data as String, + zoomPanBehavior: _zoomPanBehavior, + ), + ], + ); + } + return CircularProgressIndicator(); + } + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Bing maps aerial focalLatLng](images/zoom-pan/bing_maps_focallatlng.png) + +## Update the center latitude and longitude programmatically + +You can change the center latitude and longitude of the shape layer programmatically using the [`MapZoomPanBehavior.focalLatLng`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/focalLatLng.html) property. + +N> This is applicable for both shape layer and tile layer. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late MapZoomPanBehavior _zoomPanBehavior; + late MapShapeSource _dataSource; + + @override + void initState() { + super.initState(); + _dataSource = MapShapeSource.asset( + 'assets/world_map.json', + shapeDataField: 'continent', + ); + + _zoomPanBehavior = MapZoomPanBehavior( + focalLatLng: MapLatLng(27.1751, 78.0421), + zoomLevel: 4, + ); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Column( + children: [ + Container( + height: 600, + child: SfMaps( + layers: [ + MapShapeLayer( + source: _dataSource, + zoomPanBehavior: _zoomPanBehavior, + ), + ], + ), + ), + SizedBox(height: 20), + ElevatedButton( + child: Text('Change focalLatLng'), + onPressed: () { + _zoomPanBehavior.focalLatLng = MapLatLng(56.1304, -106.3468); + }, + ), + ], + ), + ); + } +} + +{% endhighlight %} +{% endtabs %} + +## Customizing the zoom level + +You can set the current zoom level of the map layer by using the [`MapZoomPanBehavior.zoomLevel`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/zoomLevel.html) property. + +The default [`MapZoomPanBehavior.zoomLevel`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/zoomLevel.html) value is 1, which will show the whole map in the viewport for [`MapShapeLayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer-class.html) and the possible bounds for the [`MapShapeLayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapShapeLayer-class.html) based on the [`MapZoomPanBehavior.focalLatLng`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/focalLatLng.html). You can also get the current zoom level after interaction using the [`MapZoomPanBehavior.zoomLevel`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/zoomLevel.html) property. + +To enable zooming, set the instance of [`MapZoomPanBehavior`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior-class.html) to [`MapTileLayer.zoomPanBehavior`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapLayer/zoomPanBehavior.html). By default, zooming is enabled. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late MapZoomPanBehavior _zoomPanBehavior; + + @override + void initState() { + super.initState(); + _zoomPanBehavior = MapZoomPanBehavior( + focalLatLng: MapLatLng(27.1751, 78.0421), + zoomLevel: 5, + ); + } + + @override + Widget build(BuildContext context) { + return FutureBuilder( + future: getBingUrlTemplate( + 'https://dev.virtualearth.net/REST/V1/Imagery/Metadata/AerialWithLabels?output=json&uriScheme=https&include=ImageryProviders&key=YOUR_KEY'), + builder: (context, snapshot) { + if (snapshot.hasData) { + return SfMaps( + layers: [ + MapTileLayer( + urlTemplate: snapshot.data as String, + zoomPanBehavior: _zoomPanBehavior, + ), + ], + ); + } + return CircularProgressIndicator(); + } + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Bing maps aerial zoomlevel](images/zoom-pan/bing_maps_zoomlevel.png) + +## Update the zoom level programmatically + +You can change the zoom level of the shape layer programmatically using the [`MapZoomPanBehavior.zoomLevel`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/zoomLevel.html) property. + +N> This is applicable for both shape layer and tile layer. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late MapZoomPanBehavior _zoomPanBehavior; + late MapShapeSource _dataSource; + + @override + void initState() { + _dataSource = MapShapeSource.asset( + 'assets/world_map.json', + shapeDataField: 'continent', + ); + _zoomPanBehavior = MapZoomPanBehavior( + focalLatLng: MapLatLng(27.1751, 78.0421), + zoomLevel: 2, + ); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Column( + children: [ + Container( + height: 600, + child: SfMaps( + layers: [ + MapShapeLayer( + source: _dataSource, + zoomPanBehavior: _zoomPanBehavior, + ), + ], + ), + ), + SizedBox(height: 20), + ElevatedButton( + child: Text('Change zoomLevel'), + onPressed: () { + _zoomPanBehavior.zoomLevel = 7; + }, + ), + ], + ), + ); + } +} + +{% endhighlight %} +{% endtabs %} + +## Customizing min and max zoom level + +You can set the minimum and maximum zoom level of the map layer by setting values to the [`MapZoomPanBehavior.minZoomLevel`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/minZoomLevel.html) and [`MapZoomPanBehavior.maxZoomLevel`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/maxZoomLevel.html) properties. The minimum and maximum zooming levels can be restricted using these properties respectively. The default values of [`MapZoomPanBehavior.minZoomLevel`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/minZoomLevel.html) and [`MapZoomPanBehavior.maxZoomLevel`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/maxZoomLevel.html) are 1 and 15 respectively. + +However, for [`MapTileLayer`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapTileLayer-class.html), [`MapZoomPanBehavior.maxZoomLevel`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/maxZoomLevel.html) may slightly vary depending on the providers. Please check the respective official website of the map tile providers to know about the maximum zoom level they support. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late MapZoomPanBehavior _zoomPanBehavior; + + @override + void initState() { + super.initState(); + _zoomPanBehavior = MapZoomPanBehavior( + focalLatLng: MapLatLng(27.1751, 78.0421), + zoomLevel: 5, + minZoomLevel: 3, + maxZoomLevel: 10, + ); + } + + @override + Widget build(BuildContext context) { + return FutureBuilder( + future: getBingUrlTemplate( + 'https://dev.virtualearth.net/REST/V1/Imagery/Metadata/AerialWithLabels?output=json&uriScheme=https&include=ImageryProviders&key=YOUR_KEY'), + builder: (context, snapshot) { + if (snapshot.hasData) { + return SfMaps( + layers: [ + MapTileLayer( + urlTemplate: snapshot.data as String, + zoomPanBehavior: _zoomPanBehavior, + ), + ], + ); + } + return CircularProgressIndicator(); + } + ); + } +} + +{% endhighlight %} +{% endtabs %} + +## Double tap zooming + +Double tap zooming can be enabled using the [`enableDoubleTapZooming`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/enableDoubleTapZooming.html) property. The default value of the [`enableDoubleTapZooming`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/enableDoubleTapZooming.html) is `false`. + +N> This is applicable for both tile layer and shape layer. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late MapZoomPanBehavior _zoomPanBehavior; + + @override + void initState() { + _zoomPanBehavior = MapZoomPanBehavior(enableDoubleTapZooming: true); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SfMaps( + layers: [ + MapTileLayer( + urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', + zoomPanBehavior: _zoomPanBehavior, + ), + ], + ), + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Double tap zooming](images/zoom-pan/double_tap_zoom.gif) + +## Toolbar + +The toolbar can be used to perform zoom in, zoom out, and reset operations in the web and desktop platforms. By default, the [`MapZoomPanBehavior.showToolbar`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/showToolbar.html) property is `true`. + +## Toolbar customization + +You can customize the toolbar items using the following properties: + +* **Position** - Used to position the toolbar item at the four corners of the map visual bounds using the [`position`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapToolbarSettings/position.html) property. The default value of the [`position`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapToolbarSettings/position.html) property is `MapToolbarPosition.topRight`. The possible values are [`topRight`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapToolbarPosition.html#topRight), [`topLeft`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapToolbarPosition.html#topLeft), [`bottomLeft`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapToolbarPosition.html#bottomLeft), and [`bottomRight`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapToolbarPosition.html#bottomRight). + +* **Icon color** - Used to set color to the three icons using the [`iconColor`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapToolbarSettings/iconColor.html) property. + +* **Item background color** - Used to set background color of the toolbar icons using the [`itemBackgroundColor`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapToolbarSettings/itemBackgroundColor.html) property. + +* **Item hover color** - Used to set color while hovering over the icon using the [`itemHoverColor`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapToolbarSettings/itemHoverColor.html) property. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late MapZoomPanBehavior _zoomPanBehavior; + + @override + void initState() { + _zoomPanBehavior = MapZoomPanBehavior( + focalLatLng: MapLatLng(27.1751, 78.0421), + zoomLevel: 3, + showToolbar: true, + toolbarSettings: MapToolbarSettings( + position: MapToolbarPosition.topLeft, + iconColor: Colors.red, + itemBackgroundColor: Colors.green, + itemHoverColor: Colors.blue, + ), + ); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Container( + height: 350, + width: 350, + child: SfMaps( + layers: [ + MapTileLayer( + urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', + zoomPanBehavior: _zoomPanBehavior, + ), + ], + ), + ), + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Toolbar customization](images/zoom-pan/toolbar_customization.gif) + +## Zooming callback + +Whenever zooming happens, this callback is called. If it returns false, zooming will not happen. + +[`MapZoomDetails`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomDetails-class.html) contains the following properties: + +* [`MapZoomDetails.previousVisibleBounds`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomDetails/previousVisibleBounds.html) - Provides the visible bounds before the current zooming operation completes i.e. current visible bounds. +* [`MapZoomDetails.newVisibleBounds`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomDetails/newVisibleBounds.html) - Provides the new visible bounds when the current zoom completes. Hence, if it returns false, there will be no changes in the UI. +* [`MapZoomDetails.previousZoomLevel`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomDetails/previousZoomLevel.html) - Provides the zoom level before the current zooming operation completes i.e. current zoom level. +* [`MapZoomDetails.newZoomLevel`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomDetails/newZoomLevel.html) - Provides the new zoom level when the current zoom completes. Hence, if it returns false, there will be no changes in the UI. +* [`MapZoomDetails.globalFocalPoint`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomDetails/globalFocalPoint.html) - The global focal point of the pointers in contact with the screen. +* [`MapZoomDetails.localFocalPoint`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomDetails/localFocalPoint.html) - The local focal point of the pointers in contact with the screen. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late MapZoomPanBehavior _zoomPanBehavior; + + @override + void initState() { + super.initState(); + _zoomPanBehavior = MapZoomPanBehavior(); + } + + @override + Widget build(BuildContext context) { + return FutureBuilder( + future: getBingUrlTemplate( + 'https://dev.virtualearth.net/REST/V1/Imagery/Metadata/AerialWithLabels?output=json&uriScheme=https&include=ImageryProviders&key=YOUR_KEY'), + builder: (context, snapshot) { + if (snapshot.hasData) { + return SfMaps( + layers: [ + MapTileLayer( + urlTemplate: snapshot.data as String, + zoomPanBehavior: _zoomPanBehavior, + onWillZoom: (MapZoomDetails detail) { + return true; + }, + ), + ], + ); + } + return CircularProgressIndicator(); + } + ); + } +} + +{% endhighlight %} +{% endtabs %} + +## Panning callback + +Whenever panning happens, this callback is called. If it returns false, panning will not happen. + +[`MapPanDetails`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapPanDetails-class.html) contains the following properties: + +* [`MapPanDetails.previousVisibleBounds`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapPanDetails/previousVisibleBounds.html) - Provides the visible bounds before the current panning operation completes i.e. current visible bounds. +* [`MapPanDetails.newVisibleBounds`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapPanDetails/newVisibleBounds.html) - Provides the new visible bounds when the current pan completes. Hence, if it returns false, there will be no changes in the UI. +* [`MapPanDetails.zoomLevel`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapPanDetails/zoomLevel.html) - Provides the current zoom level. +* [`MapPanDetails.delta`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapPanDetails/delta.html) - The difference in pixels between touch start and current touch position. +* [`MapPanDetails.globalFocalPoint`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapPanDetails/globalFocalPoint.html) - The global focal point of the pointers in contact with the screen. +* [`MapPanDetails.localFocalPoint`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapPanDetails/localFocalPoint.html) - The local focal point of the pointers in contact with the screen. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late MapZoomPanBehavior _zoomPanBehavior; + + @override + void initState() { + super.initState(); + _zoomPanBehavior = MapZoomPanBehavior(); + } + + @override + Widget build(BuildContext context) { + return FutureBuilder( + future: getBingUrlTemplate( + 'https://dev.virtualearth.net/REST/V1/Imagery/Metadata/AerialWithLabels?output=json&uriScheme=https&include=ImageryProviders&key=YOUR_KEY'), + builder: (context, snapshot) { + if (snapshot.hasData) { + return SfMaps( + layers: [ + MapTileLayer( + urlTemplate: snapshot.data as String, + zoomPanBehavior: _zoomPanBehavior, + onWillPan: (MapPanDetails detail) { + return true; + }, + ), + ], + ); + } + return CircularProgressIndicator(); + } + ); + } +} + +{% endhighlight %} +{% endtabs %} + +## Overriding the zoom pan behavior + +### Zooming + +Whenever zooming happens, this method is called. Subclasses can override this method to do any custom operations based on the details provided in the [`MapZoomDetails`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomDetails-class.html). + +[`MapZoomDetails`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomDetails-class.html) contains the following properties: + +* [`MapZoomDetails.previousVisibleBounds`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomDetails/previousVisibleBounds.html) - Provides the visible bounds before the current zooming operation completes i.e. current visible bounds. +* [`MapZoomDetails.newVisibleBounds`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomDetails/newVisibleBounds.html) - Provides the new visible bounds when the current zoom completes. Hence, if the `super.onZooming(details)` is not called, there will be no changes in the UI. +* [`MapZoomDetails.previousZoomLevel`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomDetails/previousZoomLevel.html) - Provides the zoom level before the current zooming operation completes i.e. current zoom level. +* [`MapZoomDetails.newZoomLevel`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomDetails/newZoomLevel.html) - Provides the new zoom level when the current zoom completes. Hence, if the `super.onZooming(details)` is not called, there will be no changes in the UI. +* [`MapZoomDetails.globalFocalPoint`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomDetails/globalFocalPoint.html) - The global focal point of the pointers in contact with the screen. +* [`MapZoomDetails.localFocalPoint`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomDetails/localFocalPoint.html) - The local focal point of the pointers in contact with the screen. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late MapZoomPanBehavior _zoomPanBehavior; + + @override + void initState() { + super.initState(); + _zoomPanBehavior = _CustomZoomPanBehavior(); + } + + @override + Widget build(BuildContext context) { + return FutureBuilder( + future: getBingUrlTemplate( + 'https://dev.virtualearth.net/REST/V1/Imagery/Metadata/AerialWithLabels?output=json&uriScheme=https&include=ImageryProviders&key=YOUR_KEY'), + builder: (context, snapshot) { + if (snapshot.hasData) { + return SfMaps( + layers: [ + MapTileLayer( + urlTemplate: snapshot.data as String, + zoomPanBehavior: _zoomPanBehavior, + ), + ], + ); + } + return CircularProgressIndicator(); + } + ); + } +} + +class _CustomZoomPanBehavior extends MapZoomPanBehavior { + + @override + void onZooming(MapZoomDetails details) { + super.onZooming(details); + // Add the code here. + } +} + +{% endhighlight %} +{% endtabs %} + +N> +* When `super.onZooming(details)` is not called, zooming will not happen. + +### Panning + +Whenever panning happens, this method is called. Subclasses can override this method to do any custom operations based on the details provided in the [`MapPanDetails`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapPanDetails-class.html). + +[`MapPanDetails`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapPanDetails-class.html) contains the following properties: + +* [`MapPanDetails.previousVisibleBounds`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapPanDetails/previousVisibleBounds.html) - Provides the visible bounds before the current panning operation completes i.e. current visible bounds. +* [`MapPanDetails.newVisibleBounds`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapPanDetails/newVisibleBounds.html) - Provides the new visible bounds when the current pan completes. Hence, if the `super.onPanning(details)` is not called, there will be no changes in the UI. +* [`MapPanDetails.zoomLevel`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapPanDetails/zoomLevel.html) - Provides the current zoom level. +* [`MapPanDetails.delta`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapPanDetails/delta.html) - The difference in pixels between touch start and current touch position. +* [`MapPanDetails.globalFocalPoint`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapPanDetails/globalFocalPoint.html) - The global focal point of the pointers in contact with the screen. +* [`MapPanDetails.localFocalPoint`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapPanDetails/localFocalPoint.html) - The local focal point of the pointers in contact with the screen. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late MapZoomPanBehavior _zoomPanBehavior; + + @override + void initState() { + super.initState(); + _zoomPanBehavior = _CustomZoomPanBehavior(); + } + + @override + Widget build(BuildContext context) { + return FutureBuilder( + future: getBingUrlTemplate( + 'https://dev.virtualearth.net/REST/V1/Imagery/Metadata/AerialWithLabels?output=json&uriScheme=https&include=ImageryProviders&key=YOUR_KEY'), + builder: (context, snapshot) { + if (snapshot.hasData) { + return SfMaps( + layers: [ + MapTileLayer( + urlTemplate: snapshot.data as String, + zoomPanBehavior: _zoomPanBehavior, + ), + ], + ); + } + return CircularProgressIndicator(); + } + ); + } +} + +class _CustomZoomPanBehavior extends MapZoomPanBehavior { + + @override + void onPanning(MapPanDetails details) { + super.onPanning(details); + // Add the code here + } +} + +{% endhighlight %} +{% endtabs %} + +N> +* When `super.onPanning(details)` is not called, panning will not happen. + +### Reset + +You can [`reset`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/reset.html) the Flutter Maps to the [`MapZoomPanBehavior.minZoomLevel`](https://pub.dev/documentation/syncfusion_flutter_maps/latest/maps/MapZoomPanBehavior/minZoomLevel.html) by calling this method. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late MapZoomPanBehavior _zoomPanBehavior; + + @override + void initState() { + super.initState(); + _zoomPanBehavior = MapZoomPanBehavior(); + } + + @override + Widget build(BuildContext context) { + return Column( + children: [ + FutureBuilder( + future: getBingUrlTemplate( + 'https://dev.virtualearth.net/REST/V1/Imagery/Metadata/AerialWithLabels?output=json&uriScheme=https&include=ImageryProviders&key=YOUR_KEY'), + builder: (context, snapshot) { + if (snapshot.hasData) { + return SfMaps( + layers: [ + MapTileLayer( + urlTemplate: snapshot.data as String, + zoomPanBehavior: _zoomPanBehavior, + ), + ], + ); + } + return CircularProgressIndicator(); + }, + ), + ElevatedButton( + onPressed: () { + _zoomPanBehavior.reset(); + }, + child: Text('Reset Zoom Level'), + ), + ], + ); + } +} + +{% endhighlight %} +{% endtabs %} + +### HandleEvent + +You can override this method to handle pointer events that hit this render object. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late MapZoomPanBehavior _zoomPanBehavior; + + @override + void initState() { + super.initState(); + _zoomPanBehavior = _CustomZoomPanBehavior(); + } + + @override + Widget build(BuildContext context) { + return FutureBuilder( + future: getBingUrlTemplate( + 'https://dev.virtualearth.net/REST/V1/Imagery/Metadata/AerialWithLabels?output=json&uriScheme=https&include=ImageryProviders&key=YOUR_KEY'), + builder: (context, snapshot) { + if (snapshot.hasData) { + return SfMaps( + layers: [ + MapTileLayer( + urlTemplate: snapshot.data as String, + zoomPanBehavior: _zoomPanBehavior, + ), + ], + ); + } + return CircularProgressIndicator(); + } + ); + } +} + +class _CustomZoomPanBehavior extends MapZoomPanBehavior { + + @override + void handleEvent(PointerEvent event, HitTestEntry entry) { + super.handleEvent(event, entry); + // Add the code here + } +} + +{% endhighlight %} +{% endtabs %} + +### Paint + +You can paint this render object into the given context at the given offset. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_maps/maps.dart'; + +class MapsExample extends StatefulWidget { + @override + _MapsExampleState createState() => _MapsExampleState(); +} + +class _MapsExampleState extends State { + late MapZoomPanBehavior _zoomPanBehavior; + + @override + void initState() { + super.initState(); + _zoomPanBehavior = _CustomZoomPanBehavior(); + } + + @override + Widget build(BuildContext context) { + return FutureBuilder( + future: getBingUrlTemplate( + 'https://dev.virtualearth.net/REST/V1/Imagery/Metadata/AerialWithLabels?output=json&uriScheme=https&include=ImageryProviders&key=YOUR_KEY'), + builder: (context, snapshot) { + if (snapshot.hasData) { + return SfMaps( + layers: [ + MapTileLayer( + urlTemplate: snapshot.data as String, + zoomPanBehavior: _zoomPanBehavior, + ), + ], + ); + } + return CircularProgressIndicator(); + } + ); + } +} + +class _CustomZoomPanBehavior extends MapZoomPanBehavior { + + @override + void paint(PaintingContext context, Offset offset) { + super.paint(context, offset); + // Add the code here + } + +} + +{% endhighlight %} +{% endtabs %} + +N> You can refer to our [Flutter Maps](https://www.syncfusion.com/flutter-widgets/flutter-maps) feature tour page for its groundbreaking feature representations. You can also explore our [Flutter Maps Zoom & Pan example](https://flutter.syncfusion.com/#/maps/shape-layer/zooming) that shows how to configure a Maps in Flutter. diff --git a/Flutter/radial-gauge/animation.md b/Flutter/radial-gauge/animation.md index e9a685c23..3d6f180ca 100644 --- a/Flutter/radial-gauge/animation.md +++ b/Flutter/radial-gauge/animation.md @@ -11,7 +11,7 @@ documentation: ug ## Initial animation -The radial gauge allows all of its elements to be animated with [`enableLoadingAnimation`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/SfRadialGauge/enableLoadingAnimation.html) property. The default value for this property is false. The duration of the animation can be controlled by the [`animationDuration`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/SfRadialGauge/animationDuration.html) property of the gauge. +The Flutter Radial Gauge allows all of its elements to be animated with [`enableLoadingAnimation`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/SfRadialGauge/enableLoadingAnimation.html) property. The default value for this property is false. The duration of the animation can be controlled by the [`animationDuration`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/SfRadialGauge/animationDuration.html) property. {% tabs %} {% highlight dart %} diff --git a/Flutter/radial-gauge/annotation.md b/Flutter/radial-gauge/annotation.md index 7b64f61b2..d5c938408 100644 --- a/Flutter/radial-gauge/annotation.md +++ b/Flutter/radial-gauge/annotation.md @@ -9,7 +9,7 @@ documentation: ug # Annotation in Flutter Radial Gauge (SfRadialGauge) -[`Radial axis`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/RadialAxis-class.html) allows you to add multiple widgets such as text and image as annotations to specific points of interest in the radial gauge. +[`Radial axis`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/RadialAxis-class.html) allows you to add multiple widgets such as text and image as annotations to specific points of interest in the Flutter Radial Gauge. The following properties are available in [`annotation`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/GaugeAnnotation-class.html) to customize the position and alignment of [`annotation widget-based`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/GaugeAnnotation/widget.html) @@ -199,7 +199,7 @@ By default, the value of [`positionFactor`](https://pub.dev/documentation/syncfu ## Setting image for annotation -Annotations provide options to add any image over the gauge control with respect to its offset position. You can add multiple images in a single control. +Annotations provide options to add any image over the Flutter Radial Gauge with respect to its offset position. You can add multiple images in a single control. {% tabs %} {% highlight dart %} diff --git a/Flutter/radial-gauge/axes.md b/Flutter/radial-gauge/axes.md index 3ee21d492..fd708a0c4 100644 --- a/Flutter/radial-gauge/axes.md +++ b/Flutter/radial-gauge/axes.md @@ -609,7 +609,7 @@ class RadialGaugeDemo extends StatelessWidget { **Background color support** -[`Radial gauge`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/SfRadialGauge-class.html) allows customizing its background color using [`backgroundColor`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/SfRadialGauge/backgroundColor.html) property. +[`Radial Gauge`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/SfRadialGauge-class.html) allows customizing its background color using [`backgroundColor`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/SfRadialGauge/backgroundColor.html) property. {% tabs %} {% highlight dart %} @@ -1413,7 +1413,7 @@ class RadialGaugeDemo extends StatelessWidget { ## Custom scale -[`Radial gauge`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/SfRadialGauge-class.html) allows you to display a set of values along with a custom scale based on your business logic using the [`onCreateAxisRenderer`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/RadialAxis/onCreateAxisRenderer.html) event of the axis. The [`onCreateAxisRenderer`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/RadialAxis/onCreateAxisRenderer.html) event allows returning the custom renderer for the axis. In that, we can override methods of `RadialAxisRenderer` to create the custom axis. +[`Radial Gauge`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/SfRadialGauge-class.html) allows you to display a set of values along with a custom scale based on your business logic using the [`onCreateAxisRenderer`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/RadialAxis/onCreateAxisRenderer.html) event of the axis. The [`onCreateAxisRenderer`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/RadialAxis/onCreateAxisRenderer.html) event allows returning the custom renderer for the axis. In that, we can override methods of `RadialAxisRenderer` to create the custom axis. {% tabs %} {% highlight dart %} diff --git a/Flutter/radial-gauge/getting-started.md b/Flutter/radial-gauge/getting-started.md index 5b82588f6..068eb8fa3 100644 --- a/Flutter/radial-gauge/getting-started.md +++ b/Flutter/radial-gauge/getting-started.md @@ -9,9 +9,9 @@ documentation: ug # Getting Started with Flutter Radial Gauge (SfRadialGauge) -This section explains the steps required to add the Flutter [Radial Gauge](https://www.syncfusion.com/flutter-widgets/flutter-radial-gauge) and its elements such as title, axis, range, pointer and annotation. This section covers only the basic features needed to get started with Syncfusion® radial gauge. +This section explains the steps required to add the Flutter [Radial Gauge](https://www.syncfusion.com/flutter-widgets/flutter-radial-gauge) and its elements such as title, axis, range, pointer and annotation. This section covers only the basic features needed to get started with Syncfusion® Flutter Radial Gauge. -To get started quickly with our Flutter radial gauge widget, you can check out this video: +To get started quickly with our Flutter Radial Gauge widget, you can check out this video: @@ -112,11 +112,11 @@ After the package has been imported, initialize the [SfRadialGauge](https://www. {% endhighlight %} {% endtabs %} -![Initialize radial gauge](images/getting-started/default_gauge.png) +![Initialize Flutter Radial Gauge](images/getting-started/default_gauge.png) ## Add title -You can add a title to the radial gauge to provide information to users about the designed gauge. The title can be set to the gauge as demonstrated in the following code snippet: +You can add a title to the Flutter Radial Gauge to provide information to users about the designed gauge. The title can be set to the gauge as demonstrated in the following code snippet: {% tabs %} {% highlight dart %} @@ -149,7 +149,7 @@ You can add a title to the radial gauge to provide information to users about th {% endhighlight %} {% endtabs %} -![title to radial gauge](images/getting-started/gauge_title.png) +![title to Flutter Radial Gauge](images/getting-started/gauge_title.png) ## Add axis @@ -187,7 +187,7 @@ Axes contain a list of axis elements, where you can add any number of radial axe {% endhighlight %} {% endtabs %} -![Axis to radial gauge](images/getting-started/gauge_axis.png) +![Axis to Flutter Radial Gauge](images/getting-started/gauge_axis.png) ## Add range @@ -230,7 +230,7 @@ Ranges contain a list of range elements, where you can add any number of ranges {% endhighlight %} {% endtabs %} -![range support to radial gauge](images/getting-started/gauge_range.png) +![range support to Flutter Radial Gauge](images/getting-started/gauge_range.png) ## Add pointer @@ -270,7 +270,7 @@ Pointers contains a list of pointer elements, where you can add any number of ga {% endhighlight %} {% endtabs %} -![gauge pointers to radial gauge](images/getting-started/gauge_pointer.png) +![gauge pointers to Flutter Radial Gauge](images/getting-started/gauge_pointer.png) ## Add annotation @@ -313,7 +313,7 @@ You can add any number of widgets such as text or image as an annotation inside {% endhighlight %} {% endtabs %} -![annotation support to the radial gauge](images/getting-started/gauge_annotation.png) +![annotation support to the Flutter Radial Gauge](images/getting-started/gauge_annotation.png) The following code example gives you the complete code of above configurations. diff --git a/Flutter/radial-gauge/marker-pointer.md b/Flutter/radial-gauge/marker-pointer.md index f9f185e94..1ad6f4edc 100644 --- a/Flutter/radial-gauge/marker-pointer.md +++ b/Flutter/radial-gauge/marker-pointer.md @@ -9,9 +9,9 @@ documentation: ug # Marker Pointer in Flutter Radial Gauge (SfRadialGauge) -A [`MarkerPointer`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/MarkerPointer-class.html) is used to indicate a specific value on the radial gauge axis. It supports seven built-in marker shapes and additional customization options such as image, text, color, size, border, elevation, overlay, and position offset. The marker type can be changed using the [`markerType`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/MarkerPointer/markerType.html) property. The default marker type is [`MarkerType.invertedTriangle`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/MarkerType.html). +A [`MarkerPointer`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/MarkerPointer-class.html) is used to indicate a specific value on the axis of the Flutter Radial Gauge. It supports seven built-in marker shapes and additional customization options such as image, text, color, size, border, elevation, overlay, and position offset. The marker type can be changed using the [`markerType`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/MarkerPointer/markerType.html) property. The default marker type is [`MarkerType.invertedTriangle`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/MarkerType.html). -The following example demonstrates adding a default marker pointer to the radial gauge. +The following example demonstrates adding a default marker pointer to the Radial Gauge. {% highlight dart %} @@ -60,7 +60,7 @@ class MarkerPointerExample extends StatelessWidget { ## Marker types -The radial gauge supports the following built-in marker types that can be set using the [`markerType`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/MarkerPointer/markerType.html) property of [`MarkerPointer`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/MarkerPointer-class.html): +The Flutter Radial Gauge supports the following built-in marker types that can be set using the [`markerType`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/MarkerPointer/markerType.html) property of [`MarkerPointer`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/MarkerPointer-class.html): * [`MarkerType.circle`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/MarkerType.html) - Renders the pointer as a circle. * [`MarkerType.diamond`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/MarkerType.html) - Renders the pointer as a diamond. @@ -292,7 +292,7 @@ class RectangleMarkerExample extends StatelessWidget { ### Triangle -The [`MarkerType.triangle`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/MarkerType.html) renders the marker pointer as an upward-pointing triangle. It is commonly used as a directional indicator on the gauge. +The [`MarkerType.triangle`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/MarkerType.html) renders the marker pointer as an upward-pointing triangle. It is commonly used as a directional indicator on the Flutter Radial Gauge. {% highlight dart %} diff --git a/Flutter/radial-gauge/needle-pointer.md b/Flutter/radial-gauge/needle-pointer.md index 6d5c09db2..305900d72 100644 --- a/Flutter/radial-gauge/needle-pointer.md +++ b/Flutter/radial-gauge/needle-pointer.md @@ -9,7 +9,7 @@ documentation: ug # Needle Pointer in Flutter Radial Gauge (SfRadialGauge) -[`Needle Pointer`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/NeedlePointer-class.html) contains three parts namely needle, [`knob`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/NeedlePointer/knobStyle.html), and [`tail`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/NeedlePointer/tailStyle.html) and that can be placed on a gauge to mark values. +[`Needle Pointer`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/NeedlePointer-class.html) contains three parts namely needle, [`knob`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/NeedlePointer/knobStyle.html), and [`tail`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/NeedlePointer/tailStyle.html) and that can be placed on a Flutter Radial Gauge to mark values. {% highlight dart %} diff --git a/Flutter/radial-gauge/overview.md b/Flutter/radial-gauge/overview.md index f554752a3..e4bcfb2d8 100644 --- a/Flutter/radial-gauge/overview.md +++ b/Flutter/radial-gauge/overview.md @@ -11,16 +11,16 @@ documentation: ug Syncfusion® Flutter Radial Gauge is a powerful data visualization widget in Dart. It enables you to create modern, interactive, and animated gauges that enhance the user interface of high-quality mobile applications built with Flutter. -![Overview flutter radial gauge](images/overview/gauge_overview.png) +![Overview Flutter Radial Gauge](images/overview/gauge_overview.png) ## Key Features -* **Title** - Add a descriptive title to the radial gauge to provide context about the data being visualized. The title can be aligned to the near, center, or far position and its text style can be customized. See the [title](radial-gauge-title.md) documentation to learn more. -* **Axes** - The radial gauge axis is a circular arc that displays a set of values along a linear or custom scale based on your design requirements. Axis elements such as labels, ticks, and axis lines can be easily customized with built-in properties to match your application's theme. See the [axes](axes.md) documentation to learn more. -* **Ranges** - Gauge ranges are visual elements that help users quickly visualize where a value falls on the axis. Text can be easily annotated within ranges to improve readability and provide additional context to your data visualization. See the [ranges](ranges.md) documentation to learn more. -* **Pointers** - Pointer is used to indicate values on an axis. The radial gauge has four types of pointers: needle pointer, marker pointer, range pointer, and widget pointer. All the pointers can be customized as needed. See the [pointers](pointers.md) documentation to learn more. -* **Animation** - The Radial Gauge provides visually appealing animations when pointers move from one value to another. Various animation types and customization options are available to create engaging user experiences. See the [animation](animation.md) documentation to learn more. +* **Title** - Add a descriptive title to the Flutter Radial Gauge to provide context about the data being visualized. The title can be aligned to the near, center, or far position and its text style can be customized. See the [title](radial-gauge-title.md) documentation to learn more. +* **Axes** - The Flutter Radial Gauge axis is a circular arc that displays a set of values along a linear or custom scale based on your design requirements. Axis elements such as labels, ticks, and axis lines can be easily customized with built-in properties to match your application's theme. See the [axes](axes.md) documentation to learn more. +* **Ranges** - Flutter Radial Gauge ranges are visual elements that help users quickly visualize where a value falls on the axis. Text can be easily annotated within ranges to improve readability and provide additional context to your data visualization. See the [ranges](ranges.md) documentation to learn more. +* **Pointers** - Pointer is used to indicate values on an axis. The Flutter Radial Gauge has four types of pointers: needle pointer, marker pointer, range pointer, and widget pointer. All the pointers can be customized as needed. See the [pointers](pointers.md) documentation to learn more. +* **Animation** - The Flutter Radial Gauge provides visually appealing animations when pointers move from one value to another. Various animation types and customization options are available to create engaging user experiences. See the [animation](animation.md) documentation to learn more. * **Annotations** - Add multiple widgets such as text, images, or custom Flutter widgets as annotations at specific points of interest in the radial gauge to provide additional context or information. See the [annotations](annotation.md) documentation to learn more. -* **Accessibility** - The radial gauge is built with accessibility support, allowing it to be navigated and read by screen readers such as TalkBack and VoiceOver. The widget exposes semantic information to assistive technologies so users with visual impairments can understand the gauge data. See the [accessibility](accessibility.md) documentation to learn more. +* **Accessibility** - The Flutter Radial Gauge is built with accessibility support, allowing it to be navigated and read by screen readers such as TalkBack and VoiceOver. The widget exposes semantic information to assistive technologies so users with visual impairments can understand the gauge data. See the [accessibility](accessibility.md) documentation to learn more. You can get the sample in the following link: [`Flutter Gauges`](https://github.com/syncfusion/flutter-examples/tree/master/lib/samples/gauge). \ No newline at end of file diff --git a/Flutter/radial-gauge/pointers.md b/Flutter/radial-gauge/pointers.md index 27089d910..9fc7677c4 100644 --- a/Flutter/radial-gauge/pointers.md +++ b/Flutter/radial-gauge/pointers.md @@ -9,14 +9,14 @@ documentation: ug # Pointers in Flutter Radial Gauge (SfRadialGauge) - Pointer is used to indicate values on an axis. The Syncfusion Flutter Radial Gauge control offers four types of pointers: +Pointer is used to indicate values on an axis. The Syncfusion® Flutter Radial Gauge control offers four types of pointers: [`Marker pointer`](https://help.syncfusion.com/flutter/radial-gauge/marker-pointer) [`Needle pointer`](https://help.syncfusion.com/flutter/radial-gauge/needle-pointer) [`Range pointer`](https://help.syncfusion.com/flutter/radial-gauge/range-pointer) [`Widget pointer`](https://help.syncfusion.com/flutter/radial-gauge/widget-pointer) -All pointers can be customized to meet your specific requirement. You can add multiple pointers to the gauge to indicate multiple values on the same scale. The value of the pointer is set using the [`value`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/GaugePointer/value.html) property. +All pointers can be customized to meet your specific requirement. You can add multiple pointers to the Flutter Radial Gauge to indicate multiple values on the same scale. The value of the pointer is set using the [`value`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/GaugePointer/value.html) property. ![multiple pointers](images/pointers/pointers.png) @@ -213,7 +213,7 @@ class _EventExampleState extends State { {% endhighlight %} {% endtabs %} -The [`onCreatePointerRenderer`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/MarkerPointer/onCreatePointerRenderer.html) callback allows you to create a custom pointer in the radial gauge. This callback is available for both the [`NeedlePointer`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/NeedlePointer-class.html) or [`MarkerPointer`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/MarkerPointer-class.html) types. +The [`onCreatePointerRenderer`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/MarkerPointer/onCreatePointerRenderer.html) callback allows you to create a custom pointer in the Flutter Radial Gauge. This callback is available for both the [`NeedlePointer`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/NeedlePointer-class.html) or [`MarkerPointer`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/MarkerPointer-class.html) types. {% tabs %} {% highlight dart %} diff --git a/Flutter/radial-gauge/radial-gauge-title.md b/Flutter/radial-gauge/radial-gauge-title.md index 46030ac35..041bc6dcf 100644 --- a/Flutter/radial-gauge/radial-gauge-title.md +++ b/Flutter/radial-gauge/radial-gauge-title.md @@ -23,7 +23,7 @@ The following properties are used to customize the appearance of title, ## Text alignment -You can align the title text content horizontally to the near (left), center, or far (right) position relative to the gauge using the [`alignment`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/GaugeTitle/alignment.html) property of [`title`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/GaugeTitle-class.html). The default alignment is `GaugeAlignment.center`. +You can align the title text content horizontally to the near (left), center, or far (right) position relative to the Flutter Radial Gauge using the [`alignment`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/GaugeTitle/alignment.html) property of [`title`](https://pub.dev/documentation/syncfusion_flutter_gauges/latest/gauges/GaugeTitle-class.html). The default alignment is `GaugeAlignment.center`. {% tabs %} {% highlight dart %} @@ -84,4 +84,4 @@ class MyHomePage extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Gauge title](images/title/gauge_title.jpg) \ No newline at end of file +![Flutter Radial Gauge title](images/title/gauge_title.jpg) \ No newline at end of file diff --git a/Flutter/radial-gauge/range-pointer.md b/Flutter/radial-gauge/range-pointer.md index baaa89175..8d6c317ca 100644 --- a/Flutter/radial-gauge/range-pointer.md +++ b/Flutter/radial-gauge/range-pointer.md @@ -9,7 +9,7 @@ documentation: ug # Range Pointer in Flutter Radial Gauge (SfRadialGauge) -A range pointer is an accenting line or shaded background range that can be placed on a gauge to mark the current value. The default width is 10 logical pixels, with a default color of RGB(0, 168, 231). +A range pointer is an accenting line or shaded background range that can be placed on a Flutter Radial Gauge to mark the current value. The default width is 10 logical pixels, with a default color of RGB(0, 168, 231). {% tabs %} {% highlight dart %} diff --git a/Flutter/range-selector/basic-features.md b/Flutter/range-selector/basic-features.md index 89abdc71b..8f0855791 100644 --- a/Flutter/range-selector/basic-features.md +++ b/Flutter/range-selector/basic-features.md @@ -20,13 +20,13 @@ The maximum value that the user can select. The default value of [`max`](https:/ ## Initial values -It represents the initial values in the range selector. The range selector's thumbs are drawn corresponding to this value. +It represents the initial values in the Flutter Range Selector. The thumbs of the Range Selector are drawn corresponding to this value. -N> For date values, the range selector does not have auto interval support. So, it is mandatory to set [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/interval.html), [`dateIntervalType`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/dateIntervalType.html), and [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/dateFormat.html) for date values. +N> For date values, the Flutter Range Selector does not have auto interval support. So, it is mandatory to set [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/interval.html), [`dateIntervalType`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/dateIntervalType.html), and [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/dateFormat.html) for date values. -**Numeric range selector** +**Numeric Range Selector** -You can show numeric values in the range selector by setting `double` values to the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/min.html), [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/max.html) and [`initialValues`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/initialValues.html) properties. +You can show numeric values in the Flutter Range Selector by setting `double` values to the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/min.html), [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/max.html) and [`initialValues`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/initialValues.html) properties. {% tabs %} {% highlight Dart %} @@ -100,11 +100,11 @@ class NumericRangeSelectorSample extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Numeric range selector](images/basic-features/selector_numeric_label.png) +![Numeric Range Selector](images/basic-features/selector_numeric_label.png) -**Date range selector** +**Date Range Selector** -You can show date values in the range selector by setting `DateTime` values to the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/min.html), [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/max.html) and [`initialValues`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/initialValues.html) properties. +You can show date values in the Flutter Range Selector by setting `DateTime` values to the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/min.html), [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/max.html) and [`initialValues`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/initialValues.html) properties. N> You must import [`intl`](https://pub.dev/packages/intl) package for formatting date range selector using the [`DateFormat`](https://pub.dev/documentation/intl/latest/intl/DateFormat-class.html) class. @@ -184,13 +184,13 @@ class DateRangeSelectorSample extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Date range selector](images/basic-features/selector_date_label.png) +![Date Range Selector](images/basic-features/selector_date_label.png) ## Handle onChangeStart, onChanged, and onChangeEnd callbacks **onChangeStart** -The [`onChangeStart`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/onChangeStart.html) callback is called when the user begins to interact with the range selector using a tap or drag action. This callback is only used to notify the user that the interaction has started and it does not change the value of the range selector thumb. +The [`onChangeStart`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/onChangeStart.html) callback is called when the user begins to interact with the Flutter Range Selector using a tap or drag action. This callback is only used to notify the user that the interaction has started and it does not change the value of the Range Selector thumb. {% tabs %} {% highlight Dart %} @@ -230,7 +230,7 @@ class _OnChangeStartSampleState extends State { **onChangeEnd** -The [`onChangeEnd`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/onChangeEnd.html) callback is called when the user stops interacting with the range selector using a tap or drag action. This callback is only used to notify the user that the interaction has ended and it does not change the value of the range selector thumb. +The [`onChangeEnd`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/onChangeEnd.html) callback is called when the user stops interacting with the Flutter Range Selector using a tap or drag action. This callback is only used to notify the user that the interaction has ended and it does not change the value of the Range Selector thumb. {% tabs %} {% highlight Dart %} @@ -342,7 +342,7 @@ class _OnChangedSampleState extends State { It represents the color applied to the active track, thumb, overlay, and inactive dividers. -The active side of the range selector is between start and end thumbs. +The active side of the Flutter Range Selector is between start and end thumbs. {% tabs %} {% highlight Dart %} diff --git a/Flutter/range-selector/enabled-and-disabled-state.md b/Flutter/range-selector/enabled-and-disabled-state.md index 3e9167117..2e9ba38bf 100644 --- a/Flutter/range-selector/enabled-and-disabled-state.md +++ b/Flutter/range-selector/enabled-and-disabled-state.md @@ -9,11 +9,11 @@ documentation: ug # Enabled and Disabled States in Flutter Range Selector -This section explains the enabled and disabled states in the Flutter range selector. +This section explains the enabled and disabled states in the Flutter Range Selector. ## Enabled state -By default, the range selector is rendered in the enabled state. You can explicitly control it using the [`enabled`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/enabled.html) property. The default value of the [`enabled`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/enabled.html) property is `true`. +By default, the Flutter Range Selector is rendered in the enabled state. You can explicitly control it using the [`enabled`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/enabled.html) property. The default value of the [`enabled`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/enabled.html) property is `true`. {% tabs %} {% highlight Dart %} @@ -92,7 +92,7 @@ class Data { ## Disabled state -You can render the range selector in a disabled state using the [`enabled`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/enabled.html) property. The default value of the [`enabled`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/enabled.html) property is `true`. +You can render the Flutter Range Selector in a disabled state using the [`enabled`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/enabled.html) property. The default value of the [`enabled`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/enabled.html) property is `true`. {% tabs %} {% highlight Dart %} @@ -169,7 +169,7 @@ class Data { {% endhighlight %} {% endtabs %} -![Range selector disabled state](images/disabled-state/selector_disabled_state.png) +![Range Selector disabled state](images/disabled-state/selector_disabled_state.png) ## Disabled color diff --git a/Flutter/range-selector/getting-started.md b/Flutter/range-selector/getting-started.md index 294d8be48..c7f4677a0 100644 --- a/Flutter/range-selector/getting-started.md +++ b/Flutter/range-selector/getting-started.md @@ -8,19 +8,19 @@ documentation: ug --- # Getting Started with Flutter Range Selector (SfRangeSelector) -This section explains the steps required to add the range selector widget and its elements such as numeric and date values, ticks, labels, and tooltips, covering only the basic features needed to get started with the Syncfusion® range selector. +This section explains the steps required to add the Flutter Range Selector widget and its elements such as numeric and date values, ticks, labels, and tooltips, covering only the basic features needed to get started with the Syncfusion® Flutter Range Selector. To get started quickly with our Flutter Range Selector widget, you can check out this video. -## Add Flutter range selector to an application +## Add Flutter Range Selector to an application Create a simple project using the instructions given in the [Getting Started with your first Flutter app](https://docs.flutter.dev/get-started/test-drive#choose-your-ide) documentation. **Add dependency** -Add the Syncfusion® Flutter range selector dependency to your pubspec.yaml file. +Add the Syncfusion® Flutter Range Selector dependency to your pubspec.yaml file. {% tabs %} {% highlight dart %} @@ -58,11 +58,11 @@ import 'package:syncfusion_flutter_sliders/sliders.dart'; {% endhighlight %} {% endtabs %} -## Initialize range selector +## Initialize Range Selector -After importing the package, initialize the range selector widget as a child of any widget. Here, the range selector widget is added as a child of the Container widget. The default values of the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/min.html) and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/max.html) properties of the SfRangeSelector are 0.0 and 1.0 respectively. So, the [`initialValues`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/initialValues.html) property must be given within the range. You can add any kind of widget as a child of range selector. Here, [Chart](https://www.syncfusion.com/flutter-widgets/flutter-charts) widget is added as a child. +After importing the package, initialize the Flutter Range Selector widget as a child of any widget. Here, the Range Selector widget is added as a child of the Container widget. The default values of the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/min.html) and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/max.html) properties of the SfRangeSelector are 0.0 and 1.0 respectively. So, the [`initialValues`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/initialValues.html) property must be given within the range. You can add any kind of widget as a child of the Flutter Range Selector. Here, [Chart](https://www.syncfusion.com/flutter-widgets/flutter-charts) widget is added as a child. -I> You need to set the [`controller`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/controller.html) property to update range selector thumb values dynamically. Refer this [`link`](https://help.syncfusion.com/flutter/range-selector/range-controller) for setting controller property. The [initialValues](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/initialValues.html) property can be used to set values at load time. +I> You need to set the [`controller`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/controller.html) property to update Range Selector thumb values dynamically. Refer this [`link`](https://help.syncfusion.com/flutter/range-selector/range-controller) for setting controller property. The [initialValues](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/initialValues.html) property can be used to set values at load time. {% tabs %} {% highlight Dart %} @@ -124,7 +124,7 @@ class GettingStartedInitializeSample extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Default range selector](images/getting-started/default-range-selector.png) +![Default Range Selector](images/getting-started/default-range-selector.png) ## Handle range change @@ -199,7 +199,7 @@ class _HandleRangeChangeSampleState extends State { ## Set numeric range -You can show numeric values in the range selector by setting `double` values to the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/min.html), [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/max.html) and [`initialValues`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/initialValues.html) properties. +You can show numeric values in the Flutter Range Selector by setting `double` values to the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/min.html), [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/max.html) and [`initialValues`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/initialValues.html) properties. {% tabs %} {% highlight Dart %} @@ -268,11 +268,11 @@ class NumericRangeSample extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Numeric range selector](images/getting-started/numeric-range-selector.png) +![Numeric Range Selector](images/getting-started/numeric-range-selector.png) ## Set date range -You can show date values in the range selector by setting `DateTime` values to the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/min.html), [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/max.html) and [`initialValues`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/initialValues.html) properties. +You can show date values in the Flutter Range Selector by setting `DateTime` values to the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/min.html), [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/max.html) and [`initialValues`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/initialValues.html) properties. N> You must import [`intl`](https://pub.dev/packages/intl) package for formatting date range selector using the [`DateFormat`](https://pub.dev/documentation/intl/latest/intl/DateFormat-class.html) class. @@ -348,11 +348,11 @@ class DateRangeSample extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Date time range selector](images/getting-started/date-time-range-selector.png) +![Date time Range Selector](images/getting-started/date-time-range-selector.png) ## Enable ticks -You can enable ticks in the range selector using the [`showTicks`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/showTicks.html) property. +You can enable ticks in the Range Selector using the [`showTicks`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/showTicks.html) property. {% tabs %} {% highlight Dart %} @@ -422,13 +422,13 @@ class EnableTicksSample extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Show ticks in range selector](images/getting-started/range-selector_with_ticks.png) +![Show ticks in Range Selector](images/getting-started/range-selector_with_ticks.png) ## Add prefix/suffix to labels You can add prefix or suffix to the labels using the [`numberFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/numberFormat.html) or [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/dateFormat.html) properties. -N> The format type (numeric or date) of the range selector is determined based on the values specified in [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/min.html), [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/max.html) and [`initialValues`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/initialValues.html) properties. +N> The format type (numeric or date) of the Flutter Range Selector is determined based on the values specified in [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/min.html), [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/max.html) and [`initialValues`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/initialValues.html) properties. I> You must import [`intl`](https://pub.dev/packages/intl) package for formatting date range selector using the [`DateFormat`](https://pub.dev/documentation/intl/latest/intl/DateFormat-class.html) class and for formatting numeric range selector using the [`NumberFormat`](https://pub.dev/documentation/intl/latest/intl/NumberFormat-class.html) class. @@ -507,4 +507,4 @@ class PrefixSuffixLabelsSample extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Format labels in range selector](images/getting-started/range-selector_with_formatted_label.png) +![Format labels in Range Selector](images/getting-started/range-selector_with_formatted_label.png) diff --git a/Flutter/range-selector/interval.md b/Flutter/range-selector/interval.md index 3f9807e1f..8786f99ff 100644 --- a/Flutter/range-selector/interval.md +++ b/Flutter/range-selector/interval.md @@ -12,9 +12,9 @@ This section explains how to set intervals for numeric and date range selectors. ## Numeric interval -Range selector elements like labels, ticks, and dividers are rendered based on the [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/interval.html), [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/min.html) and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/max.html) properties. The default value of the [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/interval.html) property is `null`, and it must be greater than 0. +Flutter Range Selector elements like labels, ticks, and dividers are rendered based on the [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/interval.html), [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/min.html) and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/max.html) properties. The default value of the [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/interval.html) property is `null`, and it must be greater than 0. -For example, if [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/min.html) is 2.0 and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/max.html) is 10.0 and [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/interval.html) is 2.0, the range selector will render the labels, major ticks, and dividers at 2.0, 4.0, and so on. +For example, if [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/min.html) is 2.0 and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/max.html) is 10.0 and [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/interval.html) is 2.0, the Flutter Range Selector will render the labels, major ticks, and dividers at 2.0, 4.0, and so on. {% tabs %} {% highlight Dart %} @@ -99,9 +99,9 @@ N> The type of date interval can range from years to seconds. It is mandatory for date [`SfRangeSelector`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector-class.html). The default value of [`dateIntervalType`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/dateIntervalType.html) property is `null`. -For date values, the range selector does not have auto interval support. So, it is mandatory to set [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/interval.html), [`dateIntervalType`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/dateIntervalType.html), and [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/dateFormat.html) for date values. +For date values, the Flutter Range Selector does not have auto interval support. So, it is mandatory to set [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/interval.html), [`dateIntervalType`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/dateIntervalType.html), and [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/dateFormat.html) for date values. -For example, if [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/min.html) is `DateTime(2002, 01, 01)` and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/max.html) is `DateTime(2010, 01, 01)` and [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/interval.html) is `2`, [`dateIntervalType`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/dateIntervalType.html) is `DateIntervalType.years`, [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/dateFormat.html) is `DateFormat.y()` then the range selector will render the labels, major ticks, and dividers at 2002, 2004, 2006 and so on. +For example, if [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/min.html) is `DateTime(2002, 01, 01)` and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/max.html) is `DateTime(2010, 01, 01)` and [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/interval.html) is `2`, [`dateIntervalType`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/dateIntervalType.html) is `DateIntervalType.years`, [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/dateFormat.html) is `DateFormat.y()` then the Flutter Range Selector will render the labels, major ticks, and dividers at 2002, 2004, 2006 and so on. {% tabs %} {% highlight Dart %} @@ -183,7 +183,7 @@ class DateIntervalSample extends StatelessWidget { ## Discrete selection for numeric values -You can move the thumb in discrete manner for numeric values using the [`stepSize`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/stepSize.html) property in the range selector. +You can move the thumb in discrete manner for numeric values using the [`stepSize`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/stepSize.html) property in the Flutter Range Selector. {% tabs %} {% highlight Dart %} @@ -263,9 +263,9 @@ class StepSizeSample extends StatelessWidget { ## Discrete selection for date values -You can move the thumb in discrete manner for date values based on the value provided in the [`stepDuration`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/stepDuration.html) property in the range selector. +You can move the thumb in discrete manner for date values based on the value provided in the [`stepDuration`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/stepDuration.html) property in the Flutter Range Selector. -For example, if [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/min.html) is `DateTime(2015, 01, 01)` and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/max.html) is `DateTime(2020, 01, 01)` and [`stepDuration`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/stepDuration.html) is `SliderStepDuration(years: 1, months: 6)`, the range selector will move the thumbs to `DateTime(2015, 01, 01)`, `DateTime(2016, 07, 01)`, `DateTime(2018, 01, 01)`, `DateTime(2019, 07, 01)`, and so on. +For example, if [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/min.html) is `DateTime(2015, 01, 01)` and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/max.html) is `DateTime(2020, 01, 01)` and [`stepDuration`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/stepDuration.html) is `SliderStepDuration(years: 1, months: 6)`, the Flutter Range Selector will move the thumbs to `DateTime(2015, 01, 01)`, `DateTime(2016, 07, 01)`, `DateTime(2018, 01, 01)`, `DateTime(2019, 07, 01)`, and so on. {% tabs %} {% highlight Dart %} diff --git a/Flutter/range-selector/labels-and-divider.md b/Flutter/range-selector/labels-and-divider.md index 807afb6f7..7f5bb702e 100644 --- a/Flutter/range-selector/labels-and-divider.md +++ b/Flutter/range-selector/labels-and-divider.md @@ -8,7 +8,7 @@ documentation: ug --- # Labels and Dividers in Flutter Range Selector (SfRangeSelector) -This section explains how to add labels and dividers to the range selector. +This section explains how to add labels and dividers to the Flutter Range Selector. ## Show labels @@ -86,7 +86,7 @@ class ShowLabelsSample extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Range selector labels](images/label-and-divider/selector_show_label.png) +![Range Selector labels](images/label-and-divider/selector_show_label.png) N> * Refer the [`numberFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/numberFormat.html) and [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/dateFormat.html) for formatting the numeric and date labels respectively. @@ -176,7 +176,7 @@ class NumberFormatSample extends StatelessWidget { ## Date format -The [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/dateFormat.html) property is used to format the date labels. It is mandatory for the date [`SfRangeSelector`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector-class.html). For date values, the range selector does not have auto interval support. So, it is mandatory to set [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/interval.html), [`dateIntervalType`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/dateIntervalType.html), and [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/dateFormat.html) for date values. The default value of [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/dateFormat.html) property is `null`. +The [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/dateFormat.html) property is used to format the date labels. It is mandatory for the date [`SfRangeSelector`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector-class.html). For date values, the Flutter Range Selector does not have auto interval support. So, it is mandatory to set [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/interval.html), [`dateIntervalType`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/dateIntervalType.html), and [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/dateFormat.html) for date values. The default value of [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/dateFormat.html) property is `null`. N> You must import [`intl`](https://pub.dev/packages/intl) package for formatting date range selector using the [`DateFormat`](https://pub.dev/documentation/intl/latest/intl/DateFormat-class.html) class. @@ -507,7 +507,7 @@ class LabelPlacementSample extends StatelessWidget { ## Edge label placement -The [`edgeLabelPlacement`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/edgeLabelPlacement.html) property determines how the edge (first and last) labels are positioned on the range selector. This property allows the edge labels to be placed either inside the major ticks or directly on the major ticks. +The [`edgeLabelPlacement`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/edgeLabelPlacement.html) property determines how the edge (first and last) labels are positioned on the Flutter Range Selector. This property allows the edge labels to be placed either inside the major ticks or directly on the major ticks. The default value of [`edgeLabelPlacement`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/edgeLabelPlacement.html) property is `EdgeLabelPlacement.auto`. @@ -679,7 +679,7 @@ class CustomizeLabelTextSample extends StatelessWidget { ## Label style -You can change the active and inactive label appearance of the range selector using the [`activeLabelStyle`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeLabelStyle.html) and [`inactiveLabelStyle`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveLabelStyle.html) properties respectively. +You can change the active and inactive label appearance of the Flutter Range Selector using the [`activeLabelStyle`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeLabelStyle.html) and [`inactiveLabelStyle`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveLabelStyle.html) properties respectively. The active side of the [`SfRangeSelector`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector-class.html) is between start and end thumbs. @@ -890,7 +890,7 @@ class _IndividualLabelStyleSampleState ## Label offset -You can adjust the space between ticks and labels of the range selector using the [`labelOffset`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/labelOffset.html) property. +You can adjust the space between ticks and labels of the Flutter Range Selector using the [`labelOffset`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/labelOffset.html) property. The default value of the [`labelOffset`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/labelOffset.html) property is `Offset(0.0, 13.0)` if the [`showTicks`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/showTicks.html) property is `false`. The default value of the [`labelOffset`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/labelOffset.html) property is `Offset(0.0, 5.0)` if the [`showTicks`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/showTicks.html) property is `true`. @@ -979,7 +979,7 @@ class LabelOffsetSample extends StatelessWidget { The [`showDividers`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/showDividers.html) property is used to render the dividers on the track. The default value of [`showDividers`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/showDividers.html) property is `false`. It is a shape which is used to represent the major interval points of the track. -For example, if [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/min.html) is 0.0 and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/max.html) is 10.0 and [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/interval.html) is 2.0, the range selector will render the dividers at 0.0, 2.0, 4.0 and so on. +For example, if [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/min.html) is 0.0 and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/max.html) is 10.0 and [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/interval.html) is 2.0, the Flutter Range Selector will render the dividers at 0.0, 2.0, 4.0 and so on. {% tabs %} {% highlight Dart %} @@ -1053,11 +1053,11 @@ class ShowDividersSample extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Range selector dividers](images/label-and-divider/selector_show_divider.png) +![Range Selector dividers](images/label-and-divider/selector_show_divider.png) ## Divider radius -You can change the active and inactive divider radius of the range selector using the [`activeDividerRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeDividerRadius.html) and the [`inactiveDividerRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveDividerRadius.html) properties respectively. +You can change the active and inactive divider radius of the Flutter Range Selector using the [`activeDividerRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeDividerRadius.html) and the [`inactiveDividerRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveDividerRadius.html) properties respectively. {% tabs %} {% highlight Dart %} @@ -1143,7 +1143,7 @@ class DividerRadiusSample extends StatelessWidget { ## Divider stroke width and stroke color -You can change the active and inactive divider stroke width of the range selector using the [`activeDividerStrokeWidth`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeDividerStrokeWidth.html) and the [`inactiveDividerStrokeWidth`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveDividerStrokeWidth.html) properties respectively. +You can change the active and inactive divider stroke width of the Flutter Range Selector using the [`activeDividerStrokeWidth`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeDividerStrokeWidth.html) and the [`inactiveDividerStrokeWidth`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveDividerStrokeWidth.html) properties respectively. Also, you can change the active and inactive divider stroke color of the range selector using the [`activeDividerStrokeColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeDividerStrokeColor.html) and the [`inactiveDividerStrokeColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveDividerStrokeColor.html) properties respectively. @@ -1233,7 +1233,7 @@ class DividerStrokeSample extends StatelessWidget { ## Divider color -You can change the active and inactive divider color of the range selector using the [`activeDividerColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeDividerColor.html) and [`inactiveDividerColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveDividerColor.html) properties respectively. +You can change the active and inactive divider color of the Flutter Range Selector using the [`activeDividerColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeDividerColor.html) and [`inactiveDividerColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveDividerColor.html) properties respectively. {% tabs %} {% highlight Dart %} diff --git a/Flutter/range-selector/overview.md b/Flutter/range-selector/overview.md index 1a1a635eb..936e35f47 100644 --- a/Flutter/range-selector/overview.md +++ b/Flutter/range-selector/overview.md @@ -11,11 +11,11 @@ documentation: ug Syncfusion® Flutter Range Selector is a highly interactive UI widget for selecting a smaller range from a larger data set. It provides a rich set of features such as numeric and date values, labels, ticks, dividers, and tooltips. It also supports adding any type of widget as content. -![Range selector overview](images/overview/range-selector-overview.png) +![Range Selector overview](images/overview/range-selector-overview.png) ## Features -* **Child support** - Add a child of any type inside the range selector. It is also possible to add a [Charts](https://www.syncfusion.com/flutter-widgets/flutter-charts) widget. With the built-in integrations, the range selector is smart enough to handle features like segment selection and zooming in the chart based on the selected range in the range selector. Similar to the range slider, it also supports both numeric and date values. +* **Child support** - Add a child of any type inside the Flutter Range Selector. It is also possible to add a [Charts](https://www.syncfusion.com/flutter-widgets/flutter-charts) widget. With the built-in integrations, the Range Selector is smart enough to handle features like segment selection and zooming in the chart based on the selected range in the Range Selector. Similar to the range slider, it also supports both numeric and date values. * **Numeric and date support** - Provides functionality for selecting numeric and date ranges. For the date range, support is provided up to the seconds interval. * **Labels** - Render labels for the date and numeric ranges with the option to customize their format based on your requirements. * **Ticks and dividers** - Provides the option to show ticks and dividers based on the interval. Also enables minor ticks to indicate the values between each interval. These options present the selected range in a more intuitive way for end users. diff --git a/Flutter/range-selector/range-controller.md b/Flutter/range-selector/range-controller.md index da4e3b603..25487e56d 100644 --- a/Flutter/range-selector/range-controller.md +++ b/Flutter/range-selector/range-controller.md @@ -9,19 +9,19 @@ documentation: ug # Controller in Flutter Range Selector (SfRangeSelector) -You can use [`RangeController`](https://pub.dev/documentation/syncfusion_flutter_core/latest/core/RangeController-class.html) for setting and getting current selected values of range selector. +You can use [`RangeController`](https://pub.dev/documentation/syncfusion_flutter_core/latest/core/RangeController-class.html) for setting and getting current selected values of Flutter Range Selector. -The `start` represents the currently selected start value of the range selector. The left thumb of the range selector is drawn corresponding to this value. +The `start` represents the currently selected start value of the Flutter Range Selector. The left thumb of the Range Selector is drawn corresponding to this value. -The `end` represents the currently selected end value of the range selector. The right thumb of the range selector is drawn corresponding to this value. +The `end` represents the currently selected end value of the Flutter Range Selector. The right thumb of the Range Selector is drawn corresponding to this value. You can get previous values using `previousStart` and `previousEnd` properties. The `start`, `end`, `previousStart`, `previousEnd` properties can be either `double` or `DateTime` based on whether it is date type [`SfRangeSelector`](https://help.syncfusion.com/flutter/range-selector/getting-started#set-date-range) or numeric [`SfRangeSelector`](https://help.syncfusion.com/flutter/range-selector/getting-started#set-numeric-range). -I> You do not need to set the [`initialValues`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/initialValues.html) property when using the [`controller`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/controller.html) property in the range selector. +I> You do not need to set the [`initialValues`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/initialValues.html) property when using the [`controller`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/controller.html) property in the Flutter Range Selector. -N> You must import the [`Core`](https://pub.dev/packages/syncfusion_flutter_core) to use the range controller in the range selector. +N> You must import the [`Core`](https://pub.dev/packages/syncfusion_flutter_core) to use the range controller in the Flutter Range Selector. {% tabs %} {% highlight Dart %} @@ -114,11 +114,11 @@ class Data { {% endhighlight %} {% endtabs %} -![Range selector controller](images/range-controller/range-controller.png) +![Range Selector controller](images/range-controller/range-controller.png) ## Selection with SfChart -The range selector provides built-in support for selecting the chart segments based on the selected range in the range selector. To achieve this segment selection, you must set the `SelectionBehavior.selectionController` property in the `SfCartesianChart.series` property. The [`selectionController`](https://pub.dev/documentation/syncfusion_flutter_charts/latest/charts/SelectionBehavior/selectionController.html) links the chart selection to the range selector's controller. +The Flutter Range Selector provides built-in support for selecting the chart segments based on the selected range in the Range Selector. To achieve this segment selection, you must set the `SelectionBehavior.selectionController` property in the `SfCartesianChart.series` property. The [`selectionController`](https://pub.dev/documentation/syncfusion_flutter_charts/latest/charts/SelectionBehavior/selectionController.html) links the chart selection to the controller of the Range Controller. {% tabs %} {% highlight Dart %} @@ -240,7 +240,7 @@ class Data { ## Zooming with SfChart -The range selector provides built-in support for updating the visible range of the chart based on the selected range in the range selector. To update the visible range, you must set the `primaryXAxis.rangeController` property in the [`SfCartesianChart`](https://pub.dev/documentation/syncfusion_flutter_charts/latest/charts/SfCartesianChart-class.html). +The Flutter Range Selector provides built-in support for updating the visible range of the chart based on the selected range in the Range Selector. To update the visible range, you must set the `primaryXAxis.rangeController` property in the [`SfCartesianChart`](https://pub.dev/documentation/syncfusion_flutter_charts/latest/charts/SfCartesianChart-class.html). {% tabs %} {% highlight Dart %} diff --git a/Flutter/range-selector/right-to-left.md b/Flutter/range-selector/right-to-left.md index e7519d096..3545bd4f8 100644 --- a/Flutter/range-selector/right-to-left.md +++ b/Flutter/range-selector/right-to-left.md @@ -9,7 +9,7 @@ documentation: ug # Right-to-Left (RTL) in Flutter Range Selector (SfRangeSelector) -N> RTL is not applicable for the vertical orientation of the range selector. +N> RTL is not applicable for the vertical orientation of the Flutter Range Selector. ## RTL rendering ways @@ -17,7 +17,7 @@ Right-to-left rendering can be achieved in the following ways: ### Wrapping the SfRangeSelector with Directionality widget -The range selector can be wrapped inside the [`Directionality`](https://api.flutter.dev/flutter/widgets/Directionality-class.html) widget and you can set the [`textDirection`](https://api.flutter.dev/flutter/widgets/Directionality/textDirection.html) property to `rtl`. +The Flutter Range Selector can be wrapped inside the [`Directionality`](https://api.flutter.dev/flutter/widgets/Directionality-class.html) widget and you can set the [`textDirection`](https://api.flutter.dev/flutter/widgets/Directionality/textDirection.html) property to `rtl`. {% tabs %} {% highlight Dart %} @@ -64,7 +64,7 @@ class _RtlDirectionalitySampleState extends State { ### Changing the locale to RTL languages -The range selector will render in right to left direction if the locale belongs to RTL languages such as Arabic, Persian, Hebrew, Pashto, and Urdu. This can be achieved by specifying the MaterialApp properties such as `localizationsDelegates`, `supportedLocales`, `locale` and adding the flutter_localizations package to your pubspec.yaml file. +The Flutter Range Selector will render in right to left direction if the locale belongs to RTL languages such as Arabic, Persian, Hebrew, Pashto, and Urdu. This can be achieved by specifying the MaterialApp properties such as `localizationsDelegates`, `supportedLocales`, `locale` and adding the flutter_localizations package to your pubspec.yaml file. {% tabs %} {% highlight Dart %} diff --git a/Flutter/range-selector/shapes.md b/Flutter/range-selector/shapes.md index 21cf068e4..738502c67 100644 --- a/Flutter/range-selector/shapes.md +++ b/Flutter/range-selector/shapes.md @@ -1,529 +1,529 @@ ---- -layout: post -title: Custom Shapes in Flutter Range Selector | Syncfusion® -description: Learn about custom shapes in Syncfusion® Flutter Range Selector (SfRangeSelector), including track, thumb, divider, tick, and tooltip customization. -platform: flutter -control: SfRangeSelector -documentation: ug ---- - -# Custom Shapes in Flutter Range Selector (SfRangeSelector) - -This section explains how to customize the shapes of the range selector elements. - -## Track shape - -You can change the size and shape of the track using the [`trackShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/trackShape.html) property in the [`SfRangeSelector`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector-class.html). - -* getPreferredSize() - Returns the size based on the values passed to it. -* paint() - Used to change the track shape. - -N> You must use the `startThumbCenter`, `endThumbCenter`, and `currentValues` parameters of the paint override method for customizing the range selector track. - -{% tabs %} -{% highlight Dart %} - -import 'dart:math' as math; - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_charts/charts.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class TrackShapeSample extends StatefulWidget { - @override - _TrackShapeSampleState createState() => _TrackShapeSampleState(); -} - -class _TrackShapeSampleState extends State { - final double _min = 2.0; - final double _max = 10.0; - SfRangeValues _values = SfRangeValues(3.0, 8.0); - - final List chartData = [ - Data(x: 2.0, y: 2.2), - Data(x: 3.0, y: 3.4), - Data(x: 4.0, y: 2.8), - Data(x: 5.0, y: 1.6), - Data(x: 6.0, y: 2.3), - Data(x: 7.0, y: 2.5), - Data(x: 8.0, y: 2.9), - Data(x: 9.0, y: 3.8), - Data(x: 10.0, y: 3.7), - ]; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfRangeSelectorTheme( - data: SfRangeSelectorThemeData( - activeTrackHeight: 10, - inactiveTrackHeight: 10, - ), - child: SfRangeSelector( - min: _min, - max: _max, - initialValues: _values, - trackShape: _TrackShape(), - child: Container( - height: 130, - child: SfCartesianChart( - margin: const EdgeInsets.all(0), - primaryXAxis: - NumericAxis(minimum: _min, maximum: _max, isVisible: false), - primaryYAxis: NumericAxis(isVisible: false), - plotAreaBorderWidth: 0, - series: >[ - SplineAreaSeries( - color: Color.fromARGB(255, 126, 184, 253), - dataSource: chartData, - xValueMapper: (Data sales, int index) => sales.x, - yValueMapper: (Data sales, int index) => sales.y) - ], - ), - ), - ), - ), - ), - ), - ); - } -} - -class Data { - Data({required this.x, required this.y}); - final double x; - final double y; -} - -class _TrackShape extends SfTrackShape { - @override - void paint(PaintingContext context, Offset offset, Offset? thumbCenter, - Offset? startThumbCenter, Offset? endThumbCenter, - {required RenderBox parentBox, - required SfSliderThemeData themeData, - SfRangeValues? currentValues, - dynamic currentValue, - required Animation enableAnimation, - required Paint? inactivePaint, - required Paint? activePaint, - required TextDirection textDirection}) { - Paint paint = Paint() - ..color = themeData.activeTrackColor! - ..style = PaintingStyle.stroke - ..strokeWidth = 1; - super.paint(context, offset, thumbCenter, startThumbCenter, endThumbCenter, - parentBox: parentBox, - themeData: themeData, - enableAnimation: enableAnimation, - inactivePaint: inactivePaint, - activePaint: paint, - textDirection: textDirection); - } -} - -{% endhighlight %} -{% endtabs %} - -![Track shape](images/shapes/track-shape.png) - -## Thumb shape - -You can change the size and shape of the thumb using the [`thumbShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/thumbShape.html) property in the [`SfRangeSelector`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector-class.html). - -* getPreferredSize() - Returns the size based on the values passed to it. -* paint() - Used to change the thumb shape. - -N> You must use the `currentValues` parameter of the paint override method for customizing the range selector thumbs. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_charts/charts.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class ThumbShapeSample extends StatefulWidget { - @override - _ThumbShapeSampleState createState() => _ThumbShapeSampleState(); -} - -class _ThumbShapeSampleState extends State { - final double _min = 2.0; - final double _max = 10.0; - SfRangeValues _values = SfRangeValues(4.0, 8.0); - - final List chartData = [ - Data(x: 2.0, y: 2.2), - Data(x: 3.0, y: 3.4), - Data(x: 4.0, y: 2.8), - Data(x: 5.0, y: 1.6), - Data(x: 6.0, y: 2.3), - Data(x: 7.0, y: 2.5), - Data(x: 8.0, y: 2.9), - Data(x: 9.0, y: 3.8), - Data(x: 10.0, y: 3.7), - ]; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfRangeSelectorTheme( - data: SfRangeSelectorThemeData(overlayColor: Colors.transparent), - child: SfRangeSelector( - min: _min, - max: _max, - initialValues: _values, - thumbShape: _SfThumbShape(), - child: Container( - height: 130, - child: SfCartesianChart( - margin: const EdgeInsets.all(0), - primaryXAxis: NumericAxis( - minimum: _min, maximum: _max, isVisible: false), - primaryYAxis: NumericAxis(isVisible: false), - plotAreaBorderWidth: 0, - series: >[ - SplineAreaSeries( - color: Color.fromARGB(255, 126, 184, 253), - dataSource: chartData, - xValueMapper: (Data sales, int index) => sales.x, - yValueMapper: (Data sales, int index) => sales.y) - ], - ), - ), - ), - ), - ), - ), - ); - } -} - -class Data { - Data({required this.x, required this.y}); - final double x; - final double y; -} - -class _SfThumbShape extends SfThumbShape { - @override - void paint(PaintingContext context, Offset center, - {required RenderBox parentBox, - required RenderBox? child, - required SfSliderThemeData themeData, - SfRangeValues? currentValues, - dynamic currentValue, - required Paint? paint, - required Animation enableAnimation, - required TextDirection textDirection, - required SfThumb? thumb}) { - final Path path = Path(); - - path.moveTo(center.dx, center.dy); - path.lineTo(center.dx + 10, center.dy - 15); - path.lineTo(center.dx - 10, center.dy - 15); - path.close(); - context.canvas.drawPath( - path, - Paint() - ..color = themeData.activeTrackColor! - ..style = PaintingStyle.fill - ..strokeWidth = 2); - } -} - -{% endhighlight %} -{% endtabs %} - -![Thumb shape](images/shapes/thumb-shape.png) - -## Divider shape - -You can change the size and shape of the divider using the [`dividerShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/dividerShape.html) property in the [`SfRangeSelector`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector-class.html). - -* getPreferredSize() - Returns the size based on the values passed to it. -* paint() - Used to change the divider shape. - -N> You must use the `startThumbCenter`, `endThumbCenter`, and `currentValues` parameters of the paint override method for customizing the range selector divider. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_charts/charts.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class DividerShapeSample extends StatefulWidget { - @override - _DividerShapeSampleState createState() => _DividerShapeSampleState(); -} - -class _DividerShapeSampleState extends State { - final double _min = 2.0; - final double _max = 10.0; - SfRangeValues _values = SfRangeValues(4.0, 8.0); - - final List chartData = [ - Data(x: 2.0, y: 2.2), - Data(x: 3.0, y: 3.4), - Data(x: 4.0, y: 2.8), - Data(x: 5.0, y: 1.6), - Data(x: 6.0, y: 2.3), - Data(x: 7.0, y: 2.5), - Data(x: 8.0, y: 2.9), - Data(x: 9.0, y: 3.8), - Data(x: 10.0, y: 3.7), - ]; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfRangeSelector( - min: _min, - max: _max, - initialValues: _values, - interval: 1, - showDividers: true, - dividerShape: _DividerShape(), - child: Container( - height: 130, - child: SfCartesianChart( - margin: const EdgeInsets.all(0), - primaryXAxis: - NumericAxis(minimum: _min, maximum: _max, isVisible: false), - primaryYAxis: NumericAxis(isVisible: false), - plotAreaBorderWidth: 0, - series: >[ - SplineAreaSeries( - color: Color.fromARGB(255, 126, 184, 253), - dataSource: chartData, - xValueMapper: (Data sales, int index) => sales.x, - yValueMapper: (Data sales, int index) => sales.y) - ], - ), - ), - ), - ), - ), - ); - } -} - -class Data { - Data({required this.x, required this.y}); - final double x; - final double y; -} - -class _DividerShape extends SfDividerShape { - @override - void paint(PaintingContext context, Offset center, Offset? thumbCenter, - Offset? startThumbCenter, Offset? endThumbCenter, - {required RenderBox parentBox, - required SfSliderThemeData themeData, - SfRangeValues? currentValues, - dynamic currentValue, - required Paint? paint, - required Animation enableAnimation, - required TextDirection textDirection}) { - final bool isActive = - center.dx >= startThumbCenter!.dx && center.dx <= endThumbCenter!.dx; - context.canvas.drawRect( - Rect.fromCenter(center: center, width: 5.0, height: 10.0), - Paint() - ..isAntiAlias = true - ..style = PaintingStyle.fill - ..color = isActive ? Colors.white : themeData.activeTrackColor!); - } -} - -{% endhighlight %} -{% endtabs %} - -![Divider shape](images/shapes/divider-shape.png) - -## Major and minor ticks shapes - -You can change the size and shape of the major and minor ticks using the [`tickShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/tickShape.html) and [`minorTickShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/minorTickShape.html) properties in the [`SfRangeSelector`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector-class.html). - -* getPreferredSize() - Returns the size based on the values passed to it. -* paint() - Used to change the ticks shape. - -N> You must use the `startThumbCenter`, `endThumbCenter`, and `currentValues` parameters of the paint override method for customizing the range selector ticks. - -{% tabs %} -{% highlight Dart %} - -import 'dart:math' as math; - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_charts/charts.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class TicksShapeSample extends StatefulWidget { - @override - _TicksShapeSampleState createState() => _TicksShapeSampleState(); -} - -class _TicksShapeSampleState extends State { - final double _min = 2.0; - final double _max = 10.0; - SfRangeValues _values = SfRangeValues(4.0, 8.0); - - final List chartData = [ - Data(x: 2.0, y: 2.2), - Data(x: 3.0, y: 3.4), - Data(x: 4.0, y: 2.8), - Data(x: 5.0, y: 1.6), - Data(x: 6.0, y: 2.3), - Data(x: 7.0, y: 2.5), - Data(x: 8.0, y: 2.9), - Data(x: 9.0, y: 3.8), - Data(x: 10.0, y: 3.7), - ]; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfRangeSelector( - min: _min, - max: _max, - initialValues: _values, - interval: 1, - showTicks: true, - minorTicksPerInterval: 3, - tickShape: _TickShape(), - minorTickShape: _MinorTickShape(), - child: Container( - height: 130, - child: SfCartesianChart( - margin: const EdgeInsets.all(0), - primaryXAxis: - NumericAxis(minimum: _min, maximum: _max, isVisible: false), - primaryYAxis: NumericAxis(isVisible: false), - plotAreaBorderWidth: 0, - series: >[ - SplineAreaSeries( - color: Color.fromARGB(255, 126, 184, 253), - dataSource: chartData, - xValueMapper: (Data sales, int index) => sales.x, - yValueMapper: (Data sales, int index) => sales.y) - ], - ), - ), - ), - ), - ), - ); - } -} - -class Data { - Data({required this.x, required this.y}); - final double x; - final double y; -} - -class _TickShape extends SfTickShape { - @override - void paint(PaintingContext context, Offset offset, Offset? thumbCenter, - Offset? startThumbCenter, Offset? endThumbCenter, - {required RenderBox parentBox, - required SfSliderThemeData themeData, - SfRangeValues? currentValues, - dynamic currentValue, - required Animation enableAnimation, - required TextDirection textDirection}) { - final Size tickSize = getPreferredSize(themeData); - final bool isTickRightOfThumb = endThumbCenter == null - ? offset.dx > thumbCenter!.dx - : offset.dx < startThumbCenter!.dx || offset.dx > endThumbCenter!.dx; - final Color begin = isTickRightOfThumb - ? themeData.disabledInactiveTickColor - : themeData.disabledActiveTickColor; - final Color end = isTickRightOfThumb - ? themeData.inactiveTickColor - : themeData.activeTickColor; - final Paint paint = Paint() - ..isAntiAlias = true - ..strokeWidth = tickSize.width - ..color = ColorTween(begin: begin, end: end).evaluate(enableAnimation)!; - context.canvas.drawLine( - offset, Offset(offset.dx, offset.dy + tickSize.height), paint); - context.canvas.drawLine( - Offset( - offset.dx, - offset.dy - - 2 - - math.max(themeData.activeTrackHeight, - themeData.inactiveTrackHeight)), - Offset( - offset.dx, - offset.dy - - 2 - - math.max(themeData.activeTrackHeight, - themeData.inactiveTrackHeight) - - tickSize.height), - paint); - } -} - -class _MinorTickShape extends SfTickShape { - @override - void paint(PaintingContext context, Offset offset, Offset? thumbCenter, - Offset? startThumbCenter, Offset? endThumbCenter, - {required RenderBox parentBox, - required SfSliderThemeData themeData, - SfRangeValues? currentValues, - dynamic currentValue, - required Animation enableAnimation, - required TextDirection textDirection}) { - final Size minorTickSize = getPreferredSize(themeData); - final bool isMinorTickRightOfThumb = endThumbCenter == null - ? offset.dx > thumbCenter!.dx - : offset.dx < startThumbCenter!.dx || offset.dx > endThumbCenter!.dx; - - final Color begin = isMinorTickRightOfThumb - ? themeData.disabledInactiveMinorTickColor - : themeData.disabledActiveMinorTickColor; - final Color end = isMinorTickRightOfThumb - ? themeData.inactiveMinorTickColor - : themeData.activeMinorTickColor; - final Paint paint = Paint() - ..isAntiAlias = true - ..strokeWidth = minorTickSize.width - ..color = ColorTween(begin: begin, end: end).evaluate(enableAnimation)!; - context.canvas.drawLine( - offset, Offset(offset.dx, offset.dy + minorTickSize.height), paint); - context.canvas.drawLine( - Offset( - offset.dx, - offset.dy - - 2 - - math.max(themeData.activeTrackHeight, - themeData.inactiveTrackHeight)), - Offset( - offset.dx, - offset.dy - - 2 - - math.max(themeData.activeTrackHeight, - themeData.inactiveTrackHeight) - - minorTickSize.height), - paint); - } -} - -{% endhighlight %} -{% endtabs %} - +--- +layout: post +title: Custom Shapes in Flutter Range Selector | Syncfusion® +description: Learn about custom shapes in Syncfusion® Flutter Range Selector (SfRangeSelector), including track, thumb, divider, tick, and tooltip customization. +platform: flutter +control: SfRangeSelector +documentation: ug +--- + +# Custom Shapes in Flutter Range Selector (SfRangeSelector) + +This section explains how to customize the shapes of the range selector elements. + +## Track shape + +You can change the size and shape of the track using the [`trackShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/trackShape.html) property in the [`SfRangeSelector`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector-class.html). + +* getPreferredSize() - Returns the size based on the values passed to it. +* paint() - Used to change the track shape. + +N> You must use the `startThumbCenter`, `endThumbCenter`, and `currentValues` parameters of the paint override method for customizing the track of the Flutter Range Selector. + +{% tabs %} +{% highlight Dart %} + +import 'dart:math' as math; + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_charts/charts.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class TrackShapeSample extends StatefulWidget { + @override + _TrackShapeSampleState createState() => _TrackShapeSampleState(); +} + +class _TrackShapeSampleState extends State { + final double _min = 2.0; + final double _max = 10.0; + SfRangeValues _values = SfRangeValues(3.0, 8.0); + + final List chartData = [ + Data(x: 2.0, y: 2.2), + Data(x: 3.0, y: 3.4), + Data(x: 4.0, y: 2.8), + Data(x: 5.0, y: 1.6), + Data(x: 6.0, y: 2.3), + Data(x: 7.0, y: 2.5), + Data(x: 8.0, y: 2.9), + Data(x: 9.0, y: 3.8), + Data(x: 10.0, y: 3.7), + ]; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfRangeSelectorTheme( + data: SfRangeSelectorThemeData( + activeTrackHeight: 10, + inactiveTrackHeight: 10, + ), + child: SfRangeSelector( + min: _min, + max: _max, + initialValues: _values, + trackShape: _TrackShape(), + child: Container( + height: 130, + child: SfCartesianChart( + margin: const EdgeInsets.all(0), + primaryXAxis: + NumericAxis(minimum: _min, maximum: _max, isVisible: false), + primaryYAxis: NumericAxis(isVisible: false), + plotAreaBorderWidth: 0, + series: >[ + SplineAreaSeries( + color: Color.fromARGB(255, 126, 184, 253), + dataSource: chartData, + xValueMapper: (Data sales, int index) => sales.x, + yValueMapper: (Data sales, int index) => sales.y) + ], + ), + ), + ), + ), + ), + ), + ); + } +} + +class Data { + Data({required this.x, required this.y}); + final double x; + final double y; +} + +class _TrackShape extends SfTrackShape { + @override + void paint(PaintingContext context, Offset offset, Offset? thumbCenter, + Offset? startThumbCenter, Offset? endThumbCenter, + {required RenderBox parentBox, + required SfSliderThemeData themeData, + SfRangeValues? currentValues, + dynamic currentValue, + required Animation enableAnimation, + required Paint? inactivePaint, + required Paint? activePaint, + required TextDirection textDirection}) { + Paint paint = Paint() + ..color = themeData.activeTrackColor! + ..style = PaintingStyle.stroke + ..strokeWidth = 1; + super.paint(context, offset, thumbCenter, startThumbCenter, endThumbCenter, + parentBox: parentBox, + themeData: themeData, + enableAnimation: enableAnimation, + inactivePaint: inactivePaint, + activePaint: paint, + textDirection: textDirection); + } +} + +{% endhighlight %} +{% endtabs %} + +![Track shape](images/shapes/track-shape.png) + +## Thumb shape + +You can change the size and shape of the thumb using the [`thumbShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/thumbShape.html) property in the [`SfRangeSelector`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector-class.html). + +* getPreferredSize() - Returns the size based on the values passed to it. +* paint() - Used to change the thumb shape. + +N> You must use the `currentValues` parameter of the paint override method for customizing the thumbs of the Flutter Range Selector. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_charts/charts.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class ThumbShapeSample extends StatefulWidget { + @override + _ThumbShapeSampleState createState() => _ThumbShapeSampleState(); +} + +class _ThumbShapeSampleState extends State { + final double _min = 2.0; + final double _max = 10.0; + SfRangeValues _values = SfRangeValues(4.0, 8.0); + + final List chartData = [ + Data(x: 2.0, y: 2.2), + Data(x: 3.0, y: 3.4), + Data(x: 4.0, y: 2.8), + Data(x: 5.0, y: 1.6), + Data(x: 6.0, y: 2.3), + Data(x: 7.0, y: 2.5), + Data(x: 8.0, y: 2.9), + Data(x: 9.0, y: 3.8), + Data(x: 10.0, y: 3.7), + ]; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfRangeSelectorTheme( + data: SfRangeSelectorThemeData(overlayColor: Colors.transparent), + child: SfRangeSelector( + min: _min, + max: _max, + initialValues: _values, + thumbShape: _SfThumbShape(), + child: Container( + height: 130, + child: SfCartesianChart( + margin: const EdgeInsets.all(0), + primaryXAxis: NumericAxis( + minimum: _min, maximum: _max, isVisible: false), + primaryYAxis: NumericAxis(isVisible: false), + plotAreaBorderWidth: 0, + series: >[ + SplineAreaSeries( + color: Color.fromARGB(255, 126, 184, 253), + dataSource: chartData, + xValueMapper: (Data sales, int index) => sales.x, + yValueMapper: (Data sales, int index) => sales.y) + ], + ), + ), + ), + ), + ), + ), + ); + } +} + +class Data { + Data({required this.x, required this.y}); + final double x; + final double y; +} + +class _SfThumbShape extends SfThumbShape { + @override + void paint(PaintingContext context, Offset center, + {required RenderBox parentBox, + required RenderBox? child, + required SfSliderThemeData themeData, + SfRangeValues? currentValues, + dynamic currentValue, + required Paint? paint, + required Animation enableAnimation, + required TextDirection textDirection, + required SfThumb? thumb}) { + final Path path = Path(); + + path.moveTo(center.dx, center.dy); + path.lineTo(center.dx + 10, center.dy - 15); + path.lineTo(center.dx - 10, center.dy - 15); + path.close(); + context.canvas.drawPath( + path, + Paint() + ..color = themeData.activeTrackColor! + ..style = PaintingStyle.fill + ..strokeWidth = 2); + } +} + +{% endhighlight %} +{% endtabs %} + +![Thumb shape](images/shapes/thumb-shape.png) + +## Divider shape + +You can change the size and shape of the divider using the [`dividerShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/dividerShape.html) property in the [`SfRangeSelector`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector-class.html). + +* getPreferredSize() - Returns the size based on the values passed to it. +* paint() - Used to change the divider shape. + +N> You must use the `startThumbCenter`, `endThumbCenter`, and `currentValues` parameters of the paint override method for customizing the divider of the Flutter Range Selector. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_charts/charts.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class DividerShapeSample extends StatefulWidget { + @override + _DividerShapeSampleState createState() => _DividerShapeSampleState(); +} + +class _DividerShapeSampleState extends State { + final double _min = 2.0; + final double _max = 10.0; + SfRangeValues _values = SfRangeValues(4.0, 8.0); + + final List chartData = [ + Data(x: 2.0, y: 2.2), + Data(x: 3.0, y: 3.4), + Data(x: 4.0, y: 2.8), + Data(x: 5.0, y: 1.6), + Data(x: 6.0, y: 2.3), + Data(x: 7.0, y: 2.5), + Data(x: 8.0, y: 2.9), + Data(x: 9.0, y: 3.8), + Data(x: 10.0, y: 3.7), + ]; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfRangeSelector( + min: _min, + max: _max, + initialValues: _values, + interval: 1, + showDividers: true, + dividerShape: _DividerShape(), + child: Container( + height: 130, + child: SfCartesianChart( + margin: const EdgeInsets.all(0), + primaryXAxis: + NumericAxis(minimum: _min, maximum: _max, isVisible: false), + primaryYAxis: NumericAxis(isVisible: false), + plotAreaBorderWidth: 0, + series: >[ + SplineAreaSeries( + color: Color.fromARGB(255, 126, 184, 253), + dataSource: chartData, + xValueMapper: (Data sales, int index) => sales.x, + yValueMapper: (Data sales, int index) => sales.y) + ], + ), + ), + ), + ), + ), + ); + } +} + +class Data { + Data({required this.x, required this.y}); + final double x; + final double y; +} + +class _DividerShape extends SfDividerShape { + @override + void paint(PaintingContext context, Offset center, Offset? thumbCenter, + Offset? startThumbCenter, Offset? endThumbCenter, + {required RenderBox parentBox, + required SfSliderThemeData themeData, + SfRangeValues? currentValues, + dynamic currentValue, + required Paint? paint, + required Animation enableAnimation, + required TextDirection textDirection}) { + final bool isActive = + center.dx >= startThumbCenter!.dx && center.dx <= endThumbCenter!.dx; + context.canvas.drawRect( + Rect.fromCenter(center: center, width: 5.0, height: 10.0), + Paint() + ..isAntiAlias = true + ..style = PaintingStyle.fill + ..color = isActive ? Colors.white : themeData.activeTrackColor!); + } +} + +{% endhighlight %} +{% endtabs %} + +![Divider shape](images/shapes/divider-shape.png) + +## Major and minor ticks shapes + +You can change the size and shape of the major and minor ticks using the [`tickShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/tickShape.html) and [`minorTickShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/minorTickShape.html) properties in the [`SfRangeSelector`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector-class.html). + +* getPreferredSize() - Returns the size based on the values passed to it. +* paint() - Used to change the ticks shape. + +N> You must use the `startThumbCenter`, `endThumbCenter`, and `currentValues` parameters of the paint override method for customizing the ticks of the Range Selector. + +{% tabs %} +{% highlight Dart %} + +import 'dart:math' as math; + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_charts/charts.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class TicksShapeSample extends StatefulWidget { + @override + _TicksShapeSampleState createState() => _TicksShapeSampleState(); +} + +class _TicksShapeSampleState extends State { + final double _min = 2.0; + final double _max = 10.0; + SfRangeValues _values = SfRangeValues(4.0, 8.0); + + final List chartData = [ + Data(x: 2.0, y: 2.2), + Data(x: 3.0, y: 3.4), + Data(x: 4.0, y: 2.8), + Data(x: 5.0, y: 1.6), + Data(x: 6.0, y: 2.3), + Data(x: 7.0, y: 2.5), + Data(x: 8.0, y: 2.9), + Data(x: 9.0, y: 3.8), + Data(x: 10.0, y: 3.7), + ]; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfRangeSelector( + min: _min, + max: _max, + initialValues: _values, + interval: 1, + showTicks: true, + minorTicksPerInterval: 3, + tickShape: _TickShape(), + minorTickShape: _MinorTickShape(), + child: Container( + height: 130, + child: SfCartesianChart( + margin: const EdgeInsets.all(0), + primaryXAxis: + NumericAxis(minimum: _min, maximum: _max, isVisible: false), + primaryYAxis: NumericAxis(isVisible: false), + plotAreaBorderWidth: 0, + series: >[ + SplineAreaSeries( + color: Color.fromARGB(255, 126, 184, 253), + dataSource: chartData, + xValueMapper: (Data sales, int index) => sales.x, + yValueMapper: (Data sales, int index) => sales.y) + ], + ), + ), + ), + ), + ), + ); + } +} + +class Data { + Data({required this.x, required this.y}); + final double x; + final double y; +} + +class _TickShape extends SfTickShape { + @override + void paint(PaintingContext context, Offset offset, Offset? thumbCenter, + Offset? startThumbCenter, Offset? endThumbCenter, + {required RenderBox parentBox, + required SfSliderThemeData themeData, + SfRangeValues? currentValues, + dynamic currentValue, + required Animation enableAnimation, + required TextDirection textDirection}) { + final Size tickSize = getPreferredSize(themeData); + final bool isTickRightOfThumb = endThumbCenter == null + ? offset.dx > thumbCenter!.dx + : offset.dx < startThumbCenter!.dx || offset.dx > endThumbCenter!.dx; + final Color begin = isTickRightOfThumb + ? themeData.disabledInactiveTickColor + : themeData.disabledActiveTickColor; + final Color end = isTickRightOfThumb + ? themeData.inactiveTickColor + : themeData.activeTickColor; + final Paint paint = Paint() + ..isAntiAlias = true + ..strokeWidth = tickSize.width + ..color = ColorTween(begin: begin, end: end).evaluate(enableAnimation)!; + context.canvas.drawLine( + offset, Offset(offset.dx, offset.dy + tickSize.height), paint); + context.canvas.drawLine( + Offset( + offset.dx, + offset.dy - + 2 - + math.max(themeData.activeTrackHeight, + themeData.inactiveTrackHeight)), + Offset( + offset.dx, + offset.dy - + 2 - + math.max(themeData.activeTrackHeight, + themeData.inactiveTrackHeight) - + tickSize.height), + paint); + } +} + +class _MinorTickShape extends SfTickShape { + @override + void paint(PaintingContext context, Offset offset, Offset? thumbCenter, + Offset? startThumbCenter, Offset? endThumbCenter, + {required RenderBox parentBox, + required SfSliderThemeData themeData, + SfRangeValues? currentValues, + dynamic currentValue, + required Animation enableAnimation, + required TextDirection textDirection}) { + final Size minorTickSize = getPreferredSize(themeData); + final bool isMinorTickRightOfThumb = endThumbCenter == null + ? offset.dx > thumbCenter!.dx + : offset.dx < startThumbCenter!.dx || offset.dx > endThumbCenter!.dx; + + final Color begin = isMinorTickRightOfThumb + ? themeData.disabledInactiveMinorTickColor + : themeData.disabledActiveMinorTickColor; + final Color end = isMinorTickRightOfThumb + ? themeData.inactiveMinorTickColor + : themeData.activeMinorTickColor; + final Paint paint = Paint() + ..isAntiAlias = true + ..strokeWidth = minorTickSize.width + ..color = ColorTween(begin: begin, end: end).evaluate(enableAnimation)!; + context.canvas.drawLine( + offset, Offset(offset.dx, offset.dy + minorTickSize.height), paint); + context.canvas.drawLine( + Offset( + offset.dx, + offset.dy - + 2 - + math.max(themeData.activeTrackHeight, + themeData.inactiveTrackHeight)), + Offset( + offset.dx, + offset.dy - + 2 - + math.max(themeData.activeTrackHeight, + themeData.inactiveTrackHeight) - + minorTickSize.height), + paint); + } +} + +{% endhighlight %} +{% endtabs %} + ![Ticks shape](images/shapes/ticks-shape.png) \ No newline at end of file diff --git a/Flutter/range-selector/thumb-and-overlay.md b/Flutter/range-selector/thumb-and-overlay.md index 2f1d790ae..045cab429 100644 --- a/Flutter/range-selector/thumb-and-overlay.md +++ b/Flutter/range-selector/thumb-and-overlay.md @@ -9,16 +9,16 @@ documentation: ug # Thumb and Thumb Overlay in Flutter Range Selector (SfRangeSelector) -This section explains how to customize the thumb and thumb overlay in the range selector. +This section explains how to customize the thumb and thumb overlay in the Flutter Range Selector. N> You must import the `theme.dart` library from the [`Core`](https://pub.dev/packages/syncfusion_flutter_core) package to use [`SfRangeSelectorTheme`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfRangeSelectorTheme-class.html). All the examples in this section use `SfRangeSelectorTheme` to customize the thumb and thumb overlay. -* **Thumb** - It is one of the elements of range selector which can be used to drag and change the selected values of the range selector. +* **Thumb** - It is one of the elements of Flutter Range Selector which can be used to drag and change the selected values of the Flutter Range Selector. * **Thumb overlay** - It is rendered around the thumb while interacting with it. ## Thumb size -You can change the size of the thumb in the range selector using the [`thumbRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/thumbRadius.html) property. +You can change the size of the thumb in the Flutter Range Selector using the [`thumbRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/thumbRadius.html) property. {% tabs %} {% highlight Dart %} @@ -102,7 +102,7 @@ class ThumbSizeSample extends StatelessWidget { ## Thumb color -You can change the color of the thumb in the range selector using the [`thumbColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/thumbColor.html) property. +You can change the color of the thumb in the Flutter Range Selector using the [`thumbColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/thumbColor.html) property. {% tabs %} {% highlight Dart %} @@ -365,7 +365,7 @@ class ThumbIconSample extends StatelessWidget { ## Thumb overlay size -You can change the size of the thumb overlay in the range selector using the [`overlayRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/overlayRadius.html) property. +You can change the size of the thumb overlay in the Flutter Range Selector using the [`overlayRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/overlayRadius.html) property. {% tabs %} {% highlight Dart %} @@ -449,7 +449,7 @@ class ThumbOverlaySizeSample extends StatelessWidget { ## Thumb overlay color -You can change the color of the thumb overlay in the range selector using the [`overlayColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/overlayColor.html) property. +You can change the color of the thumb overlay in the Flutter Range Selector using the [`overlayColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/overlayColor.html) property. {% tabs %} {% highlight Dart %} @@ -533,7 +533,7 @@ class ThumbOverlayColorSample extends StatelessWidget { ## Thumb overlap stroke color -You can change the overlap stroke color of the thumb in the range selector using the [`overlappingThumbStrokeColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfRangeSliderThemeData/overlappingThumbStrokeColor.html) property. +You can change the overlap stroke color of the thumb in the Flutter Range Selector using the [`overlappingThumbStrokeColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfRangeSliderThemeData/overlappingThumbStrokeColor.html) property. {% tabs %} {% highlight Dart %} diff --git a/Flutter/range-selector/ticks.md b/Flutter/range-selector/ticks.md index e735da5bb..731d54c31 100644 --- a/Flutter/range-selector/ticks.md +++ b/Flutter/range-selector/ticks.md @@ -9,13 +9,13 @@ documentation: ug # Ticks in Flutter Range Selector (SfRangeSelector) -This section explains how to add major and minor ticks in the range selector. +This section explains how to add major and minor ticks in the Flutter Range Selector. ## Show major ticks You can enable the major ticks on the track. It is a shape used to mark the major interval points on the track. The default value of [`showTicks`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/showTicks.html) property is `false`. -For example, if [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/min.html) is 0.0 and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/max.html) is 10.0 and [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/interval.html) is 2.0, the range selector will render the major ticks at 0.0, 2.0, 4.0 and so on. +For example, if [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/min.html) is 0.0 and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/max.html) is 10.0 and [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/interval.html) is 2.0, the Flutter Range Selector will render the major ticks at 0.0, 2.0, 4.0 and so on. {% tabs %} {% highlight Dart %} @@ -99,7 +99,7 @@ N> Refer the [`tickShape`](https://pub.dev/documentation/syncfusion_flutter_slid ## Show minor ticks -It represents the number of smaller ticks between two major ticks. For example, if [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/min.html) is 0.0 and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/max.html) is 10.0 and [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/interval.html) is 2.0, the range selector will render the major ticks at 0.0, 2.0, 4.0 and so on. If [`minorTicksPerInterval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/minorTicksPerInterval.html) is 1, then smaller ticks will be rendered on 1.0 and 3.0 and so on. +It represents the number of smaller ticks between two major ticks. For example, if [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/min.html) is 0.0 and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/max.html) is 10.0 and [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/interval.html) is 2.0, the Flutter Range Selector will render the major ticks at 0.0, 2.0, 4.0 and so on. If [`minorTicksPerInterval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/minorTicksPerInterval.html) is 1, then smaller ticks will be rendered on 1.0 and 3.0 and so on. I> The default value of [`minorTicksPerInterval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector/minorTicksPerInterval.html) property is `null` and it must be greater than 0. @@ -184,7 +184,7 @@ N> ## Major ticks color -You can change the active and inactive major ticks color of the range selector using the [`activeTickColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeTickColor.html) and [`inactiveTickColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveTickColor.html) properties respectively. +You can change the active and inactive major ticks color of the Flutter Range Selector using the [`activeTickColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeTickColor.html) and [`inactiveTickColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveTickColor.html) properties respectively. The active side of the [`SfRangeSelector`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector-class.html) is between start and end thumbs. @@ -276,7 +276,7 @@ class MajorTicksColorSample extends StatelessWidget { ## Minor ticks color -You can change the active and inactive minor ticks color of the range selector using the [`activeMinorTickColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeMinorTickColor.html) and [`inactiveMinorTickColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveMinorTickColor.html) properties respectively. +You can change the active and inactive minor ticks color of the Flutter Range Selector using the [`activeMinorTickColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeMinorTickColor.html) and [`inactiveMinorTickColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveMinorTickColor.html) properties respectively. The active side of the [`SfRangeSelector`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector-class.html) is between start and end thumbs. @@ -367,7 +367,7 @@ class MinorTicksColorSample extends StatelessWidget { ## Tick size -You can change the major and minor ticks size of the range selector using the [`tickSize`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/tickSize.html) and [`minorTickSize`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/minorTickSize.html) properties respectively. The default value of the [`tickSize`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/tickSize.html) property is `Size(1.0, 8.0)` and [`minorTickSize`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/minorTickSize.html) property is `Size(1.0, 5.0)`. +You can change the major and minor ticks size of the Flutter Range Selector using the [`tickSize`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/tickSize.html) and [`minorTickSize`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/minorTickSize.html) properties respectively. The default value of the [`tickSize`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/tickSize.html) property is `Size(1.0, 8.0)` and [`minorTickSize`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/minorTickSize.html) property is `Size(1.0, 5.0)`. {% tabs %} {% highlight Dart %} @@ -452,7 +452,7 @@ class TickSizeSample extends StatelessWidget { ## Ticks offset -You can adjust the space between track and ticks of the range selector using the [`tickOffset`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/tickOffset.html) property in the [`SfRangeSelectorThemeData`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfRangeSelectorThemeData-class.html). The default value of the [`tickOffset`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/tickOffset.html) property is `null`. +You can adjust the space between track and ticks of the Flutter Range Selector using the [`tickOffset`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/tickOffset.html) property in the [`SfRangeSelectorThemeData`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfRangeSelectorThemeData-class.html). The default value of the [`tickOffset`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/tickOffset.html) property is `null`. {% tabs %} {% highlight Dart %} diff --git a/Flutter/range-selector/tooltip.md b/Flutter/range-selector/tooltip.md index 20c5c5e5e..7d75c2a31 100644 --- a/Flutter/range-selector/tooltip.md +++ b/Flutter/range-selector/tooltip.md @@ -9,7 +9,7 @@ documentation: ug # Tooltip in Flutter Range Selector (SfRangeSelector) -This section explains how to add tooltips in the range selector. +This section explains how to add tooltips in the Flutter Range Selector. ## Enable tooltips @@ -377,7 +377,7 @@ class Data { ## Tooltip label style -You can change the appearance of the tooltip text in the range selector using the [`tooltipTextStyle`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/tooltipTextStyle.html) property. +You can change the appearance of the tooltip text in the Flutter Range Selector using the [`tooltipTextStyle`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/tooltipTextStyle.html) property. N> You must import the `theme.dart` library from the [`Core`](https://pub.dev/packages/syncfusion_flutter_core) package to use [`SfRangeSelectorTheme`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfRangeSelectorTheme-class.html). @@ -472,7 +472,7 @@ class Data { ## Tooltip overlap stroke color -You can change the overlap stroke color of the tooltip in the range selector using the [`overlappingTooltipStrokeColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfRangeSliderThemeData/overlappingTooltipStrokeColor.html) property. +You can change the overlap stroke color of the tooltip in the Flutter Range Selector using the [`overlappingTooltipStrokeColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfRangeSliderThemeData/overlappingTooltipStrokeColor.html) property. N> You must import the `theme.dart` library from the [`Core`](https://pub.dev/packages/syncfusion_flutter_core) package to use [`SfRangeSelectorTheme`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfRangeSelectorTheme-class.html). diff --git a/Flutter/range-selector/track.md b/Flutter/range-selector/track.md index 7689349c9..d895686df 100644 --- a/Flutter/range-selector/track.md +++ b/Flutter/range-selector/track.md @@ -9,11 +9,11 @@ documentation: ug # Track in Flutter Range Selector (SfRangeSelector) -This section explains how to customize the track in the range selector. +This section explains how to customize the track in the Flutter Range Selector. ## Track color -You can change the active and inactive track color of the range selector using the [`activeTrackColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeTrackColor.html) and [`inactiveTrackColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveTrackColor.html) properties respectively. +You can change the active and inactive track color of the Flutter Range Selector using the [`activeTrackColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeTrackColor.html) and [`inactiveTrackColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveTrackColor.html) properties respectively. The active side of the [`SfRangeSelector`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSelector-class.html) is between start and end thumbs. @@ -103,7 +103,7 @@ class TrackColorSample extends StatelessWidget { ## Track height -You can change the track height of the range selector using the [`activeTrackHeight`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeTrackHeight.html) and the [`inactiveTrackHeight`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveTrackHeight.html) properties. The default value of the [`activeTrackHeight`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeTrackHeight.html) and the [`inactiveTrackHeight`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveTrackHeight.html) properties are `6.0` and `4.0`. +You can change the track height of the Flutter Range Selector using the [`activeTrackHeight`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeTrackHeight.html) and the [`inactiveTrackHeight`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveTrackHeight.html) properties. The default value of the [`activeTrackHeight`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeTrackHeight.html) and the [`inactiveTrackHeight`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveTrackHeight.html) properties are `6.0` and `4.0`. {% tabs %} {% highlight Dart %} @@ -185,7 +185,7 @@ class TrackHeightSample extends StatelessWidget { ## Track corner radius -You can change the corner of the track to be round in the range selector using the [`trackCornerRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/trackCornerRadius.html) property. The default value of the [`trackCornerRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/trackCornerRadius.html) property is `1.0`. +You can change the corner of the track to be round in the Flutter Range Selector using the [`trackCornerRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/trackCornerRadius.html) property. The default value of the [`trackCornerRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/trackCornerRadius.html) property is `1.0`. {% tabs %} {% highlight Dart %} diff --git a/Flutter/range-slider/basic-features.md b/Flutter/range-slider/basic-features.md index b7bc2e632..7ca7fdb8e 100644 --- a/Flutter/range-slider/basic-features.md +++ b/Flutter/range-slider/basic-features.md @@ -20,13 +20,13 @@ The maximum value that the user can select. The default value of [`max`](https:/ ## Values -It represents the values currently selected in the range slider. The range slider's thumbs are drawn corresponding to these values. +It represents the values currently selected in the Flutter Range Slider. The thumbs of the Flutter Range Slider are drawn corresponding to these values. -For date values, the range slider does not have auto interval support. So, it is mandatory to set [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/interval.html), [`dateIntervalType`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/dateIntervalType.html), and [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/dateFormat.html) for date values. +For date values, the Flutter Range Slider does not have auto interval support. So, it is mandatory to set [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/interval.html), [`dateIntervalType`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/dateIntervalType.html), and [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/dateFormat.html) for date values. **Numeric range slider** -You can show numeric values in the range slider by setting `double` values to the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html), [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) and [`values`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/values.html) properties. +You can show numeric values in the Flutter Range Slider by setting `double` values to the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html), [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) and [`values`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/values.html) properties. ### Horizontal @@ -112,7 +112,7 @@ class _HomePageState extends State { **Date range slider** -You can show date values in the range slider by setting `DateTime` values to the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html), [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) and [`values`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/values.html) properties. +You can show date values in the Flutter Range Slider by setting `DateTime` values to the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html), [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) and [`values`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/values.html) properties. N> You must import [`intl`](https://pub.dev/packages/intl) package for formatting date range slider using the [`DateFormat`](https://pub.dev/documentation/intl/latest/intl/DateFormat-class.html) class. @@ -204,13 +204,13 @@ class _HomePageState extends State { {% endhighlight %} {% endtabs %} -![Date range slider](images/basic-features/vertical-date-labels.png) +![Date Range Slider](images/basic-features/vertical-date-labels.png) ## Handle onChangeStart, onChanged, and onChangeEnd callbacks **onChangeStart** -The [`onChangeStart`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/onChangeStart.html) callback is called when the user begins to interact with the range slider using a tap or drag action. This callback is only used to notify the user that the interaction has started and it does not change the value of the range slider thumb. +The [`onChangeStart`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/onChangeStart.html) callback is called when the user begins to interact with the Flutter Range Slider using a tap or drag action. This callback is only used to notify the user that the interaction has started and it does not change the value of the range slider thumb. {% tabs %} {% highlight Dart %} @@ -251,7 +251,7 @@ class _HomePageState extends State { **onChangeEnd** -The [`onChangeEnd`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/onChangeEnd.html) callback is called when the user stops interacting with the range slider using a tap or drag action. This callback is only used to notify the user that the interaction has ended and it does not change the value of the range slider thumb. +The [`onChangeEnd`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/onChangeEnd.html) callback is called when the user stops interacting with the Flutter Range Slider using a tap or drag action. This callback is only used to notify the user that the interaction has ended and it does not change the value of the range slider thumb. {% tabs %} {% highlight Dart %} @@ -294,9 +294,9 @@ class _HomePageState extends State { The [`onChanged`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/onChanged.html) callback is called when the user selects a value through interaction. -N> The range slider passes the new values to the callback but does not change its state until the parent widget rebuilds the range slider with the new values. +N> The Flutter Range Slider passes the new values to the callback but does not change its state until the parent widget rebuilds the Flutter Range Slider with the new values. -N> If it is null, the range slider will be disabled. +N> If it is null, the Flutter Range Slider will be disabled. ### Horizontal @@ -335,7 +335,7 @@ class _HomePageState extends State { {% endhighlight %} {% endtabs %} -![Enabled range slider](images/basic-features/enabled-state.png) +![Enabled Range Slider](images/basic-features/enabled-state.png) ### Vertical @@ -378,7 +378,7 @@ class _HomePageState extends State { ## Active color -It represents the color applied to the active track, thumb, overlay, and inactive dividers. The active side of the range slider is between the start and end thumbs. +It represents the color applied to the active track, thumb, overlay, and inactive dividers. The active side of the Flutter Range Slider is between the start and end thumbs. ### Horizontal @@ -466,7 +466,7 @@ class _HomePageState extends State { It represents the color applied to the inactive track and active dividers. -The inactive side of the range slider is between the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html) value and the start thumb, and the end thumb and the [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) value. +The inactive side of the Flutter Range Slider is between the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html) value and the start thumb, and the end thumb and the [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) value. For RTL, the inactive side is between the [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) value and the start thumb, and the end thumb and the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html) value. diff --git a/Flutter/range-slider/enabled-and-disabled-state.md b/Flutter/range-slider/enabled-and-disabled-state.md index 268611eef..436f225fa 100644 --- a/Flutter/range-slider/enabled-and-disabled-state.md +++ b/Flutter/range-slider/enabled-and-disabled-state.md @@ -9,11 +9,11 @@ documentation: ug # Enabled and Disabled States in Flutter Range Slider (SfRangeSlider) -This section explains the enabled and disabled states of the Flutter range slider. +This section explains the enabled and disabled states of the Flutter Range Slider. ## Enabled state -The range slider will be in enabled state if [`onChanged`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/onChanged.html) is set. +The Flutter Range Slider will be in enabled state if [`onChanged`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/onChanged.html) is set. ### Horizontal @@ -130,7 +130,7 @@ class _HomePageState extends State { {% endhighlight %} {% endtabs %} -![Disabled range slider](images/enabled-and-disabled/disabled-state.png) +![Disabled Range Slider](images/enabled-and-disabled/disabled-state.png) ### Vertical diff --git a/Flutter/range-slider/getting-started.md b/Flutter/range-slider/getting-started.md index 9d16bd777..b668d093c 100644 --- a/Flutter/range-slider/getting-started.md +++ b/Flutter/range-slider/getting-started.md @@ -9,19 +9,19 @@ documentation: ug # Getting Started with Flutter Range Slider (SfRangeSlider) -This section explains the steps required to add the range slider widget and its elements such as numeric and date values, ticks, labels and tooltips, covering only the basic features needed to get started with the Syncfusion® range slider. +This section explains the steps required to add the Flutter Range Slider widget and its elements such as numeric and date values, ticks, labels and tooltips, covering only the basic features needed to get started with the Syncfusion® Flutter Range Slider. To get started quickly with our Flutter Range Slider widget, check out this video. -## Add Flutter range slider to an application +## Add Flutter Range Slider to an application Create a simple project using the instructions given in the [Getting Started with your first Flutter app](https://docs.flutter.dev/get-started/test-drive#choose-your-ide) documentation. **Add dependency** -Add the Syncfusion® Flutter range slider dependency to your pubspec.yaml file. +Add the Syncfusion® Flutter Sliders dependency to your pubspec.yaml file. {% tabs %} {% highlight dart %} @@ -33,7 +33,7 @@ syncfusion_flutter_sliders: ^xx.x.xx {% endhighlight %} {% endtabs %} -N> Here **xx.x.xx** denotes the current version of [`Syncfusion Flutter Sliders`](https://pub.dev/packages/syncfusion_flutter_sliders/versions) package. +N> Here **xx.x.xx** denotes the current version of [`Flutter Range Slider`](https://pub.dev/packages/syncfusion_flutter_sliders/versions) package. **Get packages** @@ -59,11 +59,11 @@ import 'package:syncfusion_flutter_sliders/sliders.dart'; {% endhighlight %} {% endtabs %} -## Initialize range slider +## Initialize Flutter Range Slider -After importing the package, initialize the range slider widget as a child of any widget. Here, the range slider widget is added as a child of the Container widget. The default values of the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html) and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) properties of the [`SfRangeSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider-class.html) are 0.0 and 1.0 respectively. So, the [`values`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/values.html) property must be given within the range. +After importing the package, initialize the Flutter Range Slider widget as a child of any widget. Here, the Range Slider widget is added as a child of the Container widget. The default values of the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html) and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) properties of the [`SfRangeSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider-class.html) are 0.0 and 1.0 respectively. So, the [`values`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/values.html) property must be given within the range. -N> The range slider passes the new values to the [`onChanged`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/onChanged.html) callback but does not change its state until the parent widget rebuilds the range slider with the new values. +N> The Flutter Range Slider passes the new values to the [`onChanged`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/onChanged.html) callback but does not change its state until the parent widget rebuilds the Range Slider with the new values. ### Horizontal @@ -101,7 +101,7 @@ class _HomePageState extends State { {% endhighlight %} {% endtabs %} -![Default range slider](images/getting-started/default_range_slider.png) +![Default Range Slider](images/getting-started/default_range_slider.png) ### Vertical @@ -143,9 +143,9 @@ class _HomePageState extends State { ## Handle range change -The [`onChanged`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/onChanged.html) callback is used to get the current values of the range slider when the user selects a value through interaction. +The [`onChanged`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/onChanged.html) callback is used to get the current values of the Flutter Range Slider when the user selects a value through interaction. -N> The range slider passes the new values to the callback but does not change its state until the parent widget rebuilds the range slider with the new values. +N> The Flutter Range Slider passes the new values to the callback but does not change its state until the parent widget rebuilds the Range Slider with the new values. ### Horizontal @@ -184,7 +184,7 @@ class _HomePageState extends State { {% endhighlight %} {% endtabs %} -![Handle range slider](images/getting-started/handle-range-slider-state.png) +![Handle Range Slider](images/getting-started/handle-range-slider-state.png) ### Vertical @@ -227,7 +227,7 @@ class _HomePageState extends State { ## Set numeric range -You can show numeric values in the range slider by setting `double` values to the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html), [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) and [`values`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/values.html) properties. +You can show numeric values in the Flutter Range Slider by setting `double` values to the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html), [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) and [`values`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/values.html) properties. ### Horizontal @@ -273,7 +273,7 @@ class _HomePageState extends State { {% endhighlight %} {% endtabs %} -![Numeric range slider](images/getting-started/numeric_range_slider.png) +![Numeric Range Slider](images/getting-started/numeric_range_slider.png) ### Vertical @@ -323,7 +323,7 @@ class _HomePageState extends State { ## Set date range -You can show date values in the range slider by setting `DateTime` values to the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html), [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) and [`values`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/values.html) properties. +You can show date values in the Flutter Range Slider by setting `DateTime` values to the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html), [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) and [`values`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/values.html) properties. N> You must import [`intl`](https://pub.dev/packages/intl) package for formatting date range slider using the [`DateFormat`](https://pub.dev/documentation/intl/latest/intl/DateFormat-class.html) class. @@ -375,7 +375,7 @@ class _HomePageState extends State { {% endhighlight %} {% endtabs %} -![DateTime range slider](images/getting-started/date_range_slider.png) +![DateTime Range Slider](images/getting-started/date_range_slider.png) ### Vertical @@ -429,7 +429,7 @@ class _HomePageState extends State { ## Enable ticks -You can enable ticks in the range slider using the [`showTicks`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/showTicks.html) property. +You can enable ticks in the Flutter Range Slider using the [`showTicks`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/showTicks.html) property. ### Horizontal @@ -476,7 +476,7 @@ class _HomePageState extends State { {% endhighlight %} {% endtabs %} -![Numeric range slider](images/getting-started/range_slider_with_tick.png) +![Numeric Flutter Range Slider](images/getting-started/range_slider_with_tick.png) ### Vertical @@ -525,9 +525,9 @@ class _HomePageState extends State { ![Numeric range slider](images/getting-started/vertical_range_slider_with_tick.png) -## Inverse the horizontal range slider +## Inverse the horizontal Range Slider -You can invert the horizontal range slider by wrapping the range slider in the [`Directionality`](https://api.flutter.dev/flutter/widgets/Directionality-class.html) widget and setting the [`textDirection`](https://api.flutter.dev/flutter/widgets/Directionality/textDirection.html) property to `TextDirection.rtl`. The [`Directionality`](https://api.flutter.dev/flutter/widgets/Directionality-class.html) widget only affects horizontal sliders; to invert a vertical range slider, use the [`isInversed`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/isInversed.html) property described in the [Inverse the vertical range slider](#inverse-the-vertical-range-slider) section. +You can invert the horizontal range slider by wrapping the Flutter Range Slider in the [`Directionality`](https://api.flutter.dev/flutter/widgets/Directionality-class.html) widget and setting the [`textDirection`](https://api.flutter.dev/flutter/widgets/Directionality/textDirection.html) property to `TextDirection.rtl`. The [`Directionality`](https://api.flutter.dev/flutter/widgets/Directionality-class.html) widget only affects horizontal sliders; to invert a vertical range slider, use the [`isInversed`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/isInversed.html) property described in the [Inverse the vertical range slider](#inverse-the-vertical-range-slider) section. {% tabs %} {% highlight Dart %} @@ -569,9 +569,9 @@ class _HomePageState extends State { {% endhighlight %} {% endtabs %} -![Inversed horizontal range slider](images/getting-started/inversed_horizontal_range_slider.png) +![Inversed horizontal Range Slider](images/getting-started/inversed_horizontal_range_slider.png) -## Inverse the vertical range slider +## Inverse the vertical Flutter Range Slider You can invert the vertical range slider using the [`isInversed`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/isInversed.html) property. The default value of the [`isInversed`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/isInversed.html) property is `false`. @@ -613,13 +613,13 @@ class _HomePageState extends State { {% endhighlight %} {% endtabs %} -![Inversed vertical range slider](images/getting-started/inversed_vertical_range_slider.png) +![Inversed vertical Range Slider](images/getting-started/inversed_vertical_range_slider.png) ## Add prefix/suffix to labels You can add prefix or suffix to the labels using the [`numberFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/numberFormat.html) or [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/dateFormat.html) properties. -N> The format type (numeric or date) of the range slider is determined based on the values specified in [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html), [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) and [`values`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/values.html) properties. +N> The format type (numeric or date) of the Flutter Range Slider is determined based on the values specified in [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html), [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) and [`values`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/values.html) properties. I> You must import [`intl`](https://pub.dev/packages/intl) package for formatting date range slider using the [`DateFormat`](https://pub.dev/documentation/intl/latest/intl/DateFormat-class.html) class and for formatting numeric range slider using the [`NumberFormat`](https://pub.dev/documentation/intl/latest/intl/NumberFormat-class.html) class. diff --git a/Flutter/range-slider/interval.md b/Flutter/range-slider/interval.md index 872ee0832..38bbf34c3 100644 --- a/Flutter/range-slider/interval.md +++ b/Flutter/range-slider/interval.md @@ -12,9 +12,9 @@ This section explains how to set intervals for numeric and date range sliders. ## Numeric interval -Range slider elements like labels, ticks and dividers are rendered based on the [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/interval.html), [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html) and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) properties. The default value is `null`, and it must be greater than 0. +Flutter Range Slider elements like labels, ticks and dividers are rendered based on the [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/interval.html), [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html) and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) properties. The default value is `null`, and it must be greater than 0. -For example, if [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html) is 0.0 and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) is 10.0 and [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/interval.html) is 2.0, the range slider will render the labels, major ticks, and dividers at 0.0, 2.0, 4.0 and so on. +For example, if [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html) is 0.0 and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) is 10.0 and [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/interval.html) is 2.0, the Flutter Range Slider will render the labels, major ticks, and dividers at 0.0, 2.0, 4.0 and so on. ### Horizontal @@ -109,9 +109,9 @@ N> The type of date interval can range from years to seconds. It is mandatory for date [`SfRangeSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider-class.html). The default value of [`dateIntervalType`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/dateIntervalType.html) property is `null`. -For date values, the range slider does not have auto interval support. So, it is mandatory to set [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/interval.html), [`dateIntervalType`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/dateIntervalType.html), and [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/dateFormat.html) for date values. +For date values, the Flutter Range Slider does not have auto interval support. So, it is mandatory to set [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/interval.html), [`dateIntervalType`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/dateIntervalType.html), and [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/dateFormat.html) for date values. -For example, if [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html) is `DateTime(2000, 01, 01)` and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) is `DateTime(2005, 01, 01)` and [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/interval.html) is `1`, [`dateIntervalType`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/dateIntervalType.html) is `DateIntervalType.years`, [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/dateFormat.html) is `DateFormat.y()` then the range slider will render the labels, major ticks, and dividers at 2000, 2001, 2002 and so on. +For example, if [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html) is `DateTime(2000, 01, 01)` and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) is `DateTime(2005, 01, 01)` and [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/interval.html) is `1`, [`dateIntervalType`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/dateIntervalType.html) is `DateIntervalType.years`, [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/dateFormat.html) is `DateFormat.y()` then the Flutter Range Slider will render the labels, major ticks, and dividers at 2000, 2001, 2002 and so on. N> You must import [`intl`](https://pub.dev/packages/intl) package for formatting date range slider using the [`DateFormat`](https://pub.dev/documentation/intl/latest/intl/DateFormat-class.html) class. This applies to all the date-range code examples below. @@ -209,7 +209,7 @@ class _HomePageState extends State { ## Discrete selection for numeric values -You can move the thumbs in a discrete manner for numeric values using the [`stepSize`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/stepSize.html) property of the range slider. +You can move the thumbs in a discrete manner for numeric values using the [`stepSize`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/stepSize.html) property of the Flutter Range Slider. ### Horizontal @@ -301,7 +301,7 @@ class _HomePageState extends State { You can move the thumbs in a discrete manner for date values based on the value provided in the [`stepDuration`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/stepDuration.html) property of the range slider. -For example, if [min](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html) is `DateTime(2015, 01, 01)` and [max](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) is `DateTime(2020, 01, 01)` and [stepDuration](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/stepDuration.html) is `SliderStepDuration(years: 1, months: 6)`, the range slider will move the thumbs to `DateTime(2015, 01, 01)`, `DateTime(2016, 07, 01)`, `DateTime(2018, 01, 01)`, and `DateTime(2019, 07, 01)`. +For example, if [min](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html) is `DateTime(2015, 01, 01)` and [max](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) is `DateTime(2020, 01, 01)` and [stepDuration](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/stepDuration.html) is `SliderStepDuration(years: 1, months: 6)`, the Flutter Range Slider will move the thumbs to `DateTime(2015, 01, 01)`, `DateTime(2016, 07, 01)`, `DateTime(2018, 01, 01)`, and `DateTime(2019, 07, 01)`. ### Horizontal diff --git a/Flutter/range-slider/labels-and-divider.md b/Flutter/range-slider/labels-and-divider.md index 22aca8074..4d804fff4 100644 --- a/Flutter/range-slider/labels-and-divider.md +++ b/Flutter/range-slider/labels-and-divider.md @@ -8,7 +8,7 @@ documentation: ug --- # Labels in Flutter Range Slider (SfRangeSlider) -This section explains how to add labels and dividers to the range slider. +This section explains how to add labels and dividers to the Flutter Range Slider. ## Show labels @@ -54,7 +54,7 @@ class _HomePageState extends State { {% endhighlight %} {% endtabs %} -![Range slider label support](images/label-and-divider/show-labels.png) +![Range Slider label support](images/label-and-divider/show-labels.png) ### Vertical @@ -198,7 +198,7 @@ class _HomePageState extends State { ## Date format -The [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/dateFormat.html) property is used to format the date labels. It is mandatory for the date [`SfRangeSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider-class.html). For date values, the range slider does not have auto interval support. So, it is mandatory to set [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/interval.html), [`dateIntervalType`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/dateIntervalType.html), and [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/dateFormat.html) for date values. The default value of [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/dateFormat.html) property is `null`. +The [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/dateFormat.html) property is used to format the date labels. It is mandatory for the date [`SfRangeSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider-class.html). For date values, the Flutter Range Slider does not have auto interval support. So, it is mandatory to set [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/interval.html), [`dateIntervalType`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/dateIntervalType.html), and [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/dateFormat.html) for date values. The default value of [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/dateFormat.html) property is `null`. N> You must import [`intl`](https://pub.dev/packages/intl) package for formatting date range slider using the [`DateFormat`](https://pub.dev/documentation/intl/latest/intl/DateFormat-class.html) class. This applies to all the date format code examples below. @@ -586,7 +586,7 @@ class _HomePageState extends State { ## Edge label placement -The [`edgeLabelPlacement`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/edgeLabelPlacement.html) property determines how the edge (first and last) labels are positioned on the range slider. This property allows the edge labels to be placed either inside the major ticks or directly on the major ticks. +The [`edgeLabelPlacement`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/edgeLabelPlacement.html) property determines how the edge (first and last) labels are positioned on the Flutter Range Slider. This property allows the edge labels to be placed either inside the major ticks or directly on the major ticks. The default value of [`edgeLabelPlacement`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/edgeLabelPlacement.html) property is `EdgeLabelPlacement.auto`. @@ -789,11 +789,11 @@ class _HomePageState extends State { ## Label style -You can change the active and inactive label appearance of the range slider using the [`activeLabelStyle`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeLabelStyle.html) and [`inactiveLabelStyle`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveLabelStyle.html) properties respectively. +You can change the active and inactive label appearance of the Flutter Range Slider using the [`activeLabelStyle`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeLabelStyle.html) and [`inactiveLabelStyle`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveLabelStyle.html) properties respectively. -The active side of the range slider is between the start and end thumbs. +The active side of the Flutter Range Slider is between the start and end thumbs. -The inactive side of the range slider is between the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html) value and the start thumb, and the end thumb and the [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) value. +The inactive side of the Flutter Range Slider is between the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html) value and the start thumb, and the end thumb and the [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) value. For RTL, the inactive side is between the [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) value and the start thumb, and the end thumb and the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html) value. @@ -1143,7 +1143,7 @@ class _HomePageState extends State { The [`showDividers`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/showDividers.html) property is used to render the dividers on the track. The default value of [`showDividers`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/showDividers.html) property is `false`. It is a shape which is used to mark the major interval points on the track. -For example, if [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html) is 0.0 and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) is 10.0 and [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/interval.html) is 2.0, the range slider will render the dividers at 0.0, 2.0, 4.0 and so on. +For example, if [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html) is 0.0 and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) is 10.0 and [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/interval.html) is 2.0, the Flutter Range Slider will render the dividers at 0.0, 2.0, 4.0 and so on. N> The examples in the divider sections below use `SfRangeSliderThemeData`. You must import the `theme.dart` library from the [`Core`](https://pub.dev/packages/syncfusion_flutter_core) package to use [`SfRangeSliderTheme`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfRangeSliderTheme-class.html). @@ -1193,7 +1193,7 @@ class _HomePageState extends State { {% endhighlight %} {% endtabs %} -![Range slider divider support](images/label-and-divider/show-divider.png) +![Range Slider divider support](images/label-and-divider/show-divider.png) ### Vertical @@ -1245,7 +1245,7 @@ class _HomePageState extends State { ## Divider radius -You can change the active and inactive divider radius of the range slider using the [`activeDividerRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeDividerRadius.html) and the [`inactiveDividerRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveDividerRadius.html) properties respectively. +You can change the active and inactive divider radius of the Flutter Range Slider using the [`activeDividerRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeDividerRadius.html) and the [`inactiveDividerRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveDividerRadius.html) properties respectively. ### Horizontal @@ -1351,7 +1351,7 @@ class _HomePageState extends State { You can change the active and inactive divider stroke width of the range slider using the [`activeDividerStrokeWidth`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeDividerStrokeWidth.html) and the [`inactiveDividerStrokeWidth`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveDividerStrokeWidth.html) properties respectively. -Also, you can change the active and inactive divider stroke color of the range slider using the [`activeDividerStrokeColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeDividerStrokeColor.html) and the [`inactiveDividerStrokeColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveDividerStrokeColor.html) properties respectively. +Also, you can change the active and inactive divider stroke color of the Flutter Range Slider using the [`activeDividerStrokeColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeDividerStrokeColor.html) and the [`inactiveDividerStrokeColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveDividerStrokeColor.html) properties respectively. ### Horizontal diff --git a/Flutter/range-slider/overview.md b/Flutter/range-slider/overview.md index 044725cb7..16383597c 100644 --- a/Flutter/range-slider/overview.md +++ b/Flutter/range-slider/overview.md @@ -11,7 +11,7 @@ documentation: ug Syncfusion® Flutter Range Slider is a highly interactive UI widget that allows users to select a smaller range from a larger data set. It provides rich features such as numeric and date values, labels, ticks, dividers, and tooltips. -![Range slider overview](images/overview/range-slider-overview.png) +![Range Slider overview](images/overview/range-slider-overview.png) ## Features diff --git a/Flutter/range-slider/right-to-left.md b/Flutter/range-slider/right-to-left.md index f3af5f5ba..2b16072be 100644 --- a/Flutter/range-slider/right-to-left.md +++ b/Flutter/range-slider/right-to-left.md @@ -15,7 +15,7 @@ Right-to-left rendering can be achieved in the following ways: ### Wrapping the SfRangeSlider with Directionality widget -The range slider can be wrapped inside the [`Directionality`](https://api.flutter.dev/flutter/widgets/Directionality-class.html) widget and you can set the [`textDirection`](https://api.flutter.dev/flutter/widgets/Directionality/textDirection.html) property to `rtl`. +The Flutter Range Slider can be wrapped inside the [`Directionality`](https://api.flutter.dev/flutter/widgets/Directionality-class.html) widget and you can set the [`textDirection`](https://api.flutter.dev/flutter/widgets/Directionality/textDirection.html) property to `rtl`. {% tabs %} {% highlight Dart %} @@ -124,6 +124,6 @@ class _HomePageState extends State { {% endhighlight %} {% endtabs %} -N> This RTL support is not applicable for the vertical orientation of the range slider. +N> This RTL support is not applicable for the vertical orientation of the Flutter Range Slider. ![RTL support](images/right-to-left/right-to-left-support.png) \ No newline at end of file diff --git a/Flutter/range-slider/shapes.md b/Flutter/range-slider/shapes.md index 1a38fb1ec..86ffd3410 100644 --- a/Flutter/range-slider/shapes.md +++ b/Flutter/range-slider/shapes.md @@ -1,385 +1,385 @@ ---- -layout: post -title: Custom Shapes in Flutter Range Slider | Syncfusion® -description: Learn about custom shapes in Syncfusion® Flutter Range Slider (SfRangeSlider), including track, thumb, divider, tick, and tooltip customization. -platform: flutter -control: SfRangeSlider -documentation: ug ---- - -# Custom Shapes in Flutter Range Slider (SfRangeSlider) - -This section explains how to customize the shapes of the range slider elements. - -## Track shape - -You can change the size and shape of the track using the [`trackShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/trackShape.html) property in the [`SfRangeSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider-class.html). - -* getPreferredSize() - Returns the size based on the values passed to it. -* paint() - Used to change the track shape. - -N> -* For the [`SfSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider-class.html), use the `thumbCenter` and `currentValue` parameters of the `paint` override method when customizing the track. -* For the [`SfRangeSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider-class.html) and `SfRangeSelector`, use the `startThumbCenter`, `endThumbCenter`, and `currentValues` parameters of the `paint` override method when customizing the track. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class HomePage extends StatefulWidget { - @override - _HomePageState createState() => _HomePageState(); -} - -class _HomePageState extends State { - SfRangeValues _values = const SfRangeValues(3.0, 7.0); - - @override - Widget build(BuildContext context) { - return Scaffold( - body: SfRangeSliderTheme( - data: const SfRangeSliderThemeData( - activeTrackHeight: 10, - inactiveTrackHeight: 10, - ), - child: SfRangeSlider( - min: 0.0, - max: 10.0, - values: _values, - trackShape: _TrackShape(), - onChanged: (SfRangeValues newValues) { - setState(() { - _values = newValues; - }); - }, - ), - ), - ); - } -} - -class _TrackShape extends SfTrackShape { - @override - void paint(PaintingContext context, Offset offset, Offset? thumbCenter, - Offset? startThumbCenter, Offset? endThumbCenter, - {required RenderBox parentBox, - required SfSliderThemeData themeData, - SfRangeValues? currentValues, - dynamic currentValue, - required Animation enableAnimation, - required Paint? inactivePaint, - required Paint? activePaint, - required TextDirection textDirection}) { - Paint paint = Paint() - ..color = themeData.activeTrackColor! - ..style = PaintingStyle.stroke - ..strokeWidth = 1; - super.paint(context, offset, thumbCenter, startThumbCenter, endThumbCenter, - parentBox: parentBox, - themeData: themeData, - enableAnimation: enableAnimation, - inactivePaint: inactivePaint, - activePaint: paint, - textDirection: textDirection); - } -} - -{% endhighlight %} -{% endtabs %} - -![Track shape](images/shapes/track-shape.png) - -## Thumb shape - -You can change the size and shape of the thumb using the [`thumbShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/thumbShape.html) property in the [`SfRangeSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider-class.html). - -* getPreferredSize() - Returns the size based on the values passed to it. -* paint() - Used to change the thumb shape. - -N> -* For the [`SfSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider-class.html), use the `currentValue` parameter of the `paint` override method when customizing the thumb. -* For the [`SfRangeSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider-class.html) and `SfRangeSelector`, use the `currentValues` parameter of the `paint` override method when customizing the thumbs. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class HomePage extends StatefulWidget { - @override - _HomePageState createState() => _HomePageState(); -} - -class _HomePageState extends State { - final double _min = 0.0; - final double _max = 10.0; - SfRangeValues _values = const SfRangeValues(2.0, 6.0); - - @override - Widget build(BuildContext context) { - return Scaffold( - body: SfRangeSlider( - min: _min, - max: _max, - values: _values, - thumbShape: _SfThumbShape(), - onChanged: (SfRangeValues newValues) { - setState(() { - _values = newValues; - }); - }, - ), - ); - } -} - -class _SfThumbShape extends SfThumbShape { - @override - void paint(PaintingContext context, Offset center, - {required RenderBox parentBox, - required RenderBox? child, - required SfSliderThemeData themeData, - SfRangeValues? currentValues, - dynamic currentValue, - required Paint? paint, - required Animation enableAnimation, - required TextDirection textDirection, - required SfThumb? thumb}) { - final Path path = Path(); - - path.moveTo(center.dx, center.dy); - path.lineTo(center.dx + 10, center.dy - 15); - path.lineTo(center.dx - 10, center.dy - 15); - path.close(); - context.canvas.drawPath( - path, - Paint() - ..color = themeData.activeTrackColor! - ..style = PaintingStyle.fill - ..strokeWidth = 2); - } -} - -{% endhighlight %} -{% endtabs %} - -![Thumb shape](images/shapes/thumb-shape.png) - -## Divider shape - -You can change the size and shape of the divider using the [`dividerShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/dividerShape.html) property in the [`SfRangeSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider-class.html). - -* getPreferredSize() - Returns the size based on the values passed to it. -* paint() - Used to change the divider shape. - -N> -* For the [`SfSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider-class.html), use the `thumbCenter` and `currentValue` parameters of the `paint` override method when customizing the divider. -* For the [`SfRangeSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider-class.html) and `SfRangeSelector`, use the `startThumbCenter`, `endThumbCenter`, and `currentValues` parameters of the `paint` override method when customizing the divider. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class HomePage extends StatefulWidget { - @override - _HomePageState createState() => _HomePageState(); -} - -class _HomePageState extends State { - SfRangeValues _values = const SfRangeValues(2.0, 6.0); - - @override - Widget build(BuildContext context) { - return Scaffold( - body: SfRangeSlider( - min: 0.0, - max: 10.0, - values: _values, - interval: 1, - showDividers: true, - dividerShape: _DividerShape(), - onChanged: (SfRangeValues newValues) { - setState(() { - _values = newValues; - }); - }, - ), - ); - } -} - -class _DividerShape extends SfDividerShape { - @override - void paint(PaintingContext context, Offset center, Offset? thumbCenter, - Offset? startThumbCenter, Offset? endThumbCenter, - {required RenderBox parentBox, - required SfSliderThemeData themeData, - SfRangeValues? currentValues, - dynamic currentValue, - required Paint? paint, - required Animation enableAnimation, - required TextDirection textDirection}) { - final bool isActive = - center.dx >= startThumbCenter!.dx && center.dx <= endThumbCenter!.dx; - context.canvas.drawRect( - Rect.fromCenter(center: center, width: 5.0, height: 10.0), - Paint() - ..isAntiAlias = true - ..style = PaintingStyle.fill - ..color = isActive ? themeData.activeTrackColor! : Colors.white); - } -} - -{% endhighlight %} -{% endtabs %} - -![Divider shape](images/shapes/divider-shape.png) - -## Major and minor ticks shapes - -You can change the size and shape of the major and minor ticks using the [`tickShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/tickShape.html) and [`minorTickShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/minorTickShape.html) properties in the [`SfRangeSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider-class.html). - -* getPreferredSize() - Returns the size based on the values passed to it. -* paint() - Used to change the ticks shape. - -N> -* For the [`SfSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider-class.html), use the `thumbCenter` and `currentValue` parameters of the `paint` override method when customizing the ticks. -* For the [`SfRangeSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider-class.html) and `SfRangeSelector`, use the `startThumbCenter`, `endThumbCenter`, and `currentValues` parameters of the `paint` override method when customizing the ticks. - -{% tabs %} -{% highlight Dart %} - -import 'dart:math' as math; - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class HomePage extends StatefulWidget { - @override - _HomePageState createState() => _HomePageState(); -} - -class _HomePageState extends State { - SfRangeValues _values = const SfRangeValues(2.0, 6.0); - - @override - Widget build(BuildContext context) { - return Scaffold( - body: SfRangeSlider( - min: 0.0, - max: 10.0, - values: _values, - interval: 1, - showTicks: true, - minorTicksPerInterval: 3, - tickShape: _TickShape(), - minorTickShape: _MinorTickShape(), - onChanged: (SfRangeValues newValues) { - setState(() { - _values = newValues; - }); - }, - ), - ); - } -} - -class _TickShape extends SfTickShape { - @override - void paint(PaintingContext context, Offset offset, Offset? thumbCenter, - Offset? startThumbCenter, Offset? endThumbCenter, - {required RenderBox parentBox, - required SfSliderThemeData themeData, - SfRangeValues? currentValues, - dynamic currentValue, - required Animation enableAnimation, - required TextDirection textDirection}) { - final Size tickSize = getPreferredSize(themeData); - final bool isTickRightOfThumb = endThumbCenter == null - ? offset.dx > thumbCenter!.dx - : offset.dx < startThumbCenter!.dx || offset.dx > endThumbCenter.dx; - final Color begin = isTickRightOfThumb - ? themeData.disabledInactiveTickColor - : themeData.disabledActiveTickColor; - final Color end = isTickRightOfThumb - ? themeData.inactiveTickColor - : themeData.activeTickColor; - final Paint paint = Paint() - ..isAntiAlias = true - ..strokeWidth = tickSize.width - ..color = ColorTween(begin: begin, end: end).evaluate(enableAnimation)!; - context.canvas.drawLine( - offset, Offset(offset.dx, offset.dy + tickSize.height), paint); - context.canvas.drawLine( - Offset( - offset.dx, - offset.dy - - 2 - - math.max(themeData.activeTrackHeight, - themeData.inactiveTrackHeight)), - Offset( - offset.dx, - offset.dy - - 2 - - math.max(themeData.activeTrackHeight, - themeData.inactiveTrackHeight) - - tickSize.height), - paint); - } -} - -class _MinorTickShape extends SfTickShape { - @override - void paint(PaintingContext context, Offset offset, Offset? thumbCenter, - Offset? startThumbCenter, Offset? endThumbCenter, - {required RenderBox parentBox, - required SfSliderThemeData themeData, - SfRangeValues? currentValues, - dynamic currentValue, - required Animation enableAnimation, - required TextDirection textDirection}) { - final Size minorTickSize = getPreferredSize(themeData); - final bool isMinorTickRightOfThumb = endThumbCenter == null - ? offset.dx > thumbCenter!.dx - : offset.dx < startThumbCenter!.dx || offset.dx > endThumbCenter.dx; - - final Color begin = isMinorTickRightOfThumb - ? themeData.disabledInactiveMinorTickColor - : themeData.disabledActiveMinorTickColor; - final Color end = isMinorTickRightOfThumb - ? themeData.inactiveMinorTickColor - : themeData.activeMinorTickColor; - final Paint paint = Paint() - ..isAntiAlias = true - ..strokeWidth = minorTickSize.width - ..color = ColorTween(begin: begin, end: end).evaluate(enableAnimation)!; - context.canvas.drawLine( - offset, Offset(offset.dx, offset.dy + minorTickSize.height), paint); - context.canvas.drawLine( - Offset( - offset.dx, - offset.dy - - 2 - - math.max(themeData.activeTrackHeight, - themeData.inactiveTrackHeight)), - Offset( - offset.dx, - offset.dy - - 2 - - math.max(themeData.activeTrackHeight, - themeData.inactiveTrackHeight) - - minorTickSize.height), - paint); - } -} - -{% endhighlight %} -{% endtabs %} - +--- +layout: post +title: Custom Shapes in Flutter Range Slider | Syncfusion® +description: Learn about custom shapes in Syncfusion® Flutter Range Slider (SfRangeSlider), including track, thumb, divider, tick, and tooltip customization. +platform: flutter +control: SfRangeSlider +documentation: ug +--- + +# Custom Shapes in Flutter Range Slider (SfRangeSlider) + +This section explains how to customize the shapes of the Flutter Range Slider elements. + +## Track shape + +You can change the size and shape of the track using the [`trackShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/trackShape.html) property in the [`SfRangeSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider-class.html). + +* getPreferredSize() - Returns the size based on the values passed to it. +* paint() - Used to change the track shape. + +N> +* For the [`SfSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider-class.html), use the `thumbCenter` and `currentValue` parameters of the `paint` override method when customizing the track. +* For the [`SfRangeSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider-class.html) and `SfRangeSelector`, use the `startThumbCenter`, `endThumbCenter`, and `currentValues` parameters of the `paint` override method when customizing the track. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class HomePage extends StatefulWidget { + @override + _HomePageState createState() => _HomePageState(); +} + +class _HomePageState extends State { + SfRangeValues _values = const SfRangeValues(3.0, 7.0); + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SfRangeSliderTheme( + data: const SfRangeSliderThemeData( + activeTrackHeight: 10, + inactiveTrackHeight: 10, + ), + child: SfRangeSlider( + min: 0.0, + max: 10.0, + values: _values, + trackShape: _TrackShape(), + onChanged: (SfRangeValues newValues) { + setState(() { + _values = newValues; + }); + }, + ), + ), + ); + } +} + +class _TrackShape extends SfTrackShape { + @override + void paint(PaintingContext context, Offset offset, Offset? thumbCenter, + Offset? startThumbCenter, Offset? endThumbCenter, + {required RenderBox parentBox, + required SfSliderThemeData themeData, + SfRangeValues? currentValues, + dynamic currentValue, + required Animation enableAnimation, + required Paint? inactivePaint, + required Paint? activePaint, + required TextDirection textDirection}) { + Paint paint = Paint() + ..color = themeData.activeTrackColor! + ..style = PaintingStyle.stroke + ..strokeWidth = 1; + super.paint(context, offset, thumbCenter, startThumbCenter, endThumbCenter, + parentBox: parentBox, + themeData: themeData, + enableAnimation: enableAnimation, + inactivePaint: inactivePaint, + activePaint: paint, + textDirection: textDirection); + } +} + +{% endhighlight %} +{% endtabs %} + +![Track shape](images/shapes/track-shape.png) + +## Thumb shape + +You can change the size and shape of the thumb using the [`thumbShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/thumbShape.html) property in the [`SfRangeSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider-class.html). + +* getPreferredSize() - Returns the size based on the values passed to it. +* paint() - Used to change the thumb shape. + +N> +* For the [`SfSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider-class.html), use the `currentValue` parameter of the `paint` override method when customizing the thumb. +* For the [`SfRangeSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider-class.html) and `SfRangeSelector`, use the `currentValues` parameter of the `paint` override method when customizing the thumbs. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class HomePage extends StatefulWidget { + @override + _HomePageState createState() => _HomePageState(); +} + +class _HomePageState extends State { + final double _min = 0.0; + final double _max = 10.0; + SfRangeValues _values = const SfRangeValues(2.0, 6.0); + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SfRangeSlider( + min: _min, + max: _max, + values: _values, + thumbShape: _SfThumbShape(), + onChanged: (SfRangeValues newValues) { + setState(() { + _values = newValues; + }); + }, + ), + ); + } +} + +class _SfThumbShape extends SfThumbShape { + @override + void paint(PaintingContext context, Offset center, + {required RenderBox parentBox, + required RenderBox? child, + required SfSliderThemeData themeData, + SfRangeValues? currentValues, + dynamic currentValue, + required Paint? paint, + required Animation enableAnimation, + required TextDirection textDirection, + required SfThumb? thumb}) { + final Path path = Path(); + + path.moveTo(center.dx, center.dy); + path.lineTo(center.dx + 10, center.dy - 15); + path.lineTo(center.dx - 10, center.dy - 15); + path.close(); + context.canvas.drawPath( + path, + Paint() + ..color = themeData.activeTrackColor! + ..style = PaintingStyle.fill + ..strokeWidth = 2); + } +} + +{% endhighlight %} +{% endtabs %} + +![Thumb shape](images/shapes/thumb-shape.png) + +## Divider shape + +You can change the size and shape of the divider using the [`dividerShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/dividerShape.html) property in the [`SfRangeSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider-class.html). + +* getPreferredSize() - Returns the size based on the values passed to it. +* paint() - Used to change the divider shape. + +N> +* For the [`SfSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider-class.html), use the `thumbCenter` and `currentValue` parameters of the `paint` override method when customizing the divider. +* For the [`SfRangeSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider-class.html) and `SfRangeSelector`, use the `startThumbCenter`, `endThumbCenter`, and `currentValues` parameters of the `paint` override method when customizing the divider. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class HomePage extends StatefulWidget { + @override + _HomePageState createState() => _HomePageState(); +} + +class _HomePageState extends State { + SfRangeValues _values = const SfRangeValues(2.0, 6.0); + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SfRangeSlider( + min: 0.0, + max: 10.0, + values: _values, + interval: 1, + showDividers: true, + dividerShape: _DividerShape(), + onChanged: (SfRangeValues newValues) { + setState(() { + _values = newValues; + }); + }, + ), + ); + } +} + +class _DividerShape extends SfDividerShape { + @override + void paint(PaintingContext context, Offset center, Offset? thumbCenter, + Offset? startThumbCenter, Offset? endThumbCenter, + {required RenderBox parentBox, + required SfSliderThemeData themeData, + SfRangeValues? currentValues, + dynamic currentValue, + required Paint? paint, + required Animation enableAnimation, + required TextDirection textDirection}) { + final bool isActive = + center.dx >= startThumbCenter!.dx && center.dx <= endThumbCenter!.dx; + context.canvas.drawRect( + Rect.fromCenter(center: center, width: 5.0, height: 10.0), + Paint() + ..isAntiAlias = true + ..style = PaintingStyle.fill + ..color = isActive ? themeData.activeTrackColor! : Colors.white); + } +} + +{% endhighlight %} +{% endtabs %} + +![Divider shape](images/shapes/divider-shape.png) + +## Major and minor ticks shapes + +You can change the size and shape of the major and minor ticks using the [`tickShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/tickShape.html) and [`minorTickShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/minorTickShape.html) properties in the [`SfRangeSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider-class.html). + +* getPreferredSize() - Returns the size based on the values passed to it. +* paint() - Used to change the ticks shape. + +N> +* For the [`SfSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider-class.html), use the `thumbCenter` and `currentValue` parameters of the `paint` override method when customizing the ticks. +* For the [`SfRangeSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider-class.html) and `SfRangeSelector`, use the `startThumbCenter`, `endThumbCenter`, and `currentValues` parameters of the `paint` override method when customizing the ticks. + +{% tabs %} +{% highlight Dart %} + +import 'dart:math' as math; + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class HomePage extends StatefulWidget { + @override + _HomePageState createState() => _HomePageState(); +} + +class _HomePageState extends State { + SfRangeValues _values = const SfRangeValues(2.0, 6.0); + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SfRangeSlider( + min: 0.0, + max: 10.0, + values: _values, + interval: 1, + showTicks: true, + minorTicksPerInterval: 3, + tickShape: _TickShape(), + minorTickShape: _MinorTickShape(), + onChanged: (SfRangeValues newValues) { + setState(() { + _values = newValues; + }); + }, + ), + ); + } +} + +class _TickShape extends SfTickShape { + @override + void paint(PaintingContext context, Offset offset, Offset? thumbCenter, + Offset? startThumbCenter, Offset? endThumbCenter, + {required RenderBox parentBox, + required SfSliderThemeData themeData, + SfRangeValues? currentValues, + dynamic currentValue, + required Animation enableAnimation, + required TextDirection textDirection}) { + final Size tickSize = getPreferredSize(themeData); + final bool isTickRightOfThumb = endThumbCenter == null + ? offset.dx > thumbCenter!.dx + : offset.dx < startThumbCenter!.dx || offset.dx > endThumbCenter.dx; + final Color begin = isTickRightOfThumb + ? themeData.disabledInactiveTickColor + : themeData.disabledActiveTickColor; + final Color end = isTickRightOfThumb + ? themeData.inactiveTickColor + : themeData.activeTickColor; + final Paint paint = Paint() + ..isAntiAlias = true + ..strokeWidth = tickSize.width + ..color = ColorTween(begin: begin, end: end).evaluate(enableAnimation)!; + context.canvas.drawLine( + offset, Offset(offset.dx, offset.dy + tickSize.height), paint); + context.canvas.drawLine( + Offset( + offset.dx, + offset.dy - + 2 - + math.max(themeData.activeTrackHeight, + themeData.inactiveTrackHeight)), + Offset( + offset.dx, + offset.dy - + 2 - + math.max(themeData.activeTrackHeight, + themeData.inactiveTrackHeight) - + tickSize.height), + paint); + } +} + +class _MinorTickShape extends SfTickShape { + @override + void paint(PaintingContext context, Offset offset, Offset? thumbCenter, + Offset? startThumbCenter, Offset? endThumbCenter, + {required RenderBox parentBox, + required SfSliderThemeData themeData, + SfRangeValues? currentValues, + dynamic currentValue, + required Animation enableAnimation, + required TextDirection textDirection}) { + final Size minorTickSize = getPreferredSize(themeData); + final bool isMinorTickRightOfThumb = endThumbCenter == null + ? offset.dx > thumbCenter!.dx + : offset.dx < startThumbCenter!.dx || offset.dx > endThumbCenter.dx; + + final Color begin = isMinorTickRightOfThumb + ? themeData.disabledInactiveMinorTickColor + : themeData.disabledActiveMinorTickColor; + final Color end = isMinorTickRightOfThumb + ? themeData.inactiveMinorTickColor + : themeData.activeMinorTickColor; + final Paint paint = Paint() + ..isAntiAlias = true + ..strokeWidth = minorTickSize.width + ..color = ColorTween(begin: begin, end: end).evaluate(enableAnimation)!; + context.canvas.drawLine( + offset, Offset(offset.dx, offset.dy + minorTickSize.height), paint); + context.canvas.drawLine( + Offset( + offset.dx, + offset.dy - + 2 - + math.max(themeData.activeTrackHeight, + themeData.inactiveTrackHeight)), + Offset( + offset.dx, + offset.dy - + 2 - + math.max(themeData.activeTrackHeight, + themeData.inactiveTrackHeight) - + minorTickSize.height), + paint); + } +} + +{% endhighlight %} +{% endtabs %} + ![Ticks shape](images/shapes/ticks-shape.png) \ No newline at end of file diff --git a/Flutter/range-slider/thumb-and-overlay.md b/Flutter/range-slider/thumb-and-overlay.md index 22b8abc00..976645374 100644 --- a/Flutter/range-slider/thumb-and-overlay.md +++ b/Flutter/range-slider/thumb-and-overlay.md @@ -9,16 +9,16 @@ documentation: ug # Thumb and Thumb Overlay in Flutter Range Slider (SfRangeSlider) -This section explains how to customize the thumb and thumb overlay in the range slider. +This section explains how to customize the thumb and thumb overlay in the Flutter Range Slider. -* Thumb - It is one of the elements of range slider which can be used to drag and change the selected values of the range slider. +* Thumb - It is one of the elements of Flutter Range Slider which can be used to drag and change the selected values of the Range Slider. * Thumb overlay - It is rendered around the thumb while interacting with it. N> You must import the `theme.dart` library from the [`Core`](https://pub.dev/packages/syncfusion_flutter_core) package to use [`SfRangeSliderTheme`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfRangeSliderTheme-class.html). This applies to all the code examples in this section except the [Thumb icon](#thumb-icon) section, which uses properties exposed directly on `SfRangeSlider`. ## Thumb size -You can change the size of the thumb in the range slider using the [`thumbRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/thumbRadius.html) property. +You can change the size of the thumb in the Flutter Range Slider using the [`thumbRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/thumbRadius.html) property. ### Horizontal @@ -434,7 +434,7 @@ class _HomePageState extends State { ## Thumb overlay size -You can change the size of the thumb overlay in the range slider using the [`overlayRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/overlayRadius.html) property. +You can change the size of the thumb overlay in the Flutter Range Slider using the [`overlayRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/overlayRadius.html) property. ### Horizontal @@ -634,7 +634,7 @@ class _HomePageState extends State { ## Thumb overlap stroke color -You can change the overlap stroke color of the thumb in the range slider using the [`overlappingThumbStrokeColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfRangeSliderThemeData/overlappingThumbStrokeColor.html) property. +You can change the overlap stroke color of the thumb in the Flutter Range Slider using the [`overlappingThumbStrokeColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfRangeSliderThemeData/overlappingThumbStrokeColor.html) property. ### Horizontal diff --git a/Flutter/range-slider/ticks.md b/Flutter/range-slider/ticks.md index 0baf4fe5c..22031a4a8 100644 --- a/Flutter/range-slider/ticks.md +++ b/Flutter/range-slider/ticks.md @@ -9,13 +9,13 @@ documentation: ug # Ticks in Flutter Range Slider (SfRangeSlider) -This section explains how to add major and minor ticks in the range slider. +This section explains how to add major and minor ticks in the Flutter Range Slider. ## Show major ticks You can enable the major ticks on the track. It is a shape which is used to mark the major interval points on the track. The default value of [`showTicks`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/showTicks.html) property is `false`. -For example, if [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html) is 0.0 and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) is 10.0 and [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/interval.html) is 2.0, the range slider will render the major ticks at 0.0, 2.0, 4.0 and so on. +For example, if [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html) is 0.0 and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) is 10.0 and [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/interval.html) is 2.0, the Flutter Range Slider will render the major ticks at 0.0, 2.0, 4.0 and so on. ### Horizontal @@ -57,7 +57,7 @@ class _HomePageState extends State { {% endhighlight %} {% endtabs %} -![Range slider tick support](images/tick/major-tick.png) +![Range Slider tick support](images/tick/major-tick.png) ### Vertical @@ -105,7 +105,7 @@ N> Refer the [`tickShape`](https://pub.dev/documentation/syncfusion_flutter_slid ## Show minor ticks -It is used to represent the number of smaller ticks between two major ticks. For example, if [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html) is 0.0 and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) is 10.0 and [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/interval.html) is 2.0, the range slider will render the major ticks at 0.0, 2.0, 4.0 and so on. If [`minorTicksPerInterval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/minorTicksPerInterval.html) is 1, then smaller ticks will be rendered on 1.0 and 3.0 and so on. +It is used to represent the number of smaller ticks between two major ticks. For example, if [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html) is 0.0 and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) is 10.0 and [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/interval.html) is 2.0, the Flutter Range Slider will render the major ticks at 0.0, 2.0, 4.0 and so on. If [`minorTicksPerInterval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/minorTicksPerInterval.html) is 1, then smaller ticks will be rendered on 1.0 and 3.0 and so on. I> The default value of [`minorTicksPerInterval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/minorTicksPerInterval.html) property is `null`. When `null`, no minor ticks are rendered. To render minor ticks, set this property to a value greater than `0`. @@ -150,7 +150,7 @@ class _HomePageState extends State { {% endhighlight %} {% endtabs %} -![Range slider minor tick support](images/tick/minor-tick.png) +![Range Slider minor tick support](images/tick/minor-tick.png) ### Vertical @@ -201,11 +201,11 @@ N> ## Major ticks color -You can change the active and inactive major ticks color of the range slider using the [`activeTickColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeTickColor.html) and [`inactiveTickColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveTickColor.html) properties respectively. +You can change the active and inactive major ticks color of the Flutter Range Slider using the [`activeTickColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeTickColor.html) and [`inactiveTickColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveTickColor.html) properties respectively. -The active side of the range slider is between the start and end thumbs. +The active side of the Flutter Range Slider is between the start and end thumbs. -The inactive side of the range slider is between the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html) value and the start thumb, and the end thumb and the [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) value. +The inactive side of the Flutter Range Slider is between the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html) value and the start thumb, and the end thumb and the [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) value. For RTL, the inactive side is between the [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) value and the start thumb, and the end thumb and the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html) value. @@ -309,11 +309,11 @@ class _HomePageState extends State { ## Minor ticks color -You can change the active and inactive minor ticks color of the range slider using the [`activeMinorTickColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeMinorTickColor.html) and [`inactiveMinorTickColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveMinorTickColor.html) properties respectively. +You can change the active and inactive minor ticks color of the Flutter Range Slider using the [`activeMinorTickColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeMinorTickColor.html) and [`inactiveMinorTickColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveMinorTickColor.html) properties respectively. -The active side of the range slider is between the start and end thumbs. +The active side of the Flutter Range Slider is between the start and end thumbs. -The inactive side of the range slider is between the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html) value and the start thumb, and the end thumb and the [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) value. +The inactive side of the Flutter Range Slider is between the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html) value and the start thumb, and the end thumb and the [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) value. For RTL, the inactive side is between the [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) value and the start thumb, and the end thumb and the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html) value. @@ -417,7 +417,7 @@ class _HomePageState extends State { ## Tick size -You can change the major and minor ticks size of the range slider using the [`tickSize`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/tickSize.html) and [`minorTickSize`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/minorTickSize.html) properties respectively. +You can change the major and minor ticks size of the Flutter Range Slider using the [`tickSize`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/tickSize.html) and [`minorTickSize`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/minorTickSize.html) properties respectively. ### Horizontal diff --git a/Flutter/range-slider/tooltip.md b/Flutter/range-slider/tooltip.md index f35b3a0fa..1aa4f4699 100644 --- a/Flutter/range-slider/tooltip.md +++ b/Flutter/range-slider/tooltip.md @@ -9,7 +9,7 @@ documentation: ug # Tooltip in Flutter Range Slider (SfRangeSlider) -This section explains how to add tooltips to the range slider. +This section explains how to add tooltips to the Flutter Range Slider. ## Enable tooltips @@ -58,7 +58,7 @@ class _HomePageState extends State { {% endhighlight %} {% endtabs %} -![Range slider tooltip support](images/tooltip/show-tooltip.png) +![Range Slider tooltip support](images/tooltip/show-tooltip.png) ### Vertical @@ -155,7 +155,7 @@ class _HomePageState extends State { {% endhighlight %} {% endtabs %} -![Range slider tooltip shape](images/tooltip/range-tooltip-shape.png) +![Range Slider tooltip shape](images/tooltip/range-tooltip-shape.png) ## Tooltip position @@ -203,7 +203,7 @@ class _HomePageState extends State { {% endhighlight %} {% endtabs %} -![Range slider tooltip shape](images/tooltip/range-right-tooltip-shape.png) +![Range Slider tooltip shape](images/tooltip/range-right-tooltip-shape.png) ## Tooltip text format @@ -318,7 +318,7 @@ class _HomePageState extends State { ## Tooltip color -You can change the background color of the tooltip in the range slider using the [`tooltipBackgroundColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/tooltipBackgroundColor.html) property. +You can change the background color of the tooltip in the Flutter Range Slider using the [`tooltipBackgroundColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/tooltipBackgroundColor.html) property. N> You must import the `theme.dart` library from the [`Core`](https://pub.dev/packages/syncfusion_flutter_core) package to use [`SfRangeSliderTheme`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfRangeSliderTheme-class.html). This applies to all the remaining code examples in this section that use `SfRangeSliderThemeData`. @@ -422,7 +422,7 @@ class _HomePageState extends State { ## Tooltip label style -You can change the appearance of the tooltip text in the range slider using the [`tooltipTextStyle`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/tooltipTextStyle.html) property. +You can change the appearance of the tooltip text in the Flutter Range Slider using the [`tooltipTextStyle`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/tooltipTextStyle.html) property. ### Horizontal @@ -526,7 +526,7 @@ class _HomePageState extends State { ## Tooltip overlap stroke color -You can change the overlap stroke color of the tooltip in the range slider using the [`overlappingTooltipStrokeColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfRangeSliderThemeData/overlappingTooltipStrokeColor.html) property. +You can change the overlap stroke color of the tooltip in the Flutter Range Slider using the [`overlappingTooltipStrokeColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfRangeSliderThemeData/overlappingTooltipStrokeColor.html) property. ### Horizontal diff --git a/Flutter/range-slider/track.md b/Flutter/range-slider/track.md index cf0064d2f..3b43c108f 100644 --- a/Flutter/range-slider/track.md +++ b/Flutter/range-slider/track.md @@ -9,15 +9,15 @@ documentation: ug # Track in Flutter Range Slider (SfRangeSlider) -This section explains how to customize the track in the range slider. +This section explains how to customize the track in the Flutter Range Slider. ## Track color -You can change the active and inactive track color of the range slider using the [`activeTrackColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeTrackColor.html) and [`inactiveTrackColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveTrackColor.html) properties respectively. +You can change the active and inactive track color of the Flutter Range Slider using the [`activeTrackColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeTrackColor.html) and [`inactiveTrackColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveTrackColor.html) properties respectively. -The active side of the range slider is between the start and end thumbs. +The active side of the Flutter Range Slider is between the start and end thumbs. -The inactive side of the range slider is between the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html) value and the start thumb, and the end thumb and the [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) value. +The inactive side of the Flutter Range Slider is between the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html) value and the start thumb, and the end thumb and the [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) value. For RTL, the inactive side is between the [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/max.html) value and the start thumb, and the end thumb and the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRangeSlider/min.html) value. @@ -117,7 +117,7 @@ class _HomePageState extends State { ## Track height -You can change the track height of the range slider using the [`activeTrackHeight`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeTrackHeight.html) and the [`inactiveTrackHeight`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveTrackHeight.html) properties. The default values of the [`activeTrackHeight`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeTrackHeight.html) and the [`inactiveTrackHeight`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveTrackHeight.html) properties are `6.0` and `4.0`. +You can change the track height of the Flutter Range Slider using the [`activeTrackHeight`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeTrackHeight.html) and the [`inactiveTrackHeight`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveTrackHeight.html) properties. The default values of the [`activeTrackHeight`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeTrackHeight.html) and the [`inactiveTrackHeight`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveTrackHeight.html) properties are `6.0` and `4.0`. ### Horizontal @@ -213,7 +213,7 @@ class _HomePageState extends State { ## Track corner radius -You can change the corner of the track to be round in the range slider using the [`trackCornerRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/trackCornerRadius.html) property. The default value of the [`trackCornerRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/trackCornerRadius.html) property is `1.0`. +You can change the corner of the track to be round in the Flutter Range Slider using the [`trackCornerRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/trackCornerRadius.html) property. The default value of the [`trackCornerRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/trackCornerRadius.html) property is `1.0`. ### Horizontal diff --git a/Flutter/signaturepad/accessibility.md b/Flutter/signaturepad/accessibility.md index a32dd49f0..7362d6fd1 100644 --- a/Flutter/signaturepad/accessibility.md +++ b/Flutter/signaturepad/accessibility.md @@ -1,53 +1,53 @@ ---- -layout: post -title: Accessibility in Flutter SignaturePad | Syncfusion® -description: Learn about accessibility support in Syncfusion® Flutter SignaturePad (SfSignaturePad), including screen readers, keyboard navigation, and more. -platform: flutter -control: SfSignaturePad -documentation: ug ---- - -# Accessibility in Flutter SignaturePad (SfSignaturePad) - -## Screen reader - -The [`SfSignaturePad`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePad-class.html) can be accessed by screen readers by wrapping the [`SfSignaturePad`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePad-class.html) widget with the [`Semantics`](https://api.flutter.dev/flutter/widgets/Semantics-class.html) widget. - -{% tabs %} -{% highlight Dart %} - -@override -Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: Semantics( - label: 'Syncfusion Flutter SignaturePad', - hint: 'Mark your signature in this', - child: Container( - child: SfSignaturePad( - strokeColor: Colors.black, - backgroundColor: Colors.white, - maximumStrokeWidth: 5, - minimumStrokeWidth: 1, - ), - width: 200, - height: 200, - ), - ), - ), - ); -} - -{% endhighlight %} -{% endtabs %} - -## Sufficient contrast - -You can customize the colors of the [`SfSignaturePad`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePad-class.html) using the following APIs to ensure sufficient contrast: - -* [`Background`](https://help.syncfusion.com/flutter/signaturepad/getting-started#initialize-signaturepad) -* [`Stroke`](https://help.syncfusion.com/flutter/signaturepad/getting-started#customize-signature-stroke-color) - -## Easier touch targets - -The [`SfSignaturePad`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePad-class.html) has a touch target size of 48 × 48 pixels, which meets accessibility standards. +--- +layout: post +title: Accessibility in Flutter SignaturePad | Syncfusion® +description: Learn about accessibility support in Syncfusion® Flutter SignaturePad (SfSignaturePad), including screen readers, keyboard navigation, and more. +platform: flutter +control: SfSignaturePad +documentation: ug +--- + +# Accessibility in Flutter Signature Pad (SfSignaturePad) + +## Screen reader + +The [`SfSignaturePad`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePad-class.html) can be accessed by screen readers by wrapping the [`SfSignaturePad`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePad-class.html) widget with the [`Semantics`](https://api.flutter.dev/flutter/widgets/Semantics-class.html) widget. + +{% tabs %} +{% highlight Dart %} + +@override +Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Semantics( + label: 'Syncfusion Flutter SignaturePad', + hint: 'Mark your signature in this', + child: Container( + child: SfSignaturePad( + strokeColor: Colors.black, + backgroundColor: Colors.white, + maximumStrokeWidth: 5, + minimumStrokeWidth: 1, + ), + width: 200, + height: 200, + ), + ), + ), + ); +} + +{% endhighlight %} +{% endtabs %} + +## Sufficient contrast + +You can customize the colors of the [`SfSignaturePad`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePad-class.html) using the following APIs to ensure sufficient contrast: + +* [`Background`](https://help.syncfusion.com/flutter/signaturepad/getting-started#initialize-signaturepad) +* [`Stroke`](https://help.syncfusion.com/flutter/signaturepad/getting-started#customize-signature-stroke-color) + +## Easier touch targets + +The [`SfSignaturePad`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePad-class.html) has a touch target size of 48 × 48 pixels, which meets accessibility standards. diff --git a/Flutter/signaturepad/getting-started.md b/Flutter/signaturepad/getting-started.md index 4908b6e26..609d75b0d 100644 --- a/Flutter/signaturepad/getting-started.md +++ b/Flutter/signaturepad/getting-started.md @@ -7,16 +7,16 @@ control: SfSignaturePad documentation: ug --- -# Getting Started with Flutter SignaturePad (SfSignaturePad) +# Getting Started with Flutter Signature Pad (SfSignaturePad) -This section explains the steps required to add the SignaturePad widget and its elements such as minimum and maximum stroke widths, stroke color, and background color. This section also covers how to save the signature as an image, clear the existing signature in SignaturePad, and handle the [`onDrawStart`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePad/onDrawStart.html), [`onDraw`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePad/onDraw.html), and [`onDrawEnd`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePad/onDrawEnd.html) callbacks in the SignaturePad widget. +This section explains the steps required to add the Flutter Signature Pad widget and its elements such as minimum and maximum stroke widths, stroke color, and background color. This section also covers how to save the signature as an image, clear the existing signature in Signature Pad, and handle the [`onDrawStart`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePad/onDrawStart.html), [`onDraw`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePad/onDraw.html), and [`onDrawEnd`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePad/onDrawEnd.html) callbacks in the Flutter Signature Pad widget. -To get started quickly with our Flutter SignaturePad widget, you can watch this video: +To get started quickly with our Flutter Signature Pad widget, you can watch this video: -## Add Flutter SignaturePad to an application +## Add Flutter Signature Pad to an application Create a simple project using the instructions given in the [Getting Started with your first Flutter app](https://docs.flutter.dev/get-started/test-drive#choose-your-ide) documentation. @@ -56,9 +56,9 @@ import 'package:syncfusion_flutter_signaturepad/signaturepad.dart'; {% endhighlight %} {% endtabs %} -## Initialize SignaturePad +## Initialize Signature Pad -After importing the package, initialize the SignaturePad widget as a child of any widget. Here, the SignaturePad widget is added as a child of the Container widget to get a position and size. Also, a background color is applied to show the SignaturePad widget with a white background. The default [`backgroundColor`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePad/backgroundColor.html) is `Colors.transparent`. +After importing the package, initialize the Flutter Signature Pad widget as a child of any widget. Here, the Signature Pad widget is added as a child of the Container widget to get a position and size. Also, a background color is applied to show the Signature Pad widget with a white background. The default [`backgroundColor`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePad/backgroundColor.html) is `Colors.transparent`. {% tabs %} {% highlight dart %} @@ -86,11 +86,11 @@ class SignaturePadExample extends StatelessWidget { {% endhighlight %} {% endtabs %} -![Flutter SignaturePad](images/getting-started/blank_signature_pad.PNG) +![Flutter Signature Pad](images/getting-started/blank_signature_pad.PNG) ## Customize signature stroke color -You can customize the stroke color of the SignaturePad widget by using the [`strokeColor`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePad/strokeColor.html) property. The default stroke color for the dark theme is `Colors.white` and the default color for the light theme is `Colors.black`. +You can customize the stroke color of the Flutter Signature Pad widget by using the [`strokeColor`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePad/strokeColor.html) property. The default stroke color for the dark theme is `Colors.white` and the default color for the light theme is `Colors.black`. {% tabs %} {% highlight dart %} @@ -154,7 +154,7 @@ class SignaturePadExample extends StatelessWidget { ## Save signatures as images in mobile and desktop platforms -You can save the signature drawn in the SignaturePad as an image using the [`toImage()`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePadState/toImage.html) method as shown in the code example below for Android, iOS, and desktop platforms. Since this [`toImage()`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePadState/toImage.html) method is defined in the state object of SignaturePad, you have to use a global key assigned to the SignaturePad instance to call this method. Optionally, the `pixelRatio` parameter may be used to set the pixel ratio of the image. The higher the pixel ratio value, the higher quality image you get. The default value of the pixel ratio parameter is 1. +You can save the signature drawn in the Signature Pad as an image using the [`toImage()`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePadState/toImage.html) method as shown in the code example below for Android, iOS, and desktop platforms. Since this [`toImage()`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePadState/toImage.html) method is defined in the state object of Flutter Signature Pad, you have to use a global key assigned to the Signature Pad instance to call this method. Optionally, the `pixelRatio` parameter may be used to set the pixel ratio of the image. The higher the pixel ratio value, the higher quality image you get. The default value of the pixel ratio parameter is 1. {% tabs %} {% highlight dart %} @@ -248,7 +248,7 @@ class _SignaturePadExampleState extends State { ## Save signatures as images in web (mobile browser) -You can save the signature drawn in the SignaturePad as an image using the [`renderToContext2D`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePadState/renderToContext2D.html) method as shown in the code snippet below. Since this [`renderToContext2D()`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePadState/renderToContext2D.html) method is defined in the state object of SignaturePad, you have to use a global key assigned to the SignaturePad instance to call this method. +You can save the signature drawn in the Flutter Signature Pad as an image using the [`renderToContext2D`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePadState/renderToContext2D.html) method as shown in the code snippet below. Since this [`renderToContext2D()`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePadState/renderToContext2D.html) method is defined in the state object of SignaturePad, you have to use a global key assigned to the SignaturePad instance to call this method. {% tabs %} {% highlight dart %} @@ -307,9 +307,9 @@ class _SignaturePadExampleState extends State { N> Since Flutter uses two separate default web renderers, here we have two different code snippets to convert signatures to images in desktop and mobile browsers. Please refer to this Flutter [`web-renderers`](https://docs.flutter.dev/development/tools/web-renderers) page for more details. -## Clear the existing signature in SignaturePad +## Clear the existing signature in Signature Pad -You can clear the signature drawn in the SignaturePad using the [`clear()`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePadState/clear.html) method as shown in the code snippet below. Since this [`clear()`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePadState/clear.html) method is defined in the state object of SignaturePad, you have to use a global key assigned to the SignaturePad instance to call this method. +You can clear the signature drawn in the Flutter Signature Pad using the [`clear()`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePadState/clear.html) method as shown in the code snippet below. Since this [`clear()`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePadState/clear.html) method is defined in the state object of SignaturePad, you have to use a global key assigned to the SignaturePad instance to call this method. {% tabs %} {% highlight dart %} @@ -355,7 +355,8 @@ class _SignaturePadExampleState extends State { ## Signature path collection -You can get the path collection of the signature drawn in the SignaturePad using the [`toPathList()`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePadState/toPathList.html) method. Since this [`toPathList()`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePadState/toPathList.html) method is defined in the state object of SignaturePad, you have to use a global key assigned to the SignaturePad instance to call this method. +You can get the path collection of the signature drawn in the Flutter Signature +Pad using the [`toPathList()`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePadState/toPathList.html) method. Since this [`toPathList()`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePadState/toPathList.html) method is defined in the state object of SignaturePad, you have to use a global key assigned to the SignaturePad instance to call this method. {% tabs %} {% highlight dart %} @@ -402,7 +403,7 @@ class _SignaturePadExampleState extends State { ## Handle onDrawStart, onDraw, and onDrawEnd callbacks -The widget allows you to handle the [`onDrawStart`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePad/onDrawStart.html), [`onDraw`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePad/onDraw.html), and [`onDrawEnd`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePad/onDrawEnd.html) callbacks for every stroke updated to the SignaturePad. The [`onDrawStart`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePad/onDrawStart.html) callback will be called when the user starts signing on `SfSignaturePad`, the [`onDraw`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePad/onDraw.html) callback will be called when updating a stroke on the [`SfSignaturePad`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePad/SfSignaturePad.html), and the [`onDrawEnd`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePad/onDrawEnd.html) callback will be called when the user completes signing on [`SfSignaturePad`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePad/SfSignaturePad.html). +The widget allows you to handle the [`onDrawStart`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePad/onDrawStart.html), [`onDraw`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePad/onDraw.html), and [`onDrawEnd`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePad/onDrawEnd.html) callbacks for every stroke updated to the Flutter Signature Pad. The [`onDrawStart`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePad/onDrawStart.html) callback will be called when the user starts signing on `SfSignaturePad`, the [`onDraw`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePad/onDraw.html) callback will be called when updating a stroke on the [`SfSignaturePad`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePad/SfSignaturePad.html), and the [`onDrawEnd`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePad/onDrawEnd.html) callback will be called when the user completes signing on [`SfSignaturePad`](https://pub.dev/documentation/syncfusion_flutter_signaturepad/latest/signaturepad/SfSignaturePad/SfSignaturePad.html). {% tabs %} {% highlight dart %} diff --git a/Flutter/signaturepad/how-to/custom-widget-on-flutterflow.md b/Flutter/signaturepad/how-to/custom-widget-on-flutterflow.md index 4afd52588..1c642e54c 100644 --- a/Flutter/signaturepad/how-to/custom-widget-on-flutterflow.md +++ b/Flutter/signaturepad/how-to/custom-widget-on-flutterflow.md @@ -7,7 +7,7 @@ control: SfSignaturePad documentation: ug --- -# How to Add SignaturePad in FlutterFlow (SfSignaturePad) +# How to Add Signature Pad in FlutterFlow (SfSignaturePad) ## Overview @@ -28,7 +28,7 @@ Navigate to the [FlutterFlow dashboard](https://app.flutterflow.io/dashboard) an ![Custom Widget](how-to-section-images/custom-widget.png) -### Add SignaturePad widget as a dependency +### Add Signature Pad widget as a dependency 1. Click on `+ Add Dependency`, and a text editor will appear. 2. Navigate to [Syncfusion® Flutter SignaturePad](https://pub.dev/packages/syncfusion_flutter_signaturepad) in [pub.dev](https://pub.dev/) and copy the dependency name and version using the `Copy to Clipboard` option. diff --git a/Flutter/signaturepad/overview.md b/Flutter/signaturepad/overview.md index c29763ec8..92569ad21 100644 --- a/Flutter/signaturepad/overview.md +++ b/Flutter/signaturepad/overview.md @@ -7,14 +7,14 @@ control: SfSignaturePad documentation: ug --- -# About Flutter SignaturePad Control (SfSignaturePad) +# About Flutter Signature Pad Control (SfSignaturePad) -The SignaturePad is a widget for capturing smooth and realistic signatures. This widget allows you to save signatures as images and sync them across devices and documents that need signatures. You can use your finger, pen, or mouse on a tablet, touchscreen, or other input device to draw your own signature on this SignaturePad widget. +The Flutter Signature Pad is a widget for capturing smooth and realistic signatures. This widget allows you to save signatures as images and sync them across devices and documents that need signatures. You can use your finger, pen, or mouse on a tablet, touchscreen, or other input device to draw your own signature on this Signature Pad widget. ## Features * **Signature stroke color customization** - The widget allows you to set the stroke color for the signatures. * **Signature stroke width customization** - The widget allows you to set the minimum and maximum stroke widths for the signatures. -* **SignaturePad background color customization** - The widget allows you to set the background color for the SignaturePad. +* **SignaturePad background color customization** - The widget allows you to set the background color for the Flutter Signature Pad. * **Save as image** - The widget provides an option to save the drawn signature as an image. This converted image can be embedded in documents, PDFs, and anything else that supports using images to denote a signature. * **More realistic handwritten look and feel** - The unique stroke rendering algorithm draws a signature based on the speed of the drawn gestures along with minimum and maximum stroke thicknesses, which brings a more realistic, handwritten look and feel to the signature. diff --git a/Flutter/slider/basic-features.md b/Flutter/slider/basic-features.md index 60ebeaf80..fb2074803 100644 --- a/Flutter/slider/basic-features.md +++ b/Flutter/slider/basic-features.md @@ -1,606 +1,606 @@ ---- -layout: post -title: Basic Features in Flutter Slider | Syncfusion® -description: Learn about the basic features of Syncfusion® Flutter Slider (SfSlider), including values, ranges, callbacks, customization, and date sliders. -platform: flutter -control: SfSlider -documentation: ug ---- - -# Basic Features in Flutter Slider (SfSlider) -This section explains how to add and configure numeric and date sliders, core properties, and callbacks. - -## Minimum - -The minimum value that the user can select. The default value of [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html) property is 0.0 and it must be less than the [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) value. - -## Maximum - -The maximum value that the user can select. The default value of [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) property is 1.0 and it must be greater than the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html) value. - -## Value - -It represents the value currently selected in the slider. The slider's thumb is drawn corresponding to this value. - -For date values, the slider does not have auto interval support. So, it is mandatory to set [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/interval.html), [`dateIntervalType`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/dateIntervalType.html), and [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/dateFormat.html) for date values. - -**Numeric slider** - -You can show numeric values in the slider by setting `double` values to the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html), [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) and [`value`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/value.html) properties. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class NumericSliderPage extends StatefulWidget { - @override - _NumericSliderPageState createState() => _NumericSliderPageState(); -} - -class _NumericSliderPageState extends State { - double _value = 4.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider( - min: 0.0, - max: 10.0, - value: _value, - interval: 2, - showLabels: true, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Numeric slider](images/basic-features/numeric-labels.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalNumericSliderPage extends StatefulWidget { - @override - _VerticalNumericSliderPageState createState() => _VerticalNumericSliderPageState(); -} - -class _VerticalNumericSliderPageState extends State { - double _value = 4.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider.vertical( - min: 0.0, - max: 10.0, - value: _value, - interval: 2, - showLabels: true, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Numeric slider](images/basic-features/vertical_numeric_labels.png) - -**Date slider** - -You can show date values in the slider by setting `DateTime` values to the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html), [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) and [`value`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/value.html) properties. - -N> You must import [`intl`](https://pub.dev/packages/intl) package for formatting date slider using the [`DateFormat`](https://pub.dev/documentation/intl/latest/intl/DateFormat-class.html) class. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class DateSliderPage extends StatefulWidget { - @override - _DateSliderPageState createState() => _DateSliderPageState(); -} - -class _DateSliderPageState extends State { - DateTime _value = DateTime(2002, 01, 01); - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider( - min: DateTime(2000, 01, 01, 00), - max: DateTime(2004, 12, 31, 24), - value: _value, - interval: 1, - showLabels: true, - dateFormat: DateFormat.y(), - dateIntervalType: DateIntervalType.years, - onChanged: (DateTime newValue) { - setState(() { - _value = newValue; - }); - }, - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Date slider](images/basic-features/date-labels.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalDateSliderPage extends StatefulWidget { - @override - _VerticalDateSliderPageState createState() => _VerticalDateSliderPageState(); -} - -class _VerticalDateSliderPageState extends State { - DateTime _value = DateTime(2002, 01, 01); - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider.vertical( - min: DateTime(2000, 01, 01, 00), - max: DateTime(2004, 12, 31, 24), - value: _value, - interval: 1, - showLabels: true, - dateFormat: DateFormat.y(), - dateIntervalType: DateIntervalType.years, - onChanged: (DateTime newValue) { - setState(() { - _value = newValue; - }); - }, - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Date slider](images/basic-features/vertical_date_labels.png) - -## Handle onChangeStart, onChanged, and onChangeEnd callbacks - -**onChangeStart** - -The [`onChangeStart`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/onChangeStart.html) callback is called when the user begins to interact with the slider using a tap or drag action. This callback is only used to notify the user that the interaction has started and it does not change the value of the slider thumb. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class OnChangeStartPage extends StatefulWidget { - @override - _OnChangeStartPageState createState() => _OnChangeStartPageState(); -} - -class _OnChangeStartPageState extends State { - double _value = 4.0; - - @override - Widget build(BuildContext context) { - return Scaffold( - body: SfSlider( - min: 0.0, - max: 10.0, - value: _value, - onChangeStart: (double startValue) { - debugPrint('Interaction started'); - }, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ); - } -} - -{% endhighlight %} -{% endtabs %} - -**onChangeEnd** - -The [`onChangeEnd`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/onChangeEnd.html) callback is called when the user stops interacting with the slider using a tap or drag action. This callback is only used to notify the user that the interaction has ended and it does not change the value of the slider thumb. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class OnChangeEndPage extends StatefulWidget { - @override - _OnChangeEndPageState createState() => _OnChangeEndPageState(); -} - -class _OnChangeEndPageState extends State { - double _value = 4.0; - - @override - Widget build(BuildContext context) { - return Scaffold( - body: SfSlider( - min: 0.0, - max: 10.0, - value: _value, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - onChangeEnd: (double endValue) { - debugPrint('Interaction ended'); - }, - ), - ); - } -} - -{% endhighlight %} -{% endtabs %} - -**onChanged** - -The [`onChanged`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/onChanged.html) callback is called when the user selects a value through interaction. - -N> The slider passes the new value to the callback but does not change its state until the parent widget rebuilds the slider with the new value. - -N> If it is null, the slider will be disabled. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class OnChangedPage extends StatefulWidget { - @override - _OnChangedPageState createState() => _OnChangedPageState(); -} - -class _OnChangedPageState extends State { - double _value = 4.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider( - min: 0.0, - max: 10.0, - value: _value, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Enable slider](images/basic-features/enabled-state.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalOnChangedPage extends StatefulWidget { - @override - _VerticalOnChangedPageState createState() => _VerticalOnChangedPageState(); -} - -class _VerticalOnChangedPageState extends State { - double _value = 4.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider.vertical( - min: 0.0, - max: 10.0, - value: _value, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Enable slider](images/basic-features/vertical_enabled_state.png) - -## Active color - -It represents the color applied to the active track, thumb, overlay, and inactive dividers. The active side of the slider is between the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html) value and the thumb. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class ActiveColorPage extends StatefulWidget { - @override - _ActiveColorPageState createState() => _ActiveColorPageState(); -} - -class _ActiveColorPageState extends State { - double _value = 4.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider( - min: 0.0, - max: 10.0, - value: _value, - interval: 2, - activeColor: Colors.red, - showDividers: true, - showTicks: true, - showLabels: true, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Active color support](images/basic-features/active-color.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalActiveColorPage extends StatefulWidget { - @override - _VerticalActiveColorPageState createState() => _VerticalActiveColorPageState(); -} - -class _VerticalActiveColorPageState extends State { - double _value = 4.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider.vertical( - min: 0.0, - max: 10.0, - value: _value, - interval: 2, - activeColor: Colors.red, - showDividers: true, - showTicks: true, - showLabels: true, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Active color support](images/basic-features/vertical_active_color.png) - -## Inactive color - -It represents the color applied to the inactive track and active dividers. - -The inactive side of the slider is between the thumb and the [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) value. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class InactiveColorPage extends StatefulWidget { - @override - _InactiveColorPageState createState() => _InactiveColorPageState(); -} - -class _InactiveColorPageState extends State { - double _value = 4.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider( - min: 0.0, - max: 10.0, - value: _value, - interval: 2, - activeColor: Colors.red, - inactiveColor: Colors.red.withValues(alpha: 0.2), - showDividers: true, - showTicks: true, - showLabels: true, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Inactive color support](images/basic-features/inactive-color.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalInactiveColorPage extends StatefulWidget { - @override - _VerticalInactiveColorPageState createState() => _VerticalInactiveColorPageState(); -} - -class _VerticalInactiveColorPageState extends State { - double _value = 4.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider.vertical( - min: 0.0, - max: 10.0, - value: _value, - interval: 2, - activeColor: Colors.red, - inactiveColor: Colors.red.withValues(alpha: 0.2), - showDividers: true, - showTicks: true, - showLabels: true, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Inactive color support](images/basic-features/vertical_inactive_color.png) - -### For customizing individual items - -* Track - [`Link`](https://help.syncfusion.com/flutter/slider/track) -* Ticks - [`Link`](https://help.syncfusion.com/flutter/slider/ticks) -* Labels and dividers - [`Link`](https://help.syncfusion.com/flutter/slider/labels-and-divider) -* Tooltip - [`Link`](https://help.syncfusion.com/flutter/slider/tooltip) -* Thumb and overlay - [`Link`](https://help.syncfusion.com/flutter/slider/thumb-and-overlay) - -To know more about how to customize both thumb and divider in the Flutter Slider, you can watch this video. - - +--- +layout: post +title: Basic Features in Flutter Slider | Syncfusion® +description: Learn about the basic features of Syncfusion® Flutter Slider (SfSlider), including values, ranges, callbacks, customization, and date sliders. +platform: flutter +control: SfSlider +documentation: ug +--- + +# Basic Features in Flutter Slider (SfSlider) +This section explains how to add and configure numeric and date sliders, core properties, and callbacks. + +## Minimum + +The minimum value that the user can select. The default value of [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html) property is 0.0 and it must be less than the [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) value. + +## Maximum + +The maximum value that the user can select. The default value of [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) property is 1.0 and it must be greater than the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html) value. + +## Value + +It represents the value currently selected in the slider. The slider's thumb is drawn corresponding to this value. + +For date values, the Flutter Slider does not have auto interval support. So, it is mandatory to set [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/interval.html), [`dateIntervalType`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/dateIntervalType.html), and [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/dateFormat.html) for date values. + +**Numeric slider** + +You can show numeric values in the Flutter Slider by setting `double` values to the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html), [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) and [`value`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/value.html) properties. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class NumericSliderPage extends StatefulWidget { + @override + _NumericSliderPageState createState() => _NumericSliderPageState(); +} + +class _NumericSliderPageState extends State { + double _value = 4.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider( + min: 0.0, + max: 10.0, + value: _value, + interval: 2, + showLabels: true, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Numeric slider](images/basic-features/numeric-labels.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalNumericSliderPage extends StatefulWidget { + @override + _VerticalNumericSliderPageState createState() => _VerticalNumericSliderPageState(); +} + +class _VerticalNumericSliderPageState extends State { + double _value = 4.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider.vertical( + min: 0.0, + max: 10.0, + value: _value, + interval: 2, + showLabels: true, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Numeric slider](images/basic-features/vertical_numeric_labels.png) + +**Date slider** + +You can show date values in the Flutter Slider by setting `DateTime` values to the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html), [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) and [`value`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/value.html) properties. + +N> You must import [`intl`](https://pub.dev/packages/intl) package for formatting date slider using the [`DateFormat`](https://pub.dev/documentation/intl/latest/intl/DateFormat-class.html) class. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class DateSliderPage extends StatefulWidget { + @override + _DateSliderPageState createState() => _DateSliderPageState(); +} + +class _DateSliderPageState extends State { + DateTime _value = DateTime(2002, 01, 01); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider( + min: DateTime(2000, 01, 01, 00), + max: DateTime(2004, 12, 31, 24), + value: _value, + interval: 1, + showLabels: true, + dateFormat: DateFormat.y(), + dateIntervalType: DateIntervalType.years, + onChanged: (DateTime newValue) { + setState(() { + _value = newValue; + }); + }, + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Date slider](images/basic-features/date-labels.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalDateSliderPage extends StatefulWidget { + @override + _VerticalDateSliderPageState createState() => _VerticalDateSliderPageState(); +} + +class _VerticalDateSliderPageState extends State { + DateTime _value = DateTime(2002, 01, 01); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider.vertical( + min: DateTime(2000, 01, 01, 00), + max: DateTime(2004, 12, 31, 24), + value: _value, + interval: 1, + showLabels: true, + dateFormat: DateFormat.y(), + dateIntervalType: DateIntervalType.years, + onChanged: (DateTime newValue) { + setState(() { + _value = newValue; + }); + }, + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Date slider](images/basic-features/vertical_date_labels.png) + +## Handle onChangeStart, onChanged, and onChangeEnd callbacks + +**onChangeStart** + +The [`onChangeStart`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/onChangeStart.html) callback is called when the user begins to interact with the slider using a tap or drag action. This callback is only used to notify the user that the interaction has started and it does not change the value of the slider thumb. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class OnChangeStartPage extends StatefulWidget { + @override + _OnChangeStartPageState createState() => _OnChangeStartPageState(); +} + +class _OnChangeStartPageState extends State { + double _value = 4.0; + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SfSlider( + min: 0.0, + max: 10.0, + value: _value, + onChangeStart: (double startValue) { + debugPrint('Interaction started'); + }, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ); + } +} + +{% endhighlight %} +{% endtabs %} + +**onChangeEnd** + +The [`onChangeEnd`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/onChangeEnd.html) callback is called when the user stops interacting with the slider using a tap or drag action. This callback is only used to notify the user that the interaction has ended and it does not change the value of the slider thumb. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class OnChangeEndPage extends StatefulWidget { + @override + _OnChangeEndPageState createState() => _OnChangeEndPageState(); +} + +class _OnChangeEndPageState extends State { + double _value = 4.0; + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SfSlider( + min: 0.0, + max: 10.0, + value: _value, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + onChangeEnd: (double endValue) { + debugPrint('Interaction ended'); + }, + ), + ); + } +} + +{% endhighlight %} +{% endtabs %} + +**onChanged** + +The [`onChanged`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/onChanged.html) callback is called when the user selects a value through interaction. + +N> The Flutter Slider passes the new value to the callback but does not change its state until the parent widget rebuilds the slider with the new value. + +N> If it is null, the Flutter Slider will be disabled. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class OnChangedPage extends StatefulWidget { + @override + _OnChangedPageState createState() => _OnChangedPageState(); +} + +class _OnChangedPageState extends State { + double _value = 4.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider( + min: 0.0, + max: 10.0, + value: _value, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Enable slider](images/basic-features/enabled-state.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalOnChangedPage extends StatefulWidget { + @override + _VerticalOnChangedPageState createState() => _VerticalOnChangedPageState(); +} + +class _VerticalOnChangedPageState extends State { + double _value = 4.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider.vertical( + min: 0.0, + max: 10.0, + value: _value, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Enable slider](images/basic-features/vertical_enabled_state.png) + +## Active color + +It represents the color applied to the active track, thumb, overlay, and inactive dividers. The active side of the Flutter Slider is between the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html) value and the thumb. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class ActiveColorPage extends StatefulWidget { + @override + _ActiveColorPageState createState() => _ActiveColorPageState(); +} + +class _ActiveColorPageState extends State { + double _value = 4.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider( + min: 0.0, + max: 10.0, + value: _value, + interval: 2, + activeColor: Colors.red, + showDividers: true, + showTicks: true, + showLabels: true, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Active color support](images/basic-features/active-color.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalActiveColorPage extends StatefulWidget { + @override + _VerticalActiveColorPageState createState() => _VerticalActiveColorPageState(); +} + +class _VerticalActiveColorPageState extends State { + double _value = 4.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider.vertical( + min: 0.0, + max: 10.0, + value: _value, + interval: 2, + activeColor: Colors.red, + showDividers: true, + showTicks: true, + showLabels: true, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Active color support](images/basic-features/vertical_active_color.png) + +## Inactive color + +It represents the color applied to the inactive track and active dividers. + +The inactive side of the Flutter Slider is between the thumb and the [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) value. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class InactiveColorPage extends StatefulWidget { + @override + _InactiveColorPageState createState() => _InactiveColorPageState(); +} + +class _InactiveColorPageState extends State { + double _value = 4.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider( + min: 0.0, + max: 10.0, + value: _value, + interval: 2, + activeColor: Colors.red, + inactiveColor: Colors.red.withValues(alpha: 0.2), + showDividers: true, + showTicks: true, + showLabels: true, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Inactive color support](images/basic-features/inactive-color.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalInactiveColorPage extends StatefulWidget { + @override + _VerticalInactiveColorPageState createState() => _VerticalInactiveColorPageState(); +} + +class _VerticalInactiveColorPageState extends State { + double _value = 4.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider.vertical( + min: 0.0, + max: 10.0, + value: _value, + interval: 2, + activeColor: Colors.red, + inactiveColor: Colors.red.withValues(alpha: 0.2), + showDividers: true, + showTicks: true, + showLabels: true, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Inactive color support](images/basic-features/vertical_inactive_color.png) + +### For customizing individual items + +* Track - [`Link`](https://help.syncfusion.com/flutter/slider/track) +* Ticks - [`Link`](https://help.syncfusion.com/flutter/slider/ticks) +* Labels and dividers - [`Link`](https://help.syncfusion.com/flutter/slider/labels-and-divider) +* Tooltip - [`Link`](https://help.syncfusion.com/flutter/slider/tooltip) +* Thumb and overlay - [`Link`](https://help.syncfusion.com/flutter/slider/thumb-and-overlay) + +To know more about how to customize both thumb and divider in the Flutter Slider, you can watch this video. + + \ No newline at end of file diff --git a/Flutter/slider/enabled-and-disabled-state.md b/Flutter/slider/enabled-and-disabled-state.md index 31b13df6e..ec5d88f15 100644 --- a/Flutter/slider/enabled-and-disabled-state.md +++ b/Flutter/slider/enabled-and-disabled-state.md @@ -1,304 +1,304 @@ ---- -layout: post -title: Enabled and Disabled States in Flutter Slider | Syncfusion® -description: Learn about enabled and disabled states in Syncfusion® Flutter Slider (SfSlider), including customization, appearance, and interaction behavior. -platform: flutter -control: SfSlider -documentation: ug ---- - -# Enabled and Disabled States in Flutter Slider (SfSlider) - -This section explains the enabled and disabled states in the Flutter slider. - -## Enabled state - -The slider will be in enabled state if [`onChanged`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/onChanged.html) is set. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class EnabledStatePage extends StatefulWidget { - @override - _EnabledStatePageState createState() => _EnabledStatePageState(); -} - -class _EnabledStatePageState extends State { - double _value = 5.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider( - min: 0.0, - max: 10.0, - value: _value, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Enabled state](images/enabled-and-disabled/enabled-state.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalEnabledStatePage extends StatefulWidget { - @override - _VerticalEnabledStatePageState createState() => _VerticalEnabledStatePageState(); -} - -class _VerticalEnabledStatePageState extends State { - double _value = 5.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider.vertical( - min: 0.0, - max: 10.0, - value: _value, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Enabled state](images/enabled-and-disabled/vertical-enabled-state.png) - - -## Disabled state - -The slider will be in disabled state if [`onChanged`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/onChanged.html) is `null`. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class DisabledStatePage extends StatefulWidget { - @override - _DisabledStatePageState createState() => _DisabledStatePageState(); -} - -class _DisabledStatePageState extends State { - double _value = 5.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider( - min: 0.0, - max: 10.0, - value: _value, - onChanged: null, - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Disabled slider](images/enabled-and-disabled/disabled-state.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalDisabledStatePage extends StatefulWidget { - @override - _VerticalDisabledStatePageState createState() => _VerticalDisabledStatePageState(); -} - -class _VerticalDisabledStatePageState extends State { - double _value = 5.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider.vertical( - min: 0.0, - max: 10.0, - value: _value, - onChanged: null, - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Disabled slider](images/enabled-and-disabled/vertical-disabled-state.png) - - -## Disabled color - -You can change the following: - -* The color of the active and inactive track in disabled state using the [`disabledActiveTrackColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/disabledActiveTrackColor.html) and [`disabledInactiveTrackColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/disabledInactiveTrackColor.html) properties. -* The color of the active and inactive major ticks in disabled state using the [`disabledActiveTickColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/disabledActiveTickColor.html) and [`disabledInactiveTickColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/disabledInactiveTickColor.html) properties. -* The color of the active and inactive minor ticks in disabled state using the [`disabledActiveMinorTickColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/disabledActiveMinorTickColor.html) and [`disabledInactiveMinorTickColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/disabledInactiveMinorTickColor.html) properties. -* The color of the active and inactive dividers in disabled state using the [`disabledActiveDividerColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/disabledActiveDividerColor.html) and [`disabledInactiveDividerColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/disabledInactiveDividerColor.html) properties. -* The color of the thumb in disabled state using the [`disabledThumbColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/disabledThumbColor.html) property. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class DisabledColorPage extends StatefulWidget { - @override - _DisabledColorPageState createState() => _DisabledColorPageState(); -} - -class _DisabledColorPageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - disabledActiveTrackColor: Colors.orange, - disabledInactiveTrackColor: Colors.orange[200], - disabledActiveTickColor: Colors.orange, - disabledInactiveTickColor: Colors.orange[200], - disabledActiveMinorTickColor: Colors.orange, - disabledInactiveMinorTickColor: Colors.orange[200], - disabledActiveDividerColor: Colors.purple, - disabledInactiveDividerColor: Colors.purple[200], - disabledThumbColor: Colors.orange, - ), - child: SfSlider( - min: 2.0, - max: 10.0, - interval: 2, - showTicks: true, - minorTicksPerInterval: 1, - showDividers: true, - value: _value, - onChanged: null, - ), - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Disabled color support](images/enabled-and-disabled/slider-disabled-color.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalDisabledColorPage extends StatefulWidget { - @override - _VerticalDisabledColorPageState createState() => _VerticalDisabledColorPageState(); -} - -class _VerticalDisabledColorPageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - disabledActiveTrackColor: Colors.orange, - disabledInactiveTrackColor: Colors.orange[200], - disabledActiveTickColor: Colors.orange, - disabledInactiveTickColor: Colors.orange[200], - disabledActiveMinorTickColor: Colors.orange, - disabledInactiveMinorTickColor: Colors.orange[200], - disabledActiveDividerColor: Colors.purple, - disabledInactiveDividerColor: Colors.purple[200], - disabledThumbColor: Colors.orange, - ), - child: SfSlider.vertical( - min: 2.0, - max: 10.0, - interval: 2, - showTicks: true, - minorTicksPerInterval: 1, - showDividers: true, - value: _value, - onChanged: null, - ), - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Disabled color support](images/enabled-and-disabled/vertical-slider-disabled-color.png) +--- +layout: post +title: Enabled and Disabled States in Flutter Slider | Syncfusion® +description: Learn about enabled and disabled states in Syncfusion® Flutter Slider (SfSlider), including customization, appearance, and interaction behavior. +platform: flutter +control: SfSlider +documentation: ug +--- + +# Enabled and Disabled States in Flutter Slider (SfSlider) + +This section explains the enabled and disabled states in the Flutter Flutter Slider. + +## Enabled state + +The slider will be in enabled state if [`onChanged`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/onChanged.html) is set. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class EnabledStatePage extends StatefulWidget { + @override + _EnabledStatePageState createState() => _EnabledStatePageState(); +} + +class _EnabledStatePageState extends State { + double _value = 5.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider( + min: 0.0, + max: 10.0, + value: _value, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Enabled state](images/enabled-and-disabled/enabled-state.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalEnabledStatePage extends StatefulWidget { + @override + _VerticalEnabledStatePageState createState() => _VerticalEnabledStatePageState(); +} + +class _VerticalEnabledStatePageState extends State { + double _value = 5.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider.vertical( + min: 0.0, + max: 10.0, + value: _value, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Enabled state](images/enabled-and-disabled/vertical-enabled-state.png) + + +## Disabled state + +The Flutter Slider will be in disabled state if [`onChanged`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/onChanged.html) is `null`. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class DisabledStatePage extends StatefulWidget { + @override + _DisabledStatePageState createState() => _DisabledStatePageState(); +} + +class _DisabledStatePageState extends State { + double _value = 5.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider( + min: 0.0, + max: 10.0, + value: _value, + onChanged: null, + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Disabled slider](images/enabled-and-disabled/disabled-state.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalDisabledStatePage extends StatefulWidget { + @override + _VerticalDisabledStatePageState createState() => _VerticalDisabledStatePageState(); +} + +class _VerticalDisabledStatePageState extends State { + double _value = 5.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider.vertical( + min: 0.0, + max: 10.0, + value: _value, + onChanged: null, + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Disabled Flutter Slider](images/enabled-and-disabled/vertical-disabled-state.png) + + +## Disabled color + +You can change the following: + +* The color of the active and inactive track in disabled state using the [`disabledActiveTrackColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/disabledActiveTrackColor.html) and [`disabledInactiveTrackColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/disabledInactiveTrackColor.html) properties. +* The color of the active and inactive major ticks in disabled state using the [`disabledActiveTickColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/disabledActiveTickColor.html) and [`disabledInactiveTickColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/disabledInactiveTickColor.html) properties. +* The color of the active and inactive minor ticks in disabled state using the [`disabledActiveMinorTickColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/disabledActiveMinorTickColor.html) and [`disabledInactiveMinorTickColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/disabledInactiveMinorTickColor.html) properties. +* The color of the active and inactive dividers in disabled state using the [`disabledActiveDividerColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/disabledActiveDividerColor.html) and [`disabledInactiveDividerColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/disabledInactiveDividerColor.html) properties. +* The color of the thumb in disabled state using the [`disabledThumbColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/disabledThumbColor.html) property. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class DisabledColorPage extends StatefulWidget { + @override + _DisabledColorPageState createState() => _DisabledColorPageState(); +} + +class _DisabledColorPageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + disabledActiveTrackColor: Colors.orange, + disabledInactiveTrackColor: Colors.orange[200], + disabledActiveTickColor: Colors.orange, + disabledInactiveTickColor: Colors.orange[200], + disabledActiveMinorTickColor: Colors.orange, + disabledInactiveMinorTickColor: Colors.orange[200], + disabledActiveDividerColor: Colors.purple, + disabledInactiveDividerColor: Colors.purple[200], + disabledThumbColor: Colors.orange, + ), + child: SfSlider( + min: 2.0, + max: 10.0, + interval: 2, + showTicks: true, + minorTicksPerInterval: 1, + showDividers: true, + value: _value, + onChanged: null, + ), + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Disabled color support](images/enabled-and-disabled/slider-disabled-color.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalDisabledColorPage extends StatefulWidget { + @override + _VerticalDisabledColorPageState createState() => _VerticalDisabledColorPageState(); +} + +class _VerticalDisabledColorPageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + disabledActiveTrackColor: Colors.orange, + disabledInactiveTrackColor: Colors.orange[200], + disabledActiveTickColor: Colors.orange, + disabledInactiveTickColor: Colors.orange[200], + disabledActiveMinorTickColor: Colors.orange, + disabledInactiveMinorTickColor: Colors.orange[200], + disabledActiveDividerColor: Colors.purple, + disabledInactiveDividerColor: Colors.purple[200], + disabledThumbColor: Colors.orange, + ), + child: SfSlider.vertical( + min: 2.0, + max: 10.0, + interval: 2, + showTicks: true, + minorTicksPerInterval: 1, + showDividers: true, + value: _value, + onChanged: null, + ), + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Disabled color support](images/enabled-and-disabled/vertical-slider-disabled-color.png) diff --git a/Flutter/slider/getting-started.md b/Flutter/slider/getting-started.md index c32b1952e..eb387a7c8 100644 --- a/Flutter/slider/getting-started.md +++ b/Flutter/slider/getting-started.md @@ -1,713 +1,713 @@ ---- -layout: post -title: Getting Started with Flutter Slider | Syncfusion® -description: Learn how to get started with the Syncfusion® Flutter Slider (SfSlider). Explore setup, slider configuration, and customization options. -platform: flutter -control: SfSlider -documentation: ug ---- - -# Getting Started with Flutter Slider (SfSlider) -This section explains the steps required to add the slider widget and its elements such as numeric and date values, ticks, labels, and tooltip. This section covers only basic features needed to get started with Syncfusion® slider. - -To get started quickly with our Flutter Slider widget, check out this video. - - - - -## Add Flutter slider to an application -Create a simple project using the instructions given in the [Getting Started with your first Flutter app](https://docs.flutter.dev/get-started/test-drive#choose-your-ide) documentation. - -**Add dependency** - -Add the Syncfusion® Flutter slider dependency to your pubspec.yaml file. - -{% tabs %} -{% highlight dart %} - -dependencies: - -syncfusion_flutter_sliders: ^xx.x.xx - -{% endhighlight %} -{% endtabs %} - -N> Here **xx.x.xx** denotes the current version of [`Syncfusion Flutter Sliders`](https://pub.dev/packages/syncfusion_flutter_sliders/versions) package. - -**Get packages** - -Run the following command to get the required packages. - -{% tabs %} -{% highlight dart %} - -flutter pub get - -{% endhighlight %} -{% endtabs %} - -**Import package** - -Import the following package in your Dart code. - -{% tabs %} -{% highlight dart %} - -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -{% endhighlight %} -{% endtabs %} - -## Initialize slider - -After importing the package, initialize the slider widget as a child of any widget. Here, the slider widget is added as a child of the Center widget. The default value of the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html) and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) properties of the [`SfSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider-class.html) are 0.0 and 1.0 respectively. So, the [`value`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/value.html) property must be given within the range. - -N> The slider passes the new value to the [`onChanged`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/onChanged.html) callback but does not change its state until the parent widget rebuilds the slider with the new value. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class HorizontalSliderPage extends StatefulWidget { - @override - _HorizontalSliderPageState createState() => _HorizontalSliderPageState(); -} - -class _HorizontalSliderPageState extends State { - double _value = 0.5; - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: SfSlider( - value: _value, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ), - ), - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Default slider](images/getting-started/default_slider.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalSliderPage extends StatefulWidget { - @override - _VerticalSliderPageState createState() => _VerticalSliderPageState(); -} - -class _VerticalSliderPageState extends State { - double _value = 0.5; - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: SfSlider.vertical( - value: _value, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ), - ), - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Default slider](images/getting-started/vertical_default_slider.png) - -## Handle value change - -The [`onChanged`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/onChanged.html) callback is used to get the current value of the slider when the user selects a value through interaction. - -N> The slider passes the new value to the callback but does not change its state until the parent widget rebuilds the slider with the new value. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class HorizontalHandleValuePage extends StatefulWidget { - @override - _HorizontalHandleValuePageState createState() => _HorizontalHandleValuePageState(); -} - -class _HorizontalHandleValuePageState extends State { - double _value = 5.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider( - min: 0.0, - max: 10.0, - value: _value, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Handle slider](images/getting-started/handle-slider-state.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalHandleValuePage extends StatefulWidget { - @override - _VerticalHandleValuePageState createState() => _VerticalHandleValuePageState(); -} - -class _VerticalHandleValuePageState extends State { - double _value = 5.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider.vertical( - min: 0.0, - max: 10.0, - value: _value, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Handle slider](images/getting-started/vertical_handle_slider_state.png) - -## Set numeric value - -You can show numeric values in the slider by setting `double` values to the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html), [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) and [`value`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/value.html) properties. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class NumericSliderPage extends StatefulWidget { - @override - _NumericSliderPageState createState() => _NumericSliderPageState(); -} - -class _NumericSliderPageState extends State { - final double _min = 0; - final double _max = 100; - double _value = 40.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider( - min: _min, - max: _max, - value: _value, - interval: 20, - showLabels: true, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Numeric slider](images/getting-started/numeric_slider.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalNumericSliderPage extends StatefulWidget { - @override - _VerticalNumericSliderPageState createState() => _VerticalNumericSliderPageState(); -} - -class _VerticalNumericSliderPageState extends State { - final double _min = 0; - final double _max = 100; - double _value = 40.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider.vertical( - min: _min, - max: _max, - value: _value, - interval: 20, - showLabels: true, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Numeric slider](images/getting-started/vertical_numeric_slider.png) - -## Set date value - -You can show date values in the slider by setting `DateTime` values to the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html), [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) and [`value`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/value.html) properties. - -N> You must import [`intl`](https://pub.dev/packages/intl) package for formatting date slider using the [`DateFormat`](https://pub.dev/documentation/intl/latest/intl/DateFormat-class.html) class. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class DateSliderPage extends StatefulWidget { - @override - _DateSliderPageState createState() => _DateSliderPageState(); -} - -class _DateSliderPageState extends State { - DateTime _min = DateTime(2008, 01, 01); - DateTime _max = DateTime(2018, 01, 01); - DateTime _value = DateTime(2012, 01, 01); - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: SfSlider( - min: _min, - max: _max, - value: _value, - interval: 2, - showLabels: true, - dateIntervalType: DateIntervalType.years, - dateFormat: DateFormat.y(), - onChanged: (DateTime newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ), - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![DateTime slider](images/getting-started/date_slider.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalDateSliderPage extends StatefulWidget { - @override - _VerticalDateSliderPageState createState() => _VerticalDateSliderPageState(); -} - -class _VerticalDateSliderPageState extends State { - DateTime _min = DateTime(2008, 01, 01); - DateTime _max = DateTime(2018, 01, 01); - DateTime _value = DateTime(2012, 01, 01); - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: SfSlider.vertical( - min: _min, - max: _max, - value: _value, - interval: 2, - showLabels: true, - dateIntervalType: DateIntervalType.years, - dateFormat: DateFormat.y(), - onChanged: (DateTime newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ), - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![DateTime slider](images/getting-started/vertical_date_slider.png) - -## Enable ticks - -You can enable ticks in the slider using the [`showTicks`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/showTicks.html) property. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class TicksSliderPage extends StatefulWidget { - @override - _TicksSliderPageState createState() => _TicksSliderPageState(); -} - -class _TicksSliderPageState extends State { - final double _min = 0; - final double _max = 100; - double _value = 40.0; - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: SfSlider( - min: _min, - max: _max, - value: _value, - interval: 20, - showTicks: true, - showLabels: true, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ), - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Numeric slider](images/getting-started/slider_with_tick.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalTicksSliderPage extends StatefulWidget { - @override - _VerticalTicksSliderPageState createState() => _VerticalTicksSliderPageState(); -} - -class _VerticalTicksSliderPageState extends State { - final double _min = 0; - final double _max = 100; - double _value = 40.0; - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: SfSlider.vertical( - min: _min, - max: _max, - value: _value, - interval: 20, - showTicks: true, - showLabels: true, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ), - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Numeric slider](images/getting-started/vertical_slider_with_tick.png) - -## Inverse the horizontal slider - -You can invert the horizontal slider by wrapping the slider to the [`Directionality`](https://api.flutter.dev/flutter/widgets/Directionality-class.html) widget by setting [`textDirection`](https://api.flutter.dev/flutter/widgets/Directionality/textDirection.html) property to `TextDirection.rtl`. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class InversedHorizontalSliderPage extends StatefulWidget { - @override - _InversedHorizontalSliderPageState createState() => _InversedHorizontalSliderPageState(); -} - -class _InversedHorizontalSliderPageState extends State { - double _value = 40.0; - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Directionality( - textDirection: TextDirection.rtl, - child: SfSlider( - min: 0, - max: 100, - value: _value, - interval: 20, - showTicks: true, - showLabels: true, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ), - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Inversed horizontal slider](images/getting-started/inversed_horizontal_slider.png) - -## Inverse the vertical slider - -You can invert the vertical slider using the [`isInversed`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/isInversed.html) property. The default value of the [`isInversed`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/isInversed.html) property is `false`. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class InversedVerticalSliderPage extends StatefulWidget { - @override - _InversedVerticalSliderPageState createState() => _InversedVerticalSliderPageState(); -} - -class _InversedVerticalSliderPageState extends State { - double _value = 40.0; - - @override - Widget build(BuildContext context) { - return Scaffold( - body: SfSlider.vertical( - min: 0, - max: 100, - value: _value, - interval: 20, - isInversed: true, - showTicks: true, - showLabels: true, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Inversed vertical slider](images/getting-started/inversed_vertical_slider.png) - -## Add prefix/suffix to labels - -You can add prefix or suffix to the labels using the [`numberFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/numberFormat.html) or [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/dateFormat.html) properties. - -N> The format type (numeric or date) of the slider is determined based on the values specified in [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html), [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) and [`value`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/value.html) properties. - -I> You must import [`intl`](https://pub.dev/packages/intl) package for formatting date slider using the [`DateFormat`](https://pub.dev/documentation/intl/latest/intl/DateFormat-class.html) class and for formatting numeric slider using the [`NumberFormat`](https://pub.dev/documentation/intl/latest/intl/NumberFormat-class.html) class. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class PrefixSuffixSliderPage extends StatefulWidget { - @override - _PrefixSuffixSliderPageState createState() => _PrefixSuffixSliderPageState(); -} - -class _PrefixSuffixSliderPageState extends State { - final double _min = 0; - final double _max = 100; - double _value = 40.0; - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: SfSlider( - min: _min, - max: _max, - value: _value, - interval: 20, - showTicks: true, - showLabels: true, - numberFormat: NumberFormat("\$"), - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ), - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Format label](images/getting-started/slider_with_formatted_label.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalPrefixSuffixSliderPage extends StatefulWidget { - @override - _VerticalPrefixSuffixSliderPageState createState() => _VerticalPrefixSuffixSliderPageState(); -} - -class _VerticalPrefixSuffixSliderPageState extends State { - final double _min = 0; - final double _max = 100; - double _value = 40.0; - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: SfSlider.vertical( - min: _min, - max: _max, - value: _value, - interval: 20, - showTicks: true, - showLabels: true, - numberFormat: NumberFormat("\$"), - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ), - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Format label](images/getting-started/vertical_slider_with_formatted_label.png) +--- +layout: post +title: Getting Started with Flutter Slider | Syncfusion® +description: Learn how to get started with the Syncfusion® Flutter Slider (SfSlider). Explore setup, slider configuration, and customization options. +platform: flutter +control: SfSlider +documentation: ug +--- + +# Getting Started with Flutter Slider (SfSlider) +This section explains the steps required to add the Flutter Slider widget and its elements such as numeric and date values, ticks, labels, and tooltip. This section covers only basic features needed to get started with Syncfusion® Flutter Slider. + +To get started quickly with our Flutter Slider widget, check out this video. + + + + +## Add Flutter Slider to an application +Create a simple project using the instructions given in the [Getting Started with your first Flutter app](https://docs.flutter.dev/get-started/test-drive#choose-your-ide) documentation. + +**Add dependency** + +Add the Syncfusion® Flutter Sliders dependency to your pubspec.yaml file. + +{% tabs %} +{% highlight dart %} + +dependencies: + +syncfusion_flutter_sliders: ^xx.x.xx + +{% endhighlight %} +{% endtabs %} + +N> Here **xx.x.xx** denotes the current version of [`Syncfusion Flutter Sliders`](https://pub.dev/packages/syncfusion_flutter_sliders/versions) package. + +**Get packages** + +Run the following command to get the required packages. + +{% tabs %} +{% highlight dart %} + +flutter pub get + +{% endhighlight %} +{% endtabs %} + +**Import package** + +Import the following package in your Dart code. + +{% tabs %} +{% highlight dart %} + +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +{% endhighlight %} +{% endtabs %} + +## Initialize Flutter Slider + +After importing the package, initialize the Flutter Slider widget as a child of any widget. Here, the slider widget is added as a child of the Center widget. The default value of the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html) and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) properties of the [`SfSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider-class.html) are 0.0 and 1.0 respectively. So, the [`value`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/value.html) property must be given within the range. + +N> The Flutter Slider passes the new value to the [`onChanged`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/onChanged.html) callback but does not change its state until the parent widget rebuilds the slider with the new value. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class HorizontalSliderPage extends StatefulWidget { + @override + _HorizontalSliderPageState createState() => _HorizontalSliderPageState(); +} + +class _HorizontalSliderPageState extends State { + double _value = 0.5; + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: SfSlider( + value: _value, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ), + ), + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Default slider](images/getting-started/default_slider.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalSliderPage extends StatefulWidget { + @override + _VerticalSliderPageState createState() => _VerticalSliderPageState(); +} + +class _VerticalSliderPageState extends State { + double _value = 0.5; + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: SfSlider.vertical( + value: _value, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ), + ), + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Default slider](images/getting-started/vertical_default_slider.png) + +## Handle value change + +The [`onChanged`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/onChanged.html) callback is used to get the current value of the slider when the user selects a value through interaction. + +N> The Flutter Slider passes the new value to the callback but does not change its state until the parent widget rebuilds the slider with the new value. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class HorizontalHandleValuePage extends StatefulWidget { + @override + _HorizontalHandleValuePageState createState() => _HorizontalHandleValuePageState(); +} + +class _HorizontalHandleValuePageState extends State { + double _value = 5.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider( + min: 0.0, + max: 10.0, + value: _value, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Handle slider](images/getting-started/handle-slider-state.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalHandleValuePage extends StatefulWidget { + @override + _VerticalHandleValuePageState createState() => _VerticalHandleValuePageState(); +} + +class _VerticalHandleValuePageState extends State { + double _value = 5.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider.vertical( + min: 0.0, + max: 10.0, + value: _value, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Handle slider](images/getting-started/vertical_handle_slider_state.png) + +## Set numeric value + +You can show numeric values in the Flutter Slider by setting `double` values to the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html), [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) and [`value`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/value.html) properties. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class NumericSliderPage extends StatefulWidget { + @override + _NumericSliderPageState createState() => _NumericSliderPageState(); +} + +class _NumericSliderPageState extends State { + final double _min = 0; + final double _max = 100; + double _value = 40.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider( + min: _min, + max: _max, + value: _value, + interval: 20, + showLabels: true, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Numeric slider](images/getting-started/numeric_slider.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalNumericSliderPage extends StatefulWidget { + @override + _VerticalNumericSliderPageState createState() => _VerticalNumericSliderPageState(); +} + +class _VerticalNumericSliderPageState extends State { + final double _min = 0; + final double _max = 100; + double _value = 40.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider.vertical( + min: _min, + max: _max, + value: _value, + interval: 20, + showLabels: true, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Numeric Slider](images/getting-started/vertical_numeric_slider.png) + +## Set date value + +You can show date values in the Flutter Slider by setting `DateTime` values to the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html), [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) and [`value`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/value.html) properties. + +N> You must import [`intl`](https://pub.dev/packages/intl) package for formatting date slider using the [`DateFormat`](https://pub.dev/documentation/intl/latest/intl/DateFormat-class.html) class. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class DateSliderPage extends StatefulWidget { + @override + _DateSliderPageState createState() => _DateSliderPageState(); +} + +class _DateSliderPageState extends State { + DateTime _min = DateTime(2008, 01, 01); + DateTime _max = DateTime(2018, 01, 01); + DateTime _value = DateTime(2012, 01, 01); + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: SfSlider( + min: _min, + max: _max, + value: _value, + interval: 2, + showLabels: true, + dateIntervalType: DateIntervalType.years, + dateFormat: DateFormat.y(), + onChanged: (DateTime newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ), + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![DateTime slider](images/getting-started/date_slider.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalDateSliderPage extends StatefulWidget { + @override + _VerticalDateSliderPageState createState() => _VerticalDateSliderPageState(); +} + +class _VerticalDateSliderPageState extends State { + DateTime _min = DateTime(2008, 01, 01); + DateTime _max = DateTime(2018, 01, 01); + DateTime _value = DateTime(2012, 01, 01); + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: SfSlider.vertical( + min: _min, + max: _max, + value: _value, + interval: 2, + showLabels: true, + dateIntervalType: DateIntervalType.years, + dateFormat: DateFormat.y(), + onChanged: (DateTime newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ), + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![DateTime slider](images/getting-started/vertical_date_slider.png) + +## Enable ticks + +You can enable ticks in the slider using the [`showTicks`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/showTicks.html) property. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class TicksSliderPage extends StatefulWidget { + @override + _TicksSliderPageState createState() => _TicksSliderPageState(); +} + +class _TicksSliderPageState extends State { + final double _min = 0; + final double _max = 100; + double _value = 40.0; + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: SfSlider( + min: _min, + max: _max, + value: _value, + interval: 20, + showTicks: true, + showLabels: true, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ), + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Numeric Flutter Slider](images/getting-started/Flutter Slider_with_tick.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalTicksSliderPage extends StatefulWidget { + @override + _VerticalTicksSliderPageState createState() => _VerticalTicksSliderPageState(); +} + +class _VerticalTicksSliderPageState extends State { + final double _min = 0; + final double _max = 100; + double _value = 40.0; + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: SfSlider.vertical( + min: _min, + max: _max, + value: _value, + interval: 20, + showTicks: true, + showLabels: true, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ), + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Numeric slider](images/getting-started/vertical_slider_with_tick.png) + +## Inverse the horizontal Flutter Slider + +You can invert the horizontal slider by wrapping the Flutter Slider to the [`Directionality`](https://api.flutter.dev/flutter/widgets/Directionality-class.html) widget by setting [`textDirection`](https://api.flutter.dev/flutter/widgets/Directionality/textDirection.html) property to `TextDirection.rtl`. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class InversedHorizontalSliderPage extends StatefulWidget { + @override + _InversedHorizontalSliderPageState createState() => _InversedHorizontalSliderPageState(); +} + +class _InversedHorizontalSliderPageState extends State { + double _value = 40.0; + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Directionality( + textDirection: TextDirection.rtl, + child: SfSlider( + min: 0, + max: 100, + value: _value, + interval: 20, + showTicks: true, + showLabels: true, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ), + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Inversed horizontal slider](images/getting-started/inversed_horizontal_slider.png) + +## Inverse the vertical Flutter Slider + +You can invert the vertical slider using the [`isInversed`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/isInversed.html) property. The default value of the [`isInversed`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/isInversed.html) property is `false`. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class InversedVerticalSliderPage extends StatefulWidget { + @override + _InversedVerticalSliderPageState createState() => _InversedVerticalSliderPageState(); +} + +class _InversedVerticalSliderPageState extends State { + double _value = 40.0; + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SfSlider.vertical( + min: 0, + max: 100, + value: _value, + interval: 20, + isInversed: true, + showTicks: true, + showLabels: true, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Inversed vertical slider](images/getting-started/inversed_vertical_slider.png) + +## Add prefix/suffix to labels + +You can add prefix or suffix to the labels using the [`numberFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/numberFormat.html) or [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/dateFormat.html) properties. + +N> The format type (numeric or date) of the Flutter Slider is determined based on the values specified in [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html), [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) and [`value`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/value.html) properties. + +I> You must import [`intl`](https://pub.dev/packages/intl) package for formatting date slider using the [`DateFormat`](https://pub.dev/documentation/intl/latest/intl/DateFormat-class.html) class and for formatting numeric slider using the [`NumberFormat`](https://pub.dev/documentation/intl/latest/intl/NumberFormat-class.html) class. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class PrefixSuffixSliderPage extends StatefulWidget { + @override + _PrefixSuffixSliderPageState createState() => _PrefixSuffixSliderPageState(); +} + +class _PrefixSuffixSliderPageState extends State { + final double _min = 0; + final double _max = 100; + double _value = 40.0; + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: SfSlider( + min: _min, + max: _max, + value: _value, + interval: 20, + showTicks: true, + showLabels: true, + numberFormat: NumberFormat("\$"), + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ), + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Format label](images/getting-started/slider_with_formatted_label.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalPrefixSuffixSliderPage extends StatefulWidget { + @override + _VerticalPrefixSuffixSliderPageState createState() => _VerticalPrefixSuffixSliderPageState(); +} + +class _VerticalPrefixSuffixSliderPageState extends State { + final double _min = 0; + final double _max = 100; + double _value = 40.0; + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: SfSlider.vertical( + min: _min, + max: _max, + value: _value, + interval: 20, + showTicks: true, + showLabels: true, + numberFormat: NumberFormat("\$"), + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ), + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Format label](images/getting-started/vertical_slider_with_formatted_label.png) diff --git a/Flutter/slider/interval.md b/Flutter/slider/interval.md index 56cb6037c..cc35ac3ad 100644 --- a/Flutter/slider/interval.md +++ b/Flutter/slider/interval.md @@ -1,419 +1,419 @@ ---- -layout: post -title: Interval in Flutter Slider | Syncfusion® -description: Learn about interval support in Syncfusion® Flutter Slider (SfSlider), including interval customization, labels, ticks, and value selection. -platform: flutter -control: SfSlider -documentation: ug ---- - -# Interval in Flutter Slider (SfSlider) -This section explains how to set the interval for numeric and date sliders. - -## Numeric interval - -Slider elements like labels, ticks and dividers are rendered based on the [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/interval.html), [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html) and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) properties. The default value is `null` and it must be greater than 0. - -For example, if [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html) is 0.0 and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) is 10.0 and [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/interval.html) is 2.0, the slider will render the labels, major ticks, and dividers at 0.0, 2.0, 4.0 and so on. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class NumericIntervalPage extends StatefulWidget { - @override - _NumericIntervalPageState createState() => _NumericIntervalPageState(); -} - -class _NumericIntervalPageState extends State { - double _value = 4.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider( - min: 0.0, - max: 10.0, - interval: 2, - showTicks: true, - showLabels: true, - value: _value, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Numeric interval support](images/interval/numeric-interval.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalNumericIntervalPage extends StatefulWidget { - @override - _VerticalNumericIntervalPageState createState() => _VerticalNumericIntervalPageState(); -} - -class _VerticalNumericIntervalPageState extends State { - double _value = 4.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider.vertical( - min: 0.0, - max: 10.0, - interval: 2, - showTicks: true, - showLabels: true, - value: _value, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Numeric interval support](images/interval/vertical-numeric-interval.png) - -N> -* Refer the [`showDividers`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/showDividers.html) to know about the rendering of dividers at given interval. -* Refer the [`showTicks`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/showTicks.html) to know about the rendering of major ticks at given interval. -* Refer the [`showLabels`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/showLabels.html) to know about the rendering of labels at given interval. - -## Date interval - -The type of date interval. It can be years to seconds. It is mandatory for date [`SfSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider-class.html). The default value of [`dateIntervalType`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/dateIntervalType.html) property is `null`. - -For date values, the slider does not have auto interval support. So, it is mandatory to set [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/interval.html), [`dateIntervalType`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/dateIntervalType.html), and [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/dateFormat.html) for date values. - -For example, if [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html) is `DateTime(2000, 01, 01)` and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) is `DateTime(2005, 01, 01)` and [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/interval.html) is `1`, [`dateIntervalType`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/dateIntervalType.html) is `DateIntervalType.years`, [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/dateFormat.html) is `DateFormat.y()` then the slider will render the labels, major ticks, and dividers at 2000, 2001, 2002 and so on. - -N> You must import the [`intl`](https://pub.dev/packages/intl) package for formatting date slider using the [`DateFormat`](https://pub.dev/documentation/intl/latest/intl/DateFormat-class.html) class. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class DateIntervalPage extends StatefulWidget { - @override - _DateIntervalPageState createState() => _DateIntervalPageState(); -} - -class _DateIntervalPageState extends State { - DateTime _value = DateTime(2002, 01, 01); - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider( - min: DateTime(2000, 01, 01, 00), - max: DateTime(2004, 12, 31, 24), - value: _value, - interval: 1, - showLabels: true, - showTicks: true, - dateFormat: DateFormat.y(), - dateIntervalType: DateIntervalType.years, - onChanged: (DateTime newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Date interval type support](images/interval/date-interval-type.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalDateIntervalPage extends StatefulWidget { - @override - _VerticalDateIntervalPageState createState() => _VerticalDateIntervalPageState(); -} - -class _VerticalDateIntervalPageState extends State { - DateTime _value = DateTime(2002, 01, 01); - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider.vertical( - min: DateTime(2000, 01, 01, 00), - max: DateTime(2004, 12, 31, 24), - value: _value, - interval: 1, - showLabels: true, - showTicks: true, - dateFormat: DateFormat.y(), - dateIntervalType: DateIntervalType.years, - onChanged: (DateTime newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Date interval type support](images/interval/vertical-date-interval-type.png) - -## Discrete selection for numeric values - -You can move the thumb in discrete manner for numeric values using the [`stepSize`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/stepSize.html) property in the slider. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class StepSizePage extends StatefulWidget { - @override - _StepSizePageState createState() => _StepSizePageState(); -} - -class _StepSizePageState extends State { - double _value = 4.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider( - min: 0.0, - max: 10.0, - interval: 2, - stepSize: 2, - showTicks: true, - minorTicksPerInterval: 1, - showLabels: true, - value: _value, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Step size support](images/interval/step-size-support.gif) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalStepSizePage extends StatefulWidget { - @override - _VerticalStepSizePageState createState() => _VerticalStepSizePageState(); -} - -class _VerticalStepSizePageState extends State { - double _value = 4.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider.vertical( - min: 0.0, - max: 10.0, - interval: 2, - stepSize: 2, - showTicks: true, - minorTicksPerInterval: 1, - showLabels: true, - value: _value, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -## Discrete selection for date values - -You can move the thumb in discrete manner for date values using the [`stepDuration`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/stepDuration.html) property in the slider. - -N> You must import the [`intl`](https://pub.dev/packages/intl) package for formatting date slider using the [`DateFormat`](https://pub.dev/documentation/intl/latest/intl/DateFormat-class.html) class. - -For example, if [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html) is `DateTime(2015, 01, 01)` and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) is `DateTime(2020, 01, 01)` and [`stepDuration`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/stepDuration.html) is `SliderStepDuration(years: 1, months: 6)`, the slider will move the thumb at `DateTime(2015, 01, 01)`, `DateTime(2016, 07, 01)`, `DateTime(2018, 01, 01)`, and `DateTime(2019, 07, 01)`. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class StepDurationPage extends StatefulWidget { - @override - _StepDurationPageState createState() => _StepDurationPageState(); -} - -class _StepDurationPageState extends State { - DateTime _value = DateTime(2004, 01, 01); - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider( - min: DateTime(2000, 01, 01), - max: DateTime(2010, 01, 01), - interval: 2, - stepDuration: SliderStepDuration(years: 2), - dateFormat: DateFormat.y(), - dateIntervalType: DateIntervalType.years, - showTicks: true, - showLabels: true, - value: _value, - onChanged: (DateTime newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Step duration support](images/interval/step-duration-support.gif) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalStepDurationPage extends StatefulWidget { - @override - _VerticalStepDurationPageState createState() => _VerticalStepDurationPageState(); -} - -class _VerticalStepDurationPageState extends State { - DateTime _value = DateTime(2004, 01, 01); - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider.vertical( - min: DateTime(2000, 01, 01), - max: DateTime(2010, 01, 01), - interval: 2, - stepDuration: SliderStepDuration(years: 2), - dateFormat: DateFormat.y(), - dateIntervalType: DateIntervalType.years, - showTicks: true, - showLabels: true, - value: _value, - onChanged: (DateTime newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - +--- +layout: post +title: Interval in Flutter Slider | Syncfusion® +description: Learn about interval support in Syncfusion® Flutter Slider (SfSlider), including interval customization, labels, ticks, and value selection. +platform: flutter +control: SfSlider +documentation: ug +--- + +# Interval in Flutter Slider (SfSlider) +This section explains how to set the interval for numeric and date sliders. + +## Numeric interval + +Flutter Slider elements like labels, ticks and dividers are rendered based on the [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/interval.html), [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html) and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) properties. The default value is `null` and it must be greater than 0. + +For example, if [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html) is 0.0 and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) is 10.0 and [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/interval.html) is 2.0, the Flutter Slider will render the labels, major ticks, and dividers at 0.0, 2.0, 4.0 and so on. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class NumericIntervalPage extends StatefulWidget { + @override + _NumericIntervalPageState createState() => _NumericIntervalPageState(); +} + +class _NumericIntervalPageState extends State { + double _value = 4.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider( + min: 0.0, + max: 10.0, + interval: 2, + showTicks: true, + showLabels: true, + value: _value, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Numeric interval support](images/interval/numeric-interval.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalNumericIntervalPage extends StatefulWidget { + @override + _VerticalNumericIntervalPageState createState() => _VerticalNumericIntervalPageState(); +} + +class _VerticalNumericIntervalPageState extends State { + double _value = 4.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider.vertical( + min: 0.0, + max: 10.0, + interval: 2, + showTicks: true, + showLabels: true, + value: _value, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Numeric interval support](images/interval/vertical-numeric-interval.png) + +N> +* Refer the [`showDividers`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/showDividers.html) to know about the rendering of dividers at given interval. +* Refer the [`showTicks`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/showTicks.html) to know about the rendering of major ticks at given interval. +* Refer the [`showLabels`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/showLabels.html) to know about the rendering of labels at given interval. + +## Date interval + +The type of date interval. It can be years to seconds. It is mandatory for date [`SfSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider-class.html). The default value of [`dateIntervalType`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/dateIntervalType.html) property is `null`. + +For date values, the Flutter Slider does not have auto interval support. So, it is mandatory to set [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/interval.html), [`dateIntervalType`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/dateIntervalType.html), and [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/dateFormat.html) for date values. + +For example, if [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html) is `DateTime(2000, 01, 01)` and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) is `DateTime(2005, 01, 01)` and [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/interval.html) is `1`, [`dateIntervalType`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/dateIntervalType.html) is `DateIntervalType.years`, [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/dateFormat.html) is `DateFormat.y()` then the Flutter Slider will render the labels, major ticks, and dividers at 2000, 2001, 2002 and so on. + +N> You must import the [`intl`](https://pub.dev/packages/intl) package for formatting date slider using the [`DateFormat`](https://pub.dev/documentation/intl/latest/intl/DateFormat-class.html) class. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class DateIntervalPage extends StatefulWidget { + @override + _DateIntervalPageState createState() => _DateIntervalPageState(); +} + +class _DateIntervalPageState extends State { + DateTime _value = DateTime(2002, 01, 01); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider( + min: DateTime(2000, 01, 01, 00), + max: DateTime(2004, 12, 31, 24), + value: _value, + interval: 1, + showLabels: true, + showTicks: true, + dateFormat: DateFormat.y(), + dateIntervalType: DateIntervalType.years, + onChanged: (DateTime newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Date interval type support](images/interval/date-interval-type.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalDateIntervalPage extends StatefulWidget { + @override + _VerticalDateIntervalPageState createState() => _VerticalDateIntervalPageState(); +} + +class _VerticalDateIntervalPageState extends State { + DateTime _value = DateTime(2002, 01, 01); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider.vertical( + min: DateTime(2000, 01, 01, 00), + max: DateTime(2004, 12, 31, 24), + value: _value, + interval: 1, + showLabels: true, + showTicks: true, + dateFormat: DateFormat.y(), + dateIntervalType: DateIntervalType.years, + onChanged: (DateTime newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Date interval type support](images/interval/vertical-date-interval-type.png) + +## Discrete selection for numeric values + +You can move the thumb in discrete manner for numeric values using the [`stepSize`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/stepSize.html) property in the Flutter Slider. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class StepSizePage extends StatefulWidget { + @override + _StepSizePageState createState() => _StepSizePageState(); +} + +class _StepSizePageState extends State { + double _value = 4.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider( + min: 0.0, + max: 10.0, + interval: 2, + stepSize: 2, + showTicks: true, + minorTicksPerInterval: 1, + showLabels: true, + value: _value, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Step size support](images/interval/step-size-support.gif) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalStepSizePage extends StatefulWidget { + @override + _VerticalStepSizePageState createState() => _VerticalStepSizePageState(); +} + +class _VerticalStepSizePageState extends State { + double _value = 4.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider.vertical( + min: 0.0, + max: 10.0, + interval: 2, + stepSize: 2, + showTicks: true, + minorTicksPerInterval: 1, + showLabels: true, + value: _value, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +## Discrete selection for date values + +You can move the thumb in discrete manner for date values using the [`stepDuration`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/stepDuration.html) property in the Flutter Slider. + +N> You must import the [`intl`](https://pub.dev/packages/intl) package for formatting date slider using the [`DateFormat`](https://pub.dev/documentation/intl/latest/intl/DateFormat-class.html) class. + +For example, if [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html) is `DateTime(2015, 01, 01)` and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) is `DateTime(2020, 01, 01)` and [`stepDuration`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/stepDuration.html) is `SliderStepDuration(years: 1, months: 6)`, the slider will move the thumb at `DateTime(2015, 01, 01)`, `DateTime(2016, 07, 01)`, `DateTime(2018, 01, 01)`, and `DateTime(2019, 07, 01)`. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class StepDurationPage extends StatefulWidget { + @override + _StepDurationPageState createState() => _StepDurationPageState(); +} + +class _StepDurationPageState extends State { + DateTime _value = DateTime(2004, 01, 01); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider( + min: DateTime(2000, 01, 01), + max: DateTime(2010, 01, 01), + interval: 2, + stepDuration: SliderStepDuration(years: 2), + dateFormat: DateFormat.y(), + dateIntervalType: DateIntervalType.years, + showTicks: true, + showLabels: true, + value: _value, + onChanged: (DateTime newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Step duration support](images/interval/step-duration-support.gif) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalStepDurationPage extends StatefulWidget { + @override + _VerticalStepDurationPageState createState() => _VerticalStepDurationPageState(); +} + +class _VerticalStepDurationPageState extends State { + DateTime _value = DateTime(2004, 01, 01); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider.vertical( + min: DateTime(2000, 01, 01), + max: DateTime(2010, 01, 01), + interval: 2, + stepDuration: SliderStepDuration(years: 2), + dateFormat: DateFormat.y(), + dateIntervalType: DateIntervalType.years, + showTicks: true, + showLabels: true, + value: _value, + onChanged: (DateTime newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + diff --git a/Flutter/slider/labels-and-divider.md b/Flutter/slider/labels-and-divider.md index 0a110e0dd..013622e28 100644 --- a/Flutter/slider/labels-and-divider.md +++ b/Flutter/slider/labels-and-divider.md @@ -1,1615 +1,1615 @@ ---- -layout: post -title: Labels and Dividers in Flutter Slider | Syncfusion® -description: Learn about labels and dividers in Syncfusion® Flutter Slider (SfSlider), including label formatting, divider customization, and styling options. -platform: flutter -control: SfSlider -documentation: ug ---- - -# Labels and Dividers in Flutter Slider (SfSlider) -This section explains how to add labels and dividers to the slider. - -N> You must import the `theme.dart` library from the [`Core`](https://pub.dev/packages/syncfusion_flutter_core) package to use [`SfSliderTheme`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderTheme-class.html) for customizing label and divider appearance in the examples below. You must also import the [`intl`](https://pub.dev/packages/intl) package for formatting numeric and date labels. - -## Show labels - -The [`showLabels`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/showLabels.html) property is used to render the labels on given interval. The default value of [`showLabels`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/showLabels.html) property is `false`. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class ShowLabelsPage extends StatefulWidget { - @override - _ShowLabelsPageState createState() => _ShowLabelsPageState(); -} - -class _ShowLabelsPageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider( - min: 0.0, - max: 10.0, - interval: 2, - showLabels: true, - showTicks: true, - value: _value, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Slider label support](images/label-and-divider/show-labels.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalShowLabelsPage extends StatefulWidget { - @override - _VerticalShowLabelsPageState createState() => _VerticalShowLabelsPageState(); -} - -class _VerticalShowLabelsPageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider.vertical( - min: 0.0, - max: 10.0, - interval: 2, - showLabels: true, - showTicks: true, - value: _value, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Slider label support](images/label-and-divider/vertical-show-labels.png) - -N> -* Refer the [`numberFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/numberFormat.html) and [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/dateFormat.html) for formatting the numeric and date labels respectively. -* Refer the [`SfSliderThemeData`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData-class.html) for customizing the appearance of the labels. - -## Number format - -The [`numberFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/numberFormat.html) property is used to format the numeric labels. The default value of [`numberFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/numberFormat.html) property is `null`. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class NumberFormatPage extends StatefulWidget { - @override - _NumberFormatPageState createState() => _NumberFormatPageState(); -} - -class _NumberFormatPageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider( - min: 0.0, - max: 10.0, - value: _value, - interval: 2, - showTicks: true, - showLabels: true, - numberFormat: NumberFormat('\$'), - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Number format support](images/label-and-divider/number-format.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalNumberFormatPage extends StatefulWidget { - @override - _VerticalNumberFormatPageState createState() => _VerticalNumberFormatPageState(); -} - -class _VerticalNumberFormatPageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider.vertical( - min: 0.0, - max: 10.0, - value: _value, - interval: 2, - showTicks: true, - showLabels: true, - numberFormat: NumberFormat('\$'), - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Number format support](images/label-and-divider/vertical-number-format.png) - -## Date format - -The [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/dateFormat.html) property is used to format the date labels. It is mandatory for the date [`SfSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider-class.html). For date values, the slider does not have auto interval support. So, it is mandatory to set [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/interval.html), [`dateIntervalType`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/dateIntervalType.html), and [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/dateFormat.html) for date values. The default value of [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/dateFormat.html) property is `null`. - -### Year format -#### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class YearFormatPage extends StatefulWidget { - @override - _YearFormatPageState createState() => _YearFormatPageState(); -} - -class _YearFormatPageState extends State { - DateTime _value = DateTime(2002, 01, 01); - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider( - min: DateTime(2000, 01, 01, 00), - max: DateTime(2004, 12, 31, 24), - value: _value, - interval: 1, - showLabels: true, - showTicks: true, - dateFormat: DateFormat.y(), - dateIntervalType: DateIntervalType.years, - onChanged: (DateTime newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Year date format support](images/label-and-divider/year-date-format.png) - -#### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalYearFormatPage extends StatefulWidget { - @override - _VerticalYearFormatPageState createState() => _VerticalYearFormatPageState(); -} - -class _VerticalYearFormatPageState extends State { - DateTime _value = DateTime(2002, 01, 01); - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider.vertical( - min: DateTime(2000, 01, 01, 00), - max: DateTime(2004, 12, 31, 24), - value: _value, - interval: 1, - showLabels: true, - showTicks: true, - dateFormat: DateFormat.y(), - dateIntervalType: DateIntervalType.years, - onChanged: (DateTime newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Year date format support](images/label-and-divider/vertical-year-date-format.png) - -### Month format -#### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class MonthFormatPage extends StatefulWidget { - @override - _MonthFormatPageState createState() => _MonthFormatPageState(); -} - -class _MonthFormatPageState extends State { - DateTime _value = DateTime(2000, 03, 01); - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider( - min: DateTime(2000, 01, 01, 00), - max: DateTime(2000, 09, 02, 00), - value: _value, - interval: 2, - showLabels: true, - showTicks: true, - dateFormat: DateFormat.yM(), - dateIntervalType: DateIntervalType.months, - onChanged: (DateTime newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Month date format support](images/label-and-divider/month-date-format.png) - -#### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalMonthFormatPage extends StatefulWidget { - @override - _VerticalMonthFormatPageState createState() => _VerticalMonthFormatPageState(); -} - -class _VerticalMonthFormatPageState extends State { - DateTime _value = DateTime(2000, 03, 01); - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider.vertical( - min: DateTime(2000, 01, 01, 00), - max: DateTime(2000, 09, 02, 00), - value: _value, - interval: 2, - showLabels: true, - showTicks: true, - dateFormat: DateFormat.yM(), - dateIntervalType: DateIntervalType.months, - onChanged: (DateTime newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Month date format support](images/label-and-divider/vertical-month-date-format.png) - - -### Hour format -#### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class HourFormatPage extends StatefulWidget { - @override - _HourFormatPageState createState() => _HourFormatPageState(); -} - -class _HourFormatPageState extends State { - DateTime _value = DateTime(2000, 01, 01, 12, 00, 00); - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider( - min: DateTime(2000, 01, 01, 02, 00, 00), - max: DateTime(2000, 01, 01, 22, 00, 00), - value: _value, - interval: 5, - showLabels: true, - showTicks: true, - dateFormat: DateFormat('h:mm a'), - dateIntervalType: DateIntervalType.hours, - onChanged: (DateTime newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Hour date format support](images/label-and-divider/hour-date-format.png) - -#### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalHourFormatPage extends StatefulWidget { - @override - _VerticalHourFormatPageState createState() => _VerticalHourFormatPageState(); -} - -class _VerticalHourFormatPageState extends State { - DateTime _value = DateTime(2000, 01, 01, 12, 00, 00); - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider.vertical( - min: DateTime(2000, 01, 01, 02, 00, 00), - max: DateTime(2000, 01, 01, 22, 00, 00), - value: _value, - interval: 5, - showLabels: true, - showTicks: true, - dateFormat: DateFormat('h:mm a'), - dateIntervalType: DateIntervalType.hours, - onChanged: (DateTime newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Hour date format support](images/label-and-divider/vertical-hour-date-format.png) - -N> Refer the [`DateFormat`](https://pub.dev/documentation/intl/latest/intl/DateFormat-class.html) class for other date format. - -## Label placement - -The [`labelPlacement`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/labelPlacement.html) property is used to place the labels either between the major ticks or on the major ticks. The default value of the [`labelPlacement`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/labelPlacement.html) property is `LabelPlacement.onTicks`. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class LabelPlacementPage extends StatefulWidget { - @override - _LabelPlacementPageState createState() => _LabelPlacementPageState(); -} - -class _LabelPlacementPageState extends State { - DateTime _value = DateTime(2002, 01, 01); - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider( - min: DateTime(2000, 01, 01, 00), - max: DateTime(2004, 12, 31, 24), - value: _value, - interval: 1, - showLabels: true, - showTicks: true, - labelPlacement: LabelPlacement.betweenTicks, - dateFormat: DateFormat.y(), - dateIntervalType: DateIntervalType.years, - onChanged: (DateTime newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Label placement support](images/label-and-divider/label-placement.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalLabelPlacementPage extends StatefulWidget { - @override - _VerticalLabelPlacementPageState createState() => _VerticalLabelPlacementPageState(); -} - -class _VerticalLabelPlacementPageState extends State { - DateTime _value = DateTime(2002, 01, 01); - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider.vertical( - min: DateTime(2000, 01, 01, 00), - max: DateTime(2004, 12, 31, 24), - value: _value, - interval: 1, - showLabels: true, - showTicks: true, - labelPlacement: LabelPlacement.betweenTicks, - dateFormat: DateFormat.y(), - dateIntervalType: DateIntervalType.years, - onChanged: (DateTime newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Label placement support](images/label-and-divider/vertical-label-placement.png) - -## Edge label placement - -The [`edgeLabelPlacement`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/edgeLabelPlacement.html) property determines how the edge (first and last) labels are positioned on the slider. This property allows the edge labels to be placed either inside the major ticks or directly on the major ticks. - -The default value of the [`edgeLabelPlacement`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/edgeLabelPlacement.html) property is `EdgeLabelPlacement.auto`. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class EdgeLabelPlacementPage extends StatefulWidget { - @override - _EdgeLabelPlacementPageState createState() => _EdgeLabelPlacementPageState(); -} - -class _EdgeLabelPlacementPageState extends State { - DateTime _value = DateTime(2002, 01, 01); - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider( - min: DateTime(2000, 01, 01, 00), - max: DateTime(2004, 12, 31, 24), - value: _value, - interval: 1, - showLabels: true, - showTicks: true, - edgeLabelPlacement: EdgeLabelPlacement.inside, - dateFormat: DateFormat.y(), - dateIntervalType: DateIntervalType.years, - onChanged: (DateTime newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Edge Label placement support](images/label-and-divider/edge-label-placement.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalEdgeLabelPlacementPage extends StatefulWidget { - @override - _VerticalEdgeLabelPlacementPageState createState() => _VerticalEdgeLabelPlacementPageState(); -} - -class _VerticalEdgeLabelPlacementPageState extends State { - DateTime _value = DateTime(2002, 01, 01); - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider.vertical( - min: DateTime(2000, 01, 01, 00), - max: DateTime(2004, 12, 31, 24), - value: _value, - interval: 1, - showLabels: true, - showTicks: true, - edgeLabelPlacement: EdgeLabelPlacement.inside, - dateFormat: DateFormat.y(), - dateIntervalType: DateIntervalType.years, - onChanged: (DateTime newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Edge Label placement support](images/label-and-divider/vertical-edge-label-placement.png) - -## Customize label text - -You can format or change the whole numeric or date label text using the [`labelFormatterCallback`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/labelFormatterCallback.html). Its arguments are, - -* actualValue – either `DateTime` or `double` based on given [`value`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/value.html). -* formattedText – If the actual value is `double`, it is formatted by [`numberFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/numberFormat.html) and if the actual value is `DateTime`, it is formatted by [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/dateFormat.html). - ->**NOTE** -* [`labelFormatterCallback`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/labelFormatterCallback.html) has been deprecated, you can use [`onLabelCreated`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/onLabelCreated.html) callback to customize both the text and text style of the label. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class LabelFormatterPage extends StatefulWidget { - @override - _LabelFormatterPageState createState() => _LabelFormatterPageState(); -} - -class _LabelFormatterPageState extends State { - double _value = 9900.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider( - min: 100.0, - max: 10000.0, - value: _value, - showLabels: true, - interval: 9900, - labelFormatterCallback: (dynamic actualValue, String formattedText) { - return actualValue == 10000 ? '\$ $formattedText+' : '\$ $formattedText'; - }, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Label formatter support](images/label-and-divider/label-formattercallback.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalLabelFormatterPage extends StatefulWidget { - @override - _VerticalLabelFormatterPageState createState() => _VerticalLabelFormatterPageState(); -} - -class _VerticalLabelFormatterPageState extends State { - double _value = 9900.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider.vertical( - min: 100.0, - max: 10000.0, - value: _value, - showLabels: true, - interval: 9900, - labelFormatterCallback: (dynamic actualValue, String formattedText) { - return actualValue == 10000 ? '\$ $formattedText+' : '\$ $formattedText'; - }, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Label formatter support](images/label-and-divider/vertical-label-formattercallback.png) - -## Label style - -You can change the active and inactive label appearance of the slider using the [`activeLabelStyle`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeLabelStyle.html) and [`inactiveLabelStyle`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveLabelStyle.html) properties respectively. - -The active side of the slider is between the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html) value and the thumb. - -The inactive side of the slider is between the thumb and the [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) value. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class LabelStylePage extends StatefulWidget { - @override - _LabelStylePageState createState() => _LabelStylePageState(); -} - -class _LabelStylePageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - activeLabelStyle: TextStyle(color: Colors.red, fontSize: 12, fontStyle: FontStyle.italic), - inactiveLabelStyle: TextStyle(color: Colors.red[200], fontSize: 12, fontStyle: FontStyle.italic), - ), - child: SfSlider( - min: 2.0, - max: 10.0, - value: _value, - interval: 1, - showLabels: true, - showTicks: true, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Labels style support](images/label-and-divider/slider-labels-color.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalLabelStylePage extends StatefulWidget { - @override - _VerticalLabelStylePageState createState() => _VerticalLabelStylePageState(); -} - -class _VerticalLabelStylePageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - activeLabelStyle: TextStyle(color: Colors.red, fontSize: 12, fontStyle: FontStyle.italic), - inactiveLabelStyle: TextStyle(color: Colors.red[200], fontSize: 12, fontStyle: FontStyle.italic), - ), - child: SfSlider.vertical( - min: 2.0, - max: 10.0, - value: _value, - interval: 1, - showLabels: true, - showTicks: true, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Labels style support](images/label-and-divider/vertical-slider-labels-color.png) - -## Individual label style - -You can customize the appearance of each label on the [`SfSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider-class.html) individually by using the [`onLabelCreated`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/onLabelCreated.html) callback. This callback allows you to have complete control over the text and text style for each label. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class IndividualLabelPage extends StatefulWidget { - @override - _IndividualLabelPageState createState() => _IndividualLabelPageState(); -} - -class _IndividualLabelPageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: SfSlider( - min: 2.0, - max: 10.0, - value: _value, - interval: 1, - showLabels: true, - showTicks: true, - onChanged: (double value) { - setState(() { - _value = value; - }); - }, - onLabelCreated: ( - dynamic actualValue, - String text, - TextStyle labelTextStyle, - ) { - return SliderLabel( - text: text, - textStyle: - actualValue == _value.toInt() - ? const TextStyle( - color: Colors.blue, - fontSize: 14, - ) - : TextStyle( - color: Colors.red[200], - fontSize: 10, - ), - ); - }, - ), - ), - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Individual label style support](images/label-and-divider/slider-individual-label-color.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalIndividualLabelsPage extends StatefulWidget { - @override - _VerticalIndividualLabelsPageState createState() => _VerticalIndividualLabelsPageState(); -} - -class _VerticalIndividualLabelsPageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: SfSlider.vertical( - min: 2.0, - max: 10.0, - value: _value, - interval: 1, - showLabels: true, - showTicks: true, - onChanged: (double value) { - setState(() { - _value = value; - }); - }, - onLabelCreated: ( - dynamic actualValue, - String text, - TextStyle labelTextStyle, - ) { - return SliderLabel( - text: text, - textStyle: - actualValue == _value.toInt() - ? const TextStyle( - color: Colors.blue, - fontSize: 14, - ) - : TextStyle( - color: Colors.red[200], - fontSize: 10, - ), - ); - }, - ), - ), - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Individual label style support](images/label-and-divider/vertical-slider-individual-label-color.png) - -## Label offset - -You can adjust the space between ticks and labels of the slider using the [`labelOffset`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/labelOffset.html) property. - -### Horizontal - -The default value of [`labelOffset`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/labelOffset.html) property is `Offset(0.0, 13.0)` if the [`showTicks`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/showTicks.html) property is `false`. -The default value of [`labelOffset`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/labelOffset.html) property is `Offset(0.0, 5.0)` if the [`showTicks`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/showTicks.html) property is `true`. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class LabelOffsetPage extends StatefulWidget { - @override - _LabelOffsetPageState createState() => _LabelOffsetPageState(); -} - -class _LabelOffsetPageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - labelOffset: Offset(0.0, 10.0), - ), - child: SfSlider( - min: 2.0, - max: 10.0, - value: _value, - interval: 2, - showTicks: true, - showLabels: true, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Labels offset support](images/label-and-divider/slider-labels-offset.png) - -### Vertical - -The default value of [`labelOffset`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/labelOffset.html) property is `Offset(13.0, 0.0)` if the [`showTicks`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/showTicks.html) property is `false`. -The default value of [`labelOffset`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/labelOffset.html) property is `Offset(5.0, 0.0)` if the [`showTicks`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/showTicks.html) property is `true`. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalLabelOffsetPage extends StatefulWidget { - @override - _VerticalLabelOffsetPageState createState() => _VerticalLabelOffsetPageState(); -} - -class _VerticalLabelOffsetPageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - labelOffset: Offset(10.0, 0.0), - ), - child: SfSlider.vertical( - min: 2.0, - max: 10.0, - value: _value, - interval: 2, - showTicks: true, - showLabels: true, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Labels offset support](images/label-and-divider/vertical-slider-labels-offset.png) - -## Show dividers - -The [`showDividers`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/showDividers.html) property is used to render the dividers on the track. The default value of the [`showDividers`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/showDividers.html) property is `false`. It is a shape which is used to represent the major interval points of the track. - -For example, if [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html) is 0.0 and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) is 10.0 and [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/interval.html) is 2.0, the slider will render the dividers at 0.0, 2.0, 4.0 and so on. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class ShowDividersPage extends StatefulWidget { - @override - _ShowDividersPageState createState() => _ShowDividersPageState(); -} - -class _ShowDividersPageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - activeTrackHeight: 5, - inactiveTrackHeight: 5, - ), - child: SfSlider( - min: 0.0, - max: 10.0, - interval: 2, - showDividers: true, - value: _value, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Slider divider support](images/label-and-divider/show-divider.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalShowDividersPage extends StatefulWidget { - @override - _VerticalShowDividersPageState createState() => _VerticalShowDividersPageState(); -} - -class _VerticalShowDividersPageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - activeTrackHeight: 5, - inactiveTrackHeight: 5, - ), - child: SfSlider.vertical( - min: 0.0, - max: 10.0, - interval: 2, - showDividers: true, - value: _value, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Slider divider support](images/label-and-divider/vertical-show-divider.png) - -## Divider radius - -You can change the active and inactive divider radius of the slider using the [`activeDividerRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeDividerRadius.html) and the [`inactiveDividerRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveDividerRadius.html) properties respectively. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class DividerRadiusPage extends StatefulWidget { - @override - _DividerRadiusPageState createState() => _DividerRadiusPageState(); -} - -class _DividerRadiusPageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - activeTrackHeight: 10, - inactiveTrackHeight: 10, - activeDividerRadius: 5, - inactiveDividerRadius: 5, - ), - child: SfSlider( - min: 2.0, - max: 10.0, - interval: 1, - showDividers: true, - value: _value, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ) - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Divider radius support](images/label-and-divider/slider-divider-radius.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalDividerRadiusPage extends StatefulWidget { - @override - _VerticalDividerRadiusPageState createState() => _VerticalDividerRadiusPageState(); -} - -class _VerticalDividerRadiusPageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - activeTrackHeight: 10, - inactiveTrackHeight: 10, - activeDividerRadius: 5, - inactiveDividerRadius: 5, - ), - child: SfSlider.vertical( - min: 2.0, - max: 10.0, - interval: 1, - showDividers: true, - value: _value, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ) - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Divider radius support](images/label-and-divider/vertical-slider-divider-radius.png) - - -## Divider stroke width and stroke color - -You can change the active and inactive divider stroke width of the slider using the [`activeDividerStrokeWidth`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeDividerStrokeWidth.html) and the [`inactiveDividerStrokeWidth`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveDividerStrokeWidth.html) properties respectively. - -Also, you can change the active and inactive divider stroke color of the slider using the [`activeDividerStrokeColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeDividerStrokeColor.html) and the [`inactiveDividerStrokeColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveDividerStrokeColor.html) properties respectively. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class DividerStrokePage extends StatefulWidget { - @override - _DividerStrokePageState createState() => _DividerStrokePageState(); -} - -class _DividerStrokePageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - activeTrackHeight: 10, - inactiveTrackHeight: 10, - activeDividerStrokeColor: Colors.red, - activeDividerStrokeWidth: 2, - inactiveDividerStrokeWidth: 2, - inactiveDividerStrokeColor: Colors.red, - ), - child: SfSlider( - min: 2.0, - max: 10.0, - interval: 1, - showDividers: true, - value: _value, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ) - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Divider stroke width and color support](images/label-and-divider/slider-divider-stroke-color.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalDividerStrokePage extends StatefulWidget { - @override - _VerticalDividerStrokePageState createState() => _VerticalDividerStrokePageState(); -} - -class _VerticalDividerStrokePageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - activeTrackHeight: 10, - inactiveTrackHeight: 10, - activeDividerStrokeColor: Colors.red, - activeDividerStrokeWidth: 2, - inactiveDividerStrokeWidth: 2, - inactiveDividerStrokeColor: Colors.red, - ), - child: SfSlider.vertical( - min: 2.0, - max: 10.0, - interval: 1, - showDividers: true, - value: _value, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ) - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Divider stroke width and color support](images/label-and-divider/vertical-slider-divider-stroke-color.png) - - -## Divider color - -You can change the active and inactive divider color of the slider using the [`activeDividerColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeDividerColor.html) and [`inactiveDividerColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveDividerColor.html) properties respectively. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class DividerColorPage extends StatefulWidget { - @override - _DividerColorPageState createState() => _DividerColorPageState(); -} - -class _DividerColorPageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - activeTrackHeight: 5, - inactiveTrackHeight: 5, - activeDividerColor: Colors.red, - inactiveDividerColor: Colors.red[200], - ), - child: SfSlider( - min: 2.0, - max: 10.0, - interval: 1, - showDividers: true, - value: _value, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ) - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Divider color support](images/label-and-divider/slider-divider-color.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalDividerColorPage extends StatefulWidget { - @override - _VerticalDividerColorPageState createState() => _VerticalDividerColorPageState(); -} - -class _VerticalDividerColorPageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - activeTrackHeight: 5, - inactiveTrackHeight: 5, - activeDividerColor: Colors.red, - inactiveDividerColor: Colors.red[200], - ), - child: SfSlider.vertical( - min: 2.0, - max: 10.0, - interval: 1, - showDividers: true, - value: _value, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ) - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Divider color support](images/label-and-divider/vertical-slider-divider-color.png) +--- +layout: post +title: Labels and Dividers in Flutter Slider | Syncfusion® +description: Learn about labels and dividers in Syncfusion® Flutter Slider (SfSlider), including label formatting, divider customization, and styling options. +platform: flutter +control: SfSlider +documentation: ug +--- + +# Labels and Dividers in Flutter Slider (SfSlider) +This section explains how to add labels and dividers to the slider. + +N> You must import the `theme.dart` library from the [`Core`](https://pub.dev/packages/syncfusion_flutter_core) package to use [`SfSliderTheme`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderTheme-class.html) for customizing label and divider appearance in the examples below. You must also import the [`intl`](https://pub.dev/packages/intl) package for formatting numeric and date labels. + +## Show labels + +The [`showLabels`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/showLabels.html) property is used to render the labels on given interval. The default value of [`showLabels`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/showLabels.html) property is `false`. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class ShowLabelsPage extends StatefulWidget { + @override + _ShowLabelsPageState createState() => _ShowLabelsPageState(); +} + +class _ShowLabelsPageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider( + min: 0.0, + max: 10.0, + interval: 2, + showLabels: true, + showTicks: true, + value: _value, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Slider label support](images/label-and-divider/show-labels.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalShowLabelsPage extends StatefulWidget { + @override + _VerticalShowLabelsPageState createState() => _VerticalShowLabelsPageState(); +} + +class _VerticalShowLabelsPageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider.vertical( + min: 0.0, + max: 10.0, + interval: 2, + showLabels: true, + showTicks: true, + value: _value, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Slider label support](images/label-and-divider/vertical-show-labels.png) + +N> +* Refer the [`numberFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/numberFormat.html) and [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/dateFormat.html) for formatting the numeric and date labels respectively. +* Refer the [`SfSliderThemeData`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData-class.html) for customizing the appearance of the labels. + +## Number format + +The [`numberFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/numberFormat.html) property is used to format the numeric labels. The default value of [`numberFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/numberFormat.html) property is `null`. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class NumberFormatPage extends StatefulWidget { + @override + _NumberFormatPageState createState() => _NumberFormatPageState(); +} + +class _NumberFormatPageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider( + min: 0.0, + max: 10.0, + value: _value, + interval: 2, + showTicks: true, + showLabels: true, + numberFormat: NumberFormat('\$'), + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Number format support](images/label-and-divider/number-format.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalNumberFormatPage extends StatefulWidget { + @override + _VerticalNumberFormatPageState createState() => _VerticalNumberFormatPageState(); +} + +class _VerticalNumberFormatPageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider.vertical( + min: 0.0, + max: 10.0, + value: _value, + interval: 2, + showTicks: true, + showLabels: true, + numberFormat: NumberFormat('\$'), + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Number format support](images/label-and-divider/vertical-number-format.png) + +## Date format + +The [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/dateFormat.html) property is used to format the date labels. It is mandatory for the date [`SfSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider-class.html). For date values, the Flutter Slider does not have auto interval support. So, it is mandatory to set [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/interval.html), [`dateIntervalType`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/dateIntervalType.html), and [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/dateFormat.html) for date values. The default value of [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/dateFormat.html) property is `null`. + +### Year format +#### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class YearFormatPage extends StatefulWidget { + @override + _YearFormatPageState createState() => _YearFormatPageState(); +} + +class _YearFormatPageState extends State { + DateTime _value = DateTime(2002, 01, 01); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider( + min: DateTime(2000, 01, 01, 00), + max: DateTime(2004, 12, 31, 24), + value: _value, + interval: 1, + showLabels: true, + showTicks: true, + dateFormat: DateFormat.y(), + dateIntervalType: DateIntervalType.years, + onChanged: (DateTime newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Year date format support](images/label-and-divider/year-date-format.png) + +#### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalYearFormatPage extends StatefulWidget { + @override + _VerticalYearFormatPageState createState() => _VerticalYearFormatPageState(); +} + +class _VerticalYearFormatPageState extends State { + DateTime _value = DateTime(2002, 01, 01); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider.vertical( + min: DateTime(2000, 01, 01, 00), + max: DateTime(2004, 12, 31, 24), + value: _value, + interval: 1, + showLabels: true, + showTicks: true, + dateFormat: DateFormat.y(), + dateIntervalType: DateIntervalType.years, + onChanged: (DateTime newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Year date format support](images/label-and-divider/vertical-year-date-format.png) + +### Month format +#### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class MonthFormatPage extends StatefulWidget { + @override + _MonthFormatPageState createState() => _MonthFormatPageState(); +} + +class _MonthFormatPageState extends State { + DateTime _value = DateTime(2000, 03, 01); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider( + min: DateTime(2000, 01, 01, 00), + max: DateTime(2000, 09, 02, 00), + value: _value, + interval: 2, + showLabels: true, + showTicks: true, + dateFormat: DateFormat.yM(), + dateIntervalType: DateIntervalType.months, + onChanged: (DateTime newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Month date format support](images/label-and-divider/month-date-format.png) + +#### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalMonthFormatPage extends StatefulWidget { + @override + _VerticalMonthFormatPageState createState() => _VerticalMonthFormatPageState(); +} + +class _VerticalMonthFormatPageState extends State { + DateTime _value = DateTime(2000, 03, 01); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider.vertical( + min: DateTime(2000, 01, 01, 00), + max: DateTime(2000, 09, 02, 00), + value: _value, + interval: 2, + showLabels: true, + showTicks: true, + dateFormat: DateFormat.yM(), + dateIntervalType: DateIntervalType.months, + onChanged: (DateTime newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Month date format support](images/label-and-divider/vertical-month-date-format.png) + + +### Hour format +#### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class HourFormatPage extends StatefulWidget { + @override + _HourFormatPageState createState() => _HourFormatPageState(); +} + +class _HourFormatPageState extends State { + DateTime _value = DateTime(2000, 01, 01, 12, 00, 00); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider( + min: DateTime(2000, 01, 01, 02, 00, 00), + max: DateTime(2000, 01, 01, 22, 00, 00), + value: _value, + interval: 5, + showLabels: true, + showTicks: true, + dateFormat: DateFormat('h:mm a'), + dateIntervalType: DateIntervalType.hours, + onChanged: (DateTime newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Hour date format support](images/label-and-divider/hour-date-format.png) + +#### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalHourFormatPage extends StatefulWidget { + @override + _VerticalHourFormatPageState createState() => _VerticalHourFormatPageState(); +} + +class _VerticalHourFormatPageState extends State { + DateTime _value = DateTime(2000, 01, 01, 12, 00, 00); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider.vertical( + min: DateTime(2000, 01, 01, 02, 00, 00), + max: DateTime(2000, 01, 01, 22, 00, 00), + value: _value, + interval: 5, + showLabels: true, + showTicks: true, + dateFormat: DateFormat('h:mm a'), + dateIntervalType: DateIntervalType.hours, + onChanged: (DateTime newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Hour date format support](images/label-and-divider/vertical-hour-date-format.png) + +N> Refer the [`DateFormat`](https://pub.dev/documentation/intl/latest/intl/DateFormat-class.html) class for other date format. + +## Label placement + +The [`labelPlacement`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/labelPlacement.html) property is used to place the labels either between the major ticks or on the major ticks. The default value of the [`labelPlacement`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/labelPlacement.html) property is `LabelPlacement.onTicks`. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class LabelPlacementPage extends StatefulWidget { + @override + _LabelPlacementPageState createState() => _LabelPlacementPageState(); +} + +class _LabelPlacementPageState extends State { + DateTime _value = DateTime(2002, 01, 01); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider( + min: DateTime(2000, 01, 01, 00), + max: DateTime(2004, 12, 31, 24), + value: _value, + interval: 1, + showLabels: true, + showTicks: true, + labelPlacement: LabelPlacement.betweenTicks, + dateFormat: DateFormat.y(), + dateIntervalType: DateIntervalType.years, + onChanged: (DateTime newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Label placement support](images/label-and-divider/label-placement.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalLabelPlacementPage extends StatefulWidget { + @override + _VerticalLabelPlacementPageState createState() => _VerticalLabelPlacementPageState(); +} + +class _VerticalLabelPlacementPageState extends State { + DateTime _value = DateTime(2002, 01, 01); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider.vertical( + min: DateTime(2000, 01, 01, 00), + max: DateTime(2004, 12, 31, 24), + value: _value, + interval: 1, + showLabels: true, + showTicks: true, + labelPlacement: LabelPlacement.betweenTicks, + dateFormat: DateFormat.y(), + dateIntervalType: DateIntervalType.years, + onChanged: (DateTime newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Label placement support](images/label-and-divider/vertical-label-placement.png) + +## Edge label placement + +The [`edgeLabelPlacement`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/edgeLabelPlacement.html) property determines how the edge (first and last) labels are positioned on the slider. This property allows the edge labels to be placed either inside the major ticks or directly on the major ticks. + +The default value of the [`edgeLabelPlacement`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/edgeLabelPlacement.html) property is `EdgeLabelPlacement.auto`. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class EdgeLabelPlacementPage extends StatefulWidget { + @override + _EdgeLabelPlacementPageState createState() => _EdgeLabelPlacementPageState(); +} + +class _EdgeLabelPlacementPageState extends State { + DateTime _value = DateTime(2002, 01, 01); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider( + min: DateTime(2000, 01, 01, 00), + max: DateTime(2004, 12, 31, 24), + value: _value, + interval: 1, + showLabels: true, + showTicks: true, + edgeLabelPlacement: EdgeLabelPlacement.inside, + dateFormat: DateFormat.y(), + dateIntervalType: DateIntervalType.years, + onChanged: (DateTime newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Edge Label placement support](images/label-and-divider/edge-label-placement.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalEdgeLabelPlacementPage extends StatefulWidget { + @override + _VerticalEdgeLabelPlacementPageState createState() => _VerticalEdgeLabelPlacementPageState(); +} + +class _VerticalEdgeLabelPlacementPageState extends State { + DateTime _value = DateTime(2002, 01, 01); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider.vertical( + min: DateTime(2000, 01, 01, 00), + max: DateTime(2004, 12, 31, 24), + value: _value, + interval: 1, + showLabels: true, + showTicks: true, + edgeLabelPlacement: EdgeLabelPlacement.inside, + dateFormat: DateFormat.y(), + dateIntervalType: DateIntervalType.years, + onChanged: (DateTime newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Edge Label placement support](images/label-and-divider/vertical-edge-label-placement.png) + +## Customize label text + +You can format or change the whole numeric or date label text using the [`labelFormatterCallback`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/labelFormatterCallback.html). Its arguments are, + +* actualValue – either `DateTime` or `double` based on given [`value`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/value.html). +* formattedText – If the actual value is `double`, it is formatted by [`numberFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/numberFormat.html) and if the actual value is `DateTime`, it is formatted by [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/dateFormat.html). + +>**NOTE** +* [`labelFormatterCallback`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/labelFormatterCallback.html) has been deprecated, you can use [`onLabelCreated`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/onLabelCreated.html) callback to customize both the text and text style of the label. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class LabelFormatterPage extends StatefulWidget { + @override + _LabelFormatterPageState createState() => _LabelFormatterPageState(); +} + +class _LabelFormatterPageState extends State { + double _value = 9900.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider( + min: 100.0, + max: 10000.0, + value: _value, + showLabels: true, + interval: 9900, + labelFormatterCallback: (dynamic actualValue, String formattedText) { + return actualValue == 10000 ? '\$ $formattedText+' : '\$ $formattedText'; + }, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Label formatter support](images/label-and-divider/label-formattercallback.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalLabelFormatterPage extends StatefulWidget { + @override + _VerticalLabelFormatterPageState createState() => _VerticalLabelFormatterPageState(); +} + +class _VerticalLabelFormatterPageState extends State { + double _value = 9900.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider.vertical( + min: 100.0, + max: 10000.0, + value: _value, + showLabels: true, + interval: 9900, + labelFormatterCallback: (dynamic actualValue, String formattedText) { + return actualValue == 10000 ? '\$ $formattedText+' : '\$ $formattedText'; + }, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Label formatter support](images/label-and-divider/vertical-label-formattercallback.png) + +## Label style + +You can change the active and inactive label appearance of the Flutter Slider using the [`activeLabelStyle`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeLabelStyle.html) and [`inactiveLabelStyle`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveLabelStyle.html) properties respectively. + +The active side of the Flutter Slider is between the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html) value and the thumb. + +The inactive side of the Flutter Slider is between the thumb and the [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) value. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class LabelStylePage extends StatefulWidget { + @override + _LabelStylePageState createState() => _LabelStylePageState(); +} + +class _LabelStylePageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + activeLabelStyle: TextStyle(color: Colors.red, fontSize: 12, fontStyle: FontStyle.italic), + inactiveLabelStyle: TextStyle(color: Colors.red[200], fontSize: 12, fontStyle: FontStyle.italic), + ), + child: SfSlider( + min: 2.0, + max: 10.0, + value: _value, + interval: 1, + showLabels: true, + showTicks: true, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Labels style support](images/label-and-divider/slider-labels-color.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalLabelStylePage extends StatefulWidget { + @override + _VerticalLabelStylePageState createState() => _VerticalLabelStylePageState(); +} + +class _VerticalLabelStylePageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + activeLabelStyle: TextStyle(color: Colors.red, fontSize: 12, fontStyle: FontStyle.italic), + inactiveLabelStyle: TextStyle(color: Colors.red[200], fontSize: 12, fontStyle: FontStyle.italic), + ), + child: SfSlider.vertical( + min: 2.0, + max: 10.0, + value: _value, + interval: 1, + showLabels: true, + showTicks: true, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Labels style support](images/label-and-divider/vertical-slider-labels-color.png) + +## Individual label style + +You can customize the appearance of each label on the [`SfSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider-class.html) individually by using the [`onLabelCreated`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/onLabelCreated.html) callback. This callback allows you to have complete control over the text and text style for each label. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class IndividualLabelPage extends StatefulWidget { + @override + _IndividualLabelPageState createState() => _IndividualLabelPageState(); +} + +class _IndividualLabelPageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: SfSlider( + min: 2.0, + max: 10.0, + value: _value, + interval: 1, + showLabels: true, + showTicks: true, + onChanged: (double value) { + setState(() { + _value = value; + }); + }, + onLabelCreated: ( + dynamic actualValue, + String text, + TextStyle labelTextStyle, + ) { + return SliderLabel( + text: text, + textStyle: + actualValue == _value.toInt() + ? const TextStyle( + color: Colors.blue, + fontSize: 14, + ) + : TextStyle( + color: Colors.red[200], + fontSize: 10, + ), + ); + }, + ), + ), + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Individual label style support](images/label-and-divider/slider-individual-label-color.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalIndividualLabelsPage extends StatefulWidget { + @override + _VerticalIndividualLabelsPageState createState() => _VerticalIndividualLabelsPageState(); +} + +class _VerticalIndividualLabelsPageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: SfSlider.vertical( + min: 2.0, + max: 10.0, + value: _value, + interval: 1, + showLabels: true, + showTicks: true, + onChanged: (double value) { + setState(() { + _value = value; + }); + }, + onLabelCreated: ( + dynamic actualValue, + String text, + TextStyle labelTextStyle, + ) { + return SliderLabel( + text: text, + textStyle: + actualValue == _value.toInt() + ? const TextStyle( + color: Colors.blue, + fontSize: 14, + ) + : TextStyle( + color: Colors.red[200], + fontSize: 10, + ), + ); + }, + ), + ), + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Individual label style support](images/label-and-divider/vertical-slider-individual-label-color.png) + +## Label offset + +You can adjust the space between ticks and labels of the Flutter Slider using the [`labelOffset`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/labelOffset.html) property. + +### Horizontal + +The default value of [`labelOffset`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/labelOffset.html) property is `Offset(0.0, 13.0)` if the [`showTicks`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/showTicks.html) property is `false`. +The default value of [`labelOffset`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/labelOffset.html) property is `Offset(0.0, 5.0)` if the [`showTicks`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/showTicks.html) property is `true`. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class LabelOffsetPage extends StatefulWidget { + @override + _LabelOffsetPageState createState() => _LabelOffsetPageState(); +} + +class _LabelOffsetPageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + labelOffset: Offset(0.0, 10.0), + ), + child: SfSlider( + min: 2.0, + max: 10.0, + value: _value, + interval: 2, + showTicks: true, + showLabels: true, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Labels offset support](images/label-and-divider/slider-labels-offset.png) + +### Vertical + +The default value of [`labelOffset`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/labelOffset.html) property is `Offset(13.0, 0.0)` if the [`showTicks`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/showTicks.html) property is `false`. +The default value of [`labelOffset`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/labelOffset.html) property is `Offset(5.0, 0.0)` if the [`showTicks`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/showTicks.html) property is `true`. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalLabelOffsetPage extends StatefulWidget { + @override + _VerticalLabelOffsetPageState createState() => _VerticalLabelOffsetPageState(); +} + +class _VerticalLabelOffsetPageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + labelOffset: Offset(10.0, 0.0), + ), + child: SfSlider.vertical( + min: 2.0, + max: 10.0, + value: _value, + interval: 2, + showTicks: true, + showLabels: true, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Labels offset support](images/label-and-divider/vertical-slider-labels-offset.png) + +## Show dividers + +The [`showDividers`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/showDividers.html) property is used to render the dividers on the track. The default value of the [`showDividers`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/showDividers.html) property is `false`. It is a shape which is used to represent the major interval points of the track. + +For example, if [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html) is 0.0 and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) is 10.0 and [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/interval.html) is 2.0, the Flutter Slider will render the dividers at 0.0, 2.0, 4.0 and so on. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class ShowDividersPage extends StatefulWidget { + @override + _ShowDividersPageState createState() => _ShowDividersPageState(); +} + +class _ShowDividersPageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + activeTrackHeight: 5, + inactiveTrackHeight: 5, + ), + child: SfSlider( + min: 0.0, + max: 10.0, + interval: 2, + showDividers: true, + value: _value, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Slider divider support](images/label-and-divider/show-divider.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalShowDividersPage extends StatefulWidget { + @override + _VerticalShowDividersPageState createState() => _VerticalShowDividersPageState(); +} + +class _VerticalShowDividersPageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + activeTrackHeight: 5, + inactiveTrackHeight: 5, + ), + child: SfSlider.vertical( + min: 0.0, + max: 10.0, + interval: 2, + showDividers: true, + value: _value, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Slider divider support](images/label-and-divider/vertical-show-divider.png) + +## Divider radius + +You can change the active and inactive divider radius of the Flutter Slider using the [`activeDividerRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeDividerRadius.html) and the [`inactiveDividerRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveDividerRadius.html) properties respectively. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class DividerRadiusPage extends StatefulWidget { + @override + _DividerRadiusPageState createState() => _DividerRadiusPageState(); +} + +class _DividerRadiusPageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + activeTrackHeight: 10, + inactiveTrackHeight: 10, + activeDividerRadius: 5, + inactiveDividerRadius: 5, + ), + child: SfSlider( + min: 2.0, + max: 10.0, + interval: 1, + showDividers: true, + value: _value, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ) + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Divider radius support](images/label-and-divider/slider-divider-radius.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalDividerRadiusPage extends StatefulWidget { + @override + _VerticalDividerRadiusPageState createState() => _VerticalDividerRadiusPageState(); +} + +class _VerticalDividerRadiusPageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + activeTrackHeight: 10, + inactiveTrackHeight: 10, + activeDividerRadius: 5, + inactiveDividerRadius: 5, + ), + child: SfSlider.vertical( + min: 2.0, + max: 10.0, + interval: 1, + showDividers: true, + value: _value, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ) + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Divider radius support](images/label-and-divider/vertical-slider-divider-radius.png) + + +## Divider stroke width and stroke color + +You can change the active and inactive divider stroke width of the Flutter Slider using the [`activeDividerStrokeWidth`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeDividerStrokeWidth.html) and the [`inactiveDividerStrokeWidth`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveDividerStrokeWidth.html) properties respectively. + +Also, you can change the active and inactive divider stroke color of the Flutter Slider using the [`activeDividerStrokeColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeDividerStrokeColor.html) and the [`inactiveDividerStrokeColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveDividerStrokeColor.html) properties respectively. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class DividerStrokePage extends StatefulWidget { + @override + _DividerStrokePageState createState() => _DividerStrokePageState(); +} + +class _DividerStrokePageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + activeTrackHeight: 10, + inactiveTrackHeight: 10, + activeDividerStrokeColor: Colors.red, + activeDividerStrokeWidth: 2, + inactiveDividerStrokeWidth: 2, + inactiveDividerStrokeColor: Colors.red, + ), + child: SfSlider( + min: 2.0, + max: 10.0, + interval: 1, + showDividers: true, + value: _value, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ) + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Divider stroke width and color support](images/label-and-divider/slider-divider-stroke-color.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalDividerStrokePage extends StatefulWidget { + @override + _VerticalDividerStrokePageState createState() => _VerticalDividerStrokePageState(); +} + +class _VerticalDividerStrokePageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + activeTrackHeight: 10, + inactiveTrackHeight: 10, + activeDividerStrokeColor: Colors.red, + activeDividerStrokeWidth: 2, + inactiveDividerStrokeWidth: 2, + inactiveDividerStrokeColor: Colors.red, + ), + child: SfSlider.vertical( + min: 2.0, + max: 10.0, + interval: 1, + showDividers: true, + value: _value, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ) + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Divider stroke width and color support](images/label-and-divider/vertical-slider-divider-stroke-color.png) + + +## Divider color + +You can change the active and inactive divider color of the Flutter Slider using the [`activeDividerColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeDividerColor.html) and [`inactiveDividerColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveDividerColor.html) properties respectively. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class DividerColorPage extends StatefulWidget { + @override + _DividerColorPageState createState() => _DividerColorPageState(); +} + +class _DividerColorPageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + activeTrackHeight: 5, + inactiveTrackHeight: 5, + activeDividerColor: Colors.red, + inactiveDividerColor: Colors.red[200], + ), + child: SfSlider( + min: 2.0, + max: 10.0, + interval: 1, + showDividers: true, + value: _value, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ) + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Divider color support](images/label-and-divider/slider-divider-color.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalDividerColorPage extends StatefulWidget { + @override + _VerticalDividerColorPageState createState() => _VerticalDividerColorPageState(); +} + +class _VerticalDividerColorPageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + activeTrackHeight: 5, + inactiveTrackHeight: 5, + activeDividerColor: Colors.red, + inactiveDividerColor: Colors.red[200], + ), + child: SfSlider.vertical( + min: 2.0, + max: 10.0, + interval: 1, + showDividers: true, + value: _value, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ) + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Divider color support](images/label-and-divider/vertical-slider-divider-color.png) diff --git a/Flutter/slider/right-to-left.md b/Flutter/slider/right-to-left.md index b6b5ade4e..5266267ae 100644 --- a/Flutter/slider/right-to-left.md +++ b/Flutter/slider/right-to-left.md @@ -1,137 +1,137 @@ ---- -layout: post -title: Right-to-Left (RTL) in Flutter Slider | Syncfusion® -description: Learn about right-to-left (RTL) support in Syncfusion® Flutter Slider (SfSlider), including layout customization, localization, and RTL rendering. -platform: flutter -control: SfSlider -documentation: ug ---- - -# Right-to-Left (RTL) in Flutter Slider (SfSlider) - -## RTL rendering ways - -Right-to-left rendering can be achieved in the following ways: - -### Wrapping the SfSlider with Directionality widget - -The slider can be wrapped inside the [`Directionality`](https://api.flutter.dev/flutter/widgets/Directionality-class.html) widget and you can set the [`textDirection`](https://api.flutter.dev/flutter/widgets/Directionality/textDirection.html) property to `rtl`. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class RTLDirectionalityPage extends StatefulWidget { - @override - _RTLDirectionalityPageState createState() => _RTLDirectionalityPageState(); -} - -class _RTLDirectionalityPageState extends State { - double _value = 40.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Directionality( - textDirection: TextDirection.rtl, - child: Center( - child: SfSlider( - min: 0.0, - max: 100.0, - value: _value, - interval: 20, - showTicks: true, - showLabels: true, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ), - ) - ), - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -### Changing the locale to RTL languages - -The slider will render in right to left direction if the locale belongs to RTL languages such as (Arabic, Persian, Hebrew, Pashto, Urdu). It can be achieved by specifying the MaterialApp properties such as `localizationsDelegates`, `supportedLocales`, `locale` and adding the flutter_localizations package to your pubspec.yaml file. - -N> The Persian (Farsi) locale `Locale("fa", "IR")` is used in the example below. Replace it with your desired RTL locale (e.g., `Locale("ar")` for Arabic, `Locale("he")` for Hebrew, `Locale("ps")` for Pashto, or `Locale("ur")` for Urdu). - -**Add the flutter_localizations dependency** - -Add the `flutter_localizations` package to your pubspec.yaml file. - -{% tabs %} -{% highlight yaml %} - -dependencies: - flutter_localizations: - sdk: flutter - -{% endhighlight %} -{% endtabs %} - -N> Add the `flutter_localizations` package to your pubspec.yaml and run `flutter pub get` to fetch it. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:flutter_localizations/flutter_localizations.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class RTLLocalePage extends StatefulWidget { - @override - _RTLLocalePageState createState() => _RTLLocalePageState(); -} - -class _RTLLocalePageState extends State { - double _value = 40.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - localizationsDelegates: [ - GlobalMaterialLocalizations.delegate, - GlobalWidgetsLocalizations.delegate, - ], - supportedLocales: [ - Locale("fa", "IR"), - ], - locale: Locale("fa", "IR"), - home: Scaffold( - backgroundColor: Colors.white, - body: SfSlider( - min: 0.0, - max: 100.0, - value: _value, - interval: 20, - showLabels: true, - showTicks: true, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ), - ); - } -} - -{% endhighlight %} -{% endtabs %} - -N> RTL is not applicable for vertical orientation of the slider. - +--- +layout: post +title: Right-to-Left (RTL) in Flutter Slider | Syncfusion® +description: Learn about right-to-left (RTL) support in Syncfusion® Flutter Slider (SfSlider), including layout customization, localization, and RTL rendering. +platform: flutter +control: SfSlider +documentation: ug +--- + +# Right-to-Left (RTL) in Flutter Slider (SfSlider) + +## RTL rendering ways + +Right-to-left rendering can be achieved in the following ways: + +### Wrapping the SfSlider with Directionality widget + +The Flutter Slider can be wrapped inside the [`Directionality`](https://api.flutter.dev/flutter/widgets/Directionality-class.html) widget and you can set the [`textDirection`](https://api.flutter.dev/flutter/widgets/Directionality/textDirection.html) property to `rtl`. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class RTLDirectionalityPage extends StatefulWidget { + @override + _RTLDirectionalityPageState createState() => _RTLDirectionalityPageState(); +} + +class _RTLDirectionalityPageState extends State { + double _value = 40.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Directionality( + textDirection: TextDirection.rtl, + child: Center( + child: SfSlider( + min: 0.0, + max: 100.0, + value: _value, + interval: 20, + showTicks: true, + showLabels: true, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ), + ) + ), + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +### Changing the locale to RTL languages + +The Flutter Slider will render in right to left direction if the locale belongs to RTL languages such as (Arabic, Persian, Hebrew, Pashto, Urdu). It can be achieved by specifying the MaterialApp properties such as `localizationsDelegates`, `supportedLocales`, `locale` and adding the flutter_localizations package to your pubspec.yaml file. + +N> The Persian (Farsi) locale `Locale("fa", "IR")` is used in the example below. Replace it with your desired RTL locale (e.g., `Locale("ar")` for Arabic, `Locale("he")` for Hebrew, `Locale("ps")` for Pashto, or `Locale("ur")` for Urdu). + +**Add the flutter_localizations dependency** + +Add the `flutter_localizations` package to your pubspec.yaml file. + +{% tabs %} +{% highlight yaml %} + +dependencies: + flutter_localizations: + sdk: flutter + +{% endhighlight %} +{% endtabs %} + +N> Add the `flutter_localizations` package to your pubspec.yaml and run `flutter pub get` to fetch it. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:flutter_localizations/flutter_localizations.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class RTLLocalePage extends StatefulWidget { + @override + _RTLLocalePageState createState() => _RTLLocalePageState(); +} + +class _RTLLocalePageState extends State { + double _value = 40.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + localizationsDelegates: [ + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + ], + supportedLocales: [ + Locale("fa", "IR"), + ], + locale: Locale("fa", "IR"), + home: Scaffold( + backgroundColor: Colors.white, + body: SfSlider( + min: 0.0, + max: 100.0, + value: _value, + interval: 20, + showLabels: true, + showTicks: true, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ), + ); + } +} + +{% endhighlight %} +{% endtabs %} + +N> RTL is not applicable for vertical orientation of the slider. + ![RTL support](images/right-to-left/right-to-left-support.png) \ No newline at end of file diff --git a/Flutter/slider/shapes.md b/Flutter/slider/shapes.md index 3b8be08c3..3fb58d3aa 100644 --- a/Flutter/slider/shapes.md +++ b/Flutter/slider/shapes.md @@ -1,398 +1,398 @@ ---- -layout: post -title: Custom Shapes in Flutter Slider | Syncfusion® -description: Learn about custom shapes in Syncfusion® Flutter Slider (SfSlider), including track, thumb, divider, tick, and tooltip customization. -platform: flutter -control: SfSlider -documentation: ug ---- - -# Custom Shapes in Flutter Slider (SfSlider) - -This section explains how to customize slider shape elements—track, thumb, divider, and ticks. - -N> You must import the `theme.dart` library from the [`Core`](https://pub.dev/packages/syncfusion_flutter_core) package to use [`SfSliderTheme`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderTheme-class.html) in all the examples shown below. Define each custom shape class outside your widget class so the slider can reference it. - -## Track shape - -You can change the size and shape of the track using the [`trackShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/trackShape.html) property in the [`SfSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider-class.html). - -* getPreferredSize() - Returns the size based on the values passed to it. -* paint() - Used to change the track shape. - -N> -* You must use the `thumbCenter` and `currentValue` parameters of paint override method for customizing slider track. -* You must use the `startThumbCenter`, `endThumbCenter`, and `currentValues` parameters of paint override method for customizing range slider and range selector track. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class TrackShapePage extends StatefulWidget { - @override - _TrackShapePageState createState() => _TrackShapePageState(); -} - -class _TrackShapePageState extends State { - double _value = 5.0; - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - activeTrackHeight: 10, - inactiveTrackHeight: 10, - ), - child: SfSlider( - min: 0.0, - max: 10.0, - value: _value, - trackShape: _SfTrackShape(), - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ), - ), - ); - } -} - -class _SfTrackShape extends SfTrackShape { - @override - void paint(PaintingContext context, Offset offset, Offset? thumbCenter, - Offset? startThumbCenter, Offset? endThumbCenter, - {required RenderBox parentBox, - required SfSliderThemeData themeData, - SfRangeValues? currentValues, - dynamic currentValue, - required Animation enableAnimation, - required Paint? inactivePaint, - required Paint? activePaint, - required TextDirection textDirection}) { - Paint paint = Paint() - ..color = themeData.activeTrackColor! - ..style = PaintingStyle.stroke - ..strokeWidth = 1; - super.paint(context, offset, thumbCenter, startThumbCenter, endThumbCenter, - parentBox: parentBox, - themeData: themeData, - enableAnimation: enableAnimation, - inactivePaint: inactivePaint, - activePaint: paint, - textDirection: textDirection); - } -} - -{% endhighlight %} -{% endtabs %} - -![Track shape](images/shapes/track-shape.png) - -## Thumb shape - -You can change the size and shape of the thumb using the [`thumbShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/thumbShape.html) property in the [`SfSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider-class.html). - -* getPreferredSize() - Returns the size based on the values passed to it. -* paint() - Used to change the thumb shape. - -N> -* You must use the `currentValue` parameter of paint override method for customizing slider thumb. -* You must use the `currentValues` parameter of paint override method for customizing range slider and range selector thumbs. - -I> The `themeData.activeTrackColor` may be `null`. The null assertion operator (`!`) is used here for brevity; in production code, prefer a fallback (e.g., `themeData.activeTrackColor ?? Colors.red`) to avoid null errors. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class ThumbShapePage extends StatefulWidget { - @override - _ThumbShapePageState createState() => _ThumbShapePageState(); -} - -class _ThumbShapePageState extends State { - double _value = 4.0; - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData(overlayRadius: 0), - child: SfSlider( - min: 2.0, - max: 10.0, - value: _value, - thumbShape: _SfThumbShape(), - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ), - ), - ); - } -} - -class _SfThumbShape extends SfThumbShape { - @override - void paint(PaintingContext context, Offset center, - {required RenderBox parentBox, - required RenderBox? child, - required SfSliderThemeData themeData, - SfRangeValues? currentValues, - dynamic currentValue, - required Paint? paint, - required Animation enableAnimation, - required TextDirection textDirection, - required SfThumb? thumb}) { - final Path path = Path(); - - path.moveTo(center.dx, center.dy); - path.lineTo(center.dx + 10, center.dy - 15); - path.lineTo(center.dx - 10, center.dy - 15); - path.close(); - context.canvas.drawPath( - path, - Paint() - ..color = themeData.activeTrackColor! - ..style = PaintingStyle.fill - ..strokeWidth = 2); - } -} - -{% endhighlight %} -{% endtabs %} - -![Thumb shape](images/shapes/thumb-shape.png) - -## Divider shape - -You can change the size and shape of the divider using the [`dividerShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/dividerShape.html) property in the [`SfSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider-class.html). - -* getPreferredSize() - Returns the size based on the values passed to it. -* paint() - Used to change the divider shape. - -N> -* You must use the `thumbCenter` and `currentValue` parameters of paint override method for customizing slider divider. -* You must use the `startThumbCenter`, `endThumbCenter`, and `currentValues` parameters of paint override method for customizing range slider and range selector divider. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class DividerShapePage extends StatefulWidget { - @override - _DividerShapePageState createState() => _DividerShapePageState(); -} - -class _DividerShapePageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return Scaffold( - body: SfSlider( - min: 2.0, - max: 10.0, - value: _value, - interval: 1, - showDividers: true, - dividerShape: _DividerShape(), - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ); - } -} - -class _DividerShape extends SfDividerShape { - @override - void paint(PaintingContext context, Offset center, Offset? thumbCenter, - Offset? startThumbCenter, Offset? endThumbCenter, - {required RenderBox parentBox, - required SfSliderThemeData themeData, - SfRangeValues? currentValues, - dynamic currentValue, - required Paint? paint, - required Animation enableAnimation, - required TextDirection textDirection}) { - bool isActive = false; - - switch (textDirection) { - case TextDirection.ltr: - isActive = center.dx <= thumbCenter!.dx; - break; - case TextDirection.rtl: - isActive = center.dx >= thumbCenter!.dx; - break; - } - - context.canvas.drawRect( - Rect.fromCenter(center: center, width: 5.0, height: 10.0), - Paint() - ..isAntiAlias = true - ..style = PaintingStyle.fill - ..color = isActive ? themeData.activeTrackColor! : Colors.white); - } -} - -{% endhighlight %} -{% endtabs %} - -![Divider shape](images/shapes/divider-shape.png) - -## Major and minor ticks shapes - -You can change the size and shape of the major and minor ticks using the [`tickShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/tickShape.html) and [`minorTickShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/minorTickShape.html) properties in the [`SfSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider-class.html). - -* getPreferredSize() - Returns the size based on the values passed to it. -* paint() - Used to change the ticks shape. - -N> -* You must use the `thumbCenter` and `currentValue` parameters of paint override method for customizing slider ticks. -* You must use the `startThumbCenter`, `endThumbCenter`, and `currentValues` parameters of paint override method for customizing range slider and range selector ticks. - -{% tabs %} -{% highlight Dart %} - -import 'dart:math' as math; - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class TicksShapePage extends StatefulWidget { - @override - _TicksShapePageState createState() => _TicksShapePageState(); -} - -class _TicksShapePageState extends State { - double _value = 5.0; - - @override - Widget build(BuildContext context) { - return Scaffold( - body: SfSlider( - min: 0.0, - max: 10.0, - value: _value, - interval: 1, - showTicks: true, - minorTicksPerInterval: 3, - tickShape: _SfTickShape(), - minorTickShape: _SfMinorTickShape(), - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ); - } -} - -class _SfTickShape extends SfTickShape { - @override - void paint(PaintingContext context, Offset offset, Offset? thumbCenter, - Offset? startThumbCenter, Offset? endThumbCenter, - {required RenderBox parentBox, - required SfSliderThemeData themeData, - SfRangeValues? currentValues, - dynamic currentValue, - required Animation enableAnimation, - required TextDirection textDirection}) { - final Size tickSize = getPreferredSize(themeData); - final bool isTickRightOfThumb = offset.dx > thumbCenter!.dx; - final Color begin = isTickRightOfThumb - ? themeData.disabledInactiveTickColor - : themeData.disabledActiveTickColor; - final Color end = isTickRightOfThumb - ? themeData.inactiveTickColor - : themeData.activeTickColor; - final Paint paint = Paint() - ..isAntiAlias = true - ..strokeWidth = tickSize.width - ..color = ColorTween(begin: begin, end: end).evaluate(enableAnimation)!; - - context.canvas.drawLine( - Offset( - offset.dx, - offset.dy - - 2 - - math.max(themeData.activeTrackHeight, - themeData.inactiveTrackHeight)), - Offset( - offset.dx, - offset.dy - - 2 - - math.max(themeData.activeTrackHeight, - themeData.inactiveTrackHeight) - - tickSize.height), - paint); - } -} - -class _SfMinorTickShape extends SfTickShape { - @override - void paint(PaintingContext context, Offset offset, Offset? thumbCenter, - Offset? startThumbCenter, Offset? endThumbCenter, - {required RenderBox parentBox, - required SfSliderThemeData themeData, - SfRangeValues? currentValues, - dynamic currentValue, - required Animation enableAnimation, - required TextDirection textDirection}) { - final Size minorTickSize = getPreferredSize(themeData); - final bool isMinorTickRightOfThumb = offset.dx > thumbCenter!.dx; - - final Color begin = isMinorTickRightOfThumb - ? themeData.disabledInactiveMinorTickColor - : themeData.disabledActiveMinorTickColor; - final Color end = isMinorTickRightOfThumb - ? themeData.inactiveMinorTickColor - : themeData.activeMinorTickColor; - final Paint paint = Paint() - ..isAntiAlias = true - ..strokeWidth = minorTickSize.width - ..color = ColorTween(begin: begin, end: end).evaluate(enableAnimation)!; - - context.canvas.drawLine( - Offset( - offset.dx, - offset.dy - - 2 - - math.max(themeData.activeTrackHeight, - themeData.inactiveTrackHeight)), - Offset( - offset.dx, - offset.dy - - 2 - - math.max(themeData.activeTrackHeight, - themeData.inactiveTrackHeight) - - minorTickSize.height), - paint); - } -} - -{% endhighlight %} -{% endtabs %} - +--- +layout: post +title: Custom Shapes in Flutter Slider | Syncfusion® +description: Learn about custom shapes in Syncfusion® Flutter Slider (SfSlider), including track, thumb, divider, tick, and tooltip customization. +platform: flutter +control: SfSlider +documentation: ug +--- + +# Custom Shapes in Flutter Slider (SfSlider) + +This section explains how to customize shape elements of the Flutter Slider—track, thumb, divider, and ticks. + +N> You must import the `theme.dart` library from the [`Core`](https://pub.dev/packages/syncfusion_flutter_core) package to use [`SfSliderTheme`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderTheme-class.html) in all the examples shown below. Define each custom shape class outside your widget class so the Flutter Slider can reference it. + +## Track shape + +You can change the size and shape of the track using the [`trackShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/trackShape.html) property in the [`SfSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider-class.html). + +* getPreferredSize() - Returns the size based on the values passed to it. +* paint() - Used to change the track shape. + +N> +* You must use the `thumbCenter` and `currentValue` parameters of paint override method for customizing slider track. +* You must use the `startThumbCenter`, `endThumbCenter`, and `currentValues` parameters of paint override method for customizing range slider and range selector track. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class TrackShapePage extends StatefulWidget { + @override + _TrackShapePageState createState() => _TrackShapePageState(); +} + +class _TrackShapePageState extends State { + double _value = 5.0; + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + activeTrackHeight: 10, + inactiveTrackHeight: 10, + ), + child: SfSlider( + min: 0.0, + max: 10.0, + value: _value, + trackShape: _SfTrackShape(), + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ), + ), + ); + } +} + +class _SfTrackShape extends SfTrackShape { + @override + void paint(PaintingContext context, Offset offset, Offset? thumbCenter, + Offset? startThumbCenter, Offset? endThumbCenter, + {required RenderBox parentBox, + required SfSliderThemeData themeData, + SfRangeValues? currentValues, + dynamic currentValue, + required Animation enableAnimation, + required Paint? inactivePaint, + required Paint? activePaint, + required TextDirection textDirection}) { + Paint paint = Paint() + ..color = themeData.activeTrackColor! + ..style = PaintingStyle.stroke + ..strokeWidth = 1; + super.paint(context, offset, thumbCenter, startThumbCenter, endThumbCenter, + parentBox: parentBox, + themeData: themeData, + enableAnimation: enableAnimation, + inactivePaint: inactivePaint, + activePaint: paint, + textDirection: textDirection); + } +} + +{% endhighlight %} +{% endtabs %} + +![Track shape](images/shapes/track-shape.png) + +## Thumb shape + +You can change the size and shape of the thumb using the [`thumbShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/thumbShape.html) property in the [`SfSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider-class.html). + +* getPreferredSize() - Returns the size based on the values passed to it. +* paint() - Used to change the thumb shape. + +N> +* You must use the `currentValue` parameter of paint override method for customizing slider thumb. +* You must use the `currentValues` parameter of paint override method for customizing range slider and range selector thumbs. + +I> The `themeData.activeTrackColor` may be `null`. The null assertion operator (`!`) is used here for brevity; in production code, prefer a fallback (e.g., `themeData.activeTrackColor ?? Colors.red`) to avoid null errors. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class ThumbShapePage extends StatefulWidget { + @override + _ThumbShapePageState createState() => _ThumbShapePageState(); +} + +class _ThumbShapePageState extends State { + double _value = 4.0; + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData(overlayRadius: 0), + child: SfSlider( + min: 2.0, + max: 10.0, + value: _value, + thumbShape: _SfThumbShape(), + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ), + ), + ); + } +} + +class _SfThumbShape extends SfThumbShape { + @override + void paint(PaintingContext context, Offset center, + {required RenderBox parentBox, + required RenderBox? child, + required SfSliderThemeData themeData, + SfRangeValues? currentValues, + dynamic currentValue, + required Paint? paint, + required Animation enableAnimation, + required TextDirection textDirection, + required SfThumb? thumb}) { + final Path path = Path(); + + path.moveTo(center.dx, center.dy); + path.lineTo(center.dx + 10, center.dy - 15); + path.lineTo(center.dx - 10, center.dy - 15); + path.close(); + context.canvas.drawPath( + path, + Paint() + ..color = themeData.activeTrackColor! + ..style = PaintingStyle.fill + ..strokeWidth = 2); + } +} + +{% endhighlight %} +{% endtabs %} + +![Thumb shape](images/shapes/thumb-shape.png) + +## Divider shape + +You can change the size and shape of the divider using the [`dividerShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/dividerShape.html) property in the [`SfSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider-class.html). + +* getPreferredSize() - Returns the size based on the values passed to it. +* paint() - Used to change the divider shape. + +N> +* You must use the `thumbCenter` and `currentValue` parameters of paint override method for customizing slider divider. +* You must use the `startThumbCenter`, `endThumbCenter`, and `currentValues` parameters of paint override method for customizing range slider and range selector divider. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class DividerShapePage extends StatefulWidget { + @override + _DividerShapePageState createState() => _DividerShapePageState(); +} + +class _DividerShapePageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SfSlider( + min: 2.0, + max: 10.0, + value: _value, + interval: 1, + showDividers: true, + dividerShape: _DividerShape(), + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ); + } +} + +class _DividerShape extends SfDividerShape { + @override + void paint(PaintingContext context, Offset center, Offset? thumbCenter, + Offset? startThumbCenter, Offset? endThumbCenter, + {required RenderBox parentBox, + required SfSliderThemeData themeData, + SfRangeValues? currentValues, + dynamic currentValue, + required Paint? paint, + required Animation enableAnimation, + required TextDirection textDirection}) { + bool isActive = false; + + switch (textDirection) { + case TextDirection.ltr: + isActive = center.dx <= thumbCenter!.dx; + break; + case TextDirection.rtl: + isActive = center.dx >= thumbCenter!.dx; + break; + } + + context.canvas.drawRect( + Rect.fromCenter(center: center, width: 5.0, height: 10.0), + Paint() + ..isAntiAlias = true + ..style = PaintingStyle.fill + ..color = isActive ? themeData.activeTrackColor! : Colors.white); + } +} + +{% endhighlight %} +{% endtabs %} + +![Divider shape](images/shapes/divider-shape.png) + +## Major and minor ticks shapes + +You can change the size and shape of the major and minor ticks using the [`tickShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/tickShape.html) and [`minorTickShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/minorTickShape.html) properties in the [`SfSlider`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider-class.html). + +* getPreferredSize() - Returns the size based on the values passed to it. +* paint() - Used to change the ticks shape. + +N> +* You must use the `thumbCenter` and `currentValue` parameters of paint override method for customizing slider ticks. +* You must use the `startThumbCenter`, `endThumbCenter`, and `currentValues` parameters of paint override method for customizing range slider and range selector ticks. + +{% tabs %} +{% highlight Dart %} + +import 'dart:math' as math; + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class TicksShapePage extends StatefulWidget { + @override + _TicksShapePageState createState() => _TicksShapePageState(); +} + +class _TicksShapePageState extends State { + double _value = 5.0; + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SfSlider( + min: 0.0, + max: 10.0, + value: _value, + interval: 1, + showTicks: true, + minorTicksPerInterval: 3, + tickShape: _SfTickShape(), + minorTickShape: _SfMinorTickShape(), + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ); + } +} + +class _SfTickShape extends SfTickShape { + @override + void paint(PaintingContext context, Offset offset, Offset? thumbCenter, + Offset? startThumbCenter, Offset? endThumbCenter, + {required RenderBox parentBox, + required SfSliderThemeData themeData, + SfRangeValues? currentValues, + dynamic currentValue, + required Animation enableAnimation, + required TextDirection textDirection}) { + final Size tickSize = getPreferredSize(themeData); + final bool isTickRightOfThumb = offset.dx > thumbCenter!.dx; + final Color begin = isTickRightOfThumb + ? themeData.disabledInactiveTickColor + : themeData.disabledActiveTickColor; + final Color end = isTickRightOfThumb + ? themeData.inactiveTickColor + : themeData.activeTickColor; + final Paint paint = Paint() + ..isAntiAlias = true + ..strokeWidth = tickSize.width + ..color = ColorTween(begin: begin, end: end).evaluate(enableAnimation)!; + + context.canvas.drawLine( + Offset( + offset.dx, + offset.dy - + 2 - + math.max(themeData.activeTrackHeight, + themeData.inactiveTrackHeight)), + Offset( + offset.dx, + offset.dy - + 2 - + math.max(themeData.activeTrackHeight, + themeData.inactiveTrackHeight) - + tickSize.height), + paint); + } +} + +class _SfMinorTickShape extends SfTickShape { + @override + void paint(PaintingContext context, Offset offset, Offset? thumbCenter, + Offset? startThumbCenter, Offset? endThumbCenter, + {required RenderBox parentBox, + required SfSliderThemeData themeData, + SfRangeValues? currentValues, + dynamic currentValue, + required Animation enableAnimation, + required TextDirection textDirection}) { + final Size minorTickSize = getPreferredSize(themeData); + final bool isMinorTickRightOfThumb = offset.dx > thumbCenter!.dx; + + final Color begin = isMinorTickRightOfThumb + ? themeData.disabledInactiveMinorTickColor + : themeData.disabledActiveMinorTickColor; + final Color end = isMinorTickRightOfThumb + ? themeData.inactiveMinorTickColor + : themeData.activeMinorTickColor; + final Paint paint = Paint() + ..isAntiAlias = true + ..strokeWidth = minorTickSize.width + ..color = ColorTween(begin: begin, end: end).evaluate(enableAnimation)!; + + context.canvas.drawLine( + Offset( + offset.dx, + offset.dy - + 2 - + math.max(themeData.activeTrackHeight, + themeData.inactiveTrackHeight)), + Offset( + offset.dx, + offset.dy - + 2 - + math.max(themeData.activeTrackHeight, + themeData.inactiveTrackHeight) - + minorTickSize.height), + paint); + } +} + +{% endhighlight %} +{% endtabs %} + ![Ticks shape](images/shapes/ticks-shape.png) \ No newline at end of file diff --git a/Flutter/slider/thumb-and-overlay.md b/Flutter/slider/thumb-and-overlay.md index bb353196b..787c21618 100644 --- a/Flutter/slider/thumb-and-overlay.md +++ b/Flutter/slider/thumb-and-overlay.md @@ -1,670 +1,670 @@ ---- -layout: post -title: Thumb and Thumb Overlay in Flutter Slider | Syncfusion® -description: Learn about thumb and thumb overlay customization in Syncfusion® Flutter Slider (SfSlider), including size, color, appearance, and styling options. -platform: flutter -control: SfSlider -documentation: ug ---- - -# Thumb and Thumb Overlay in Flutter Slider (SfSlider) - -This section explains how to customize the thumb and thumb overlay in the slider. - -* Thumb - It is one of the elements of slider which can be used to drag and change the selected value of the slider. -* Thumb overlay - It is rendered around the thumb while interacting with it. - -N> You must import the `theme.dart` library from the [`Core`](https://pub.dev/packages/syncfusion_flutter_core) package to use [`SfSliderTheme`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderTheme-class.html) in all the examples shown below. - -## Thumb size - -You can change the size of the thumb in the slider using the [`thumbRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/thumbRadius.html) property. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class ThumbSizePage extends StatefulWidget { - @override - _ThumbSizePageState createState() => _ThumbSizePageState(); -} - -class _ThumbSizePageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - thumbRadius: 13, - ), - child: SfSlider( - min: 2.0, - max: 10.0, - interval: 1, - showTicks: true, - showLabels: true, - value: _value, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Thumb size support](images/thumb-and-overlay/slider-thumb-size.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalThumbSizePage extends StatefulWidget { - @override - _VerticalThumbSizePageState createState() => _VerticalThumbSizePageState(); -} - -class _VerticalThumbSizePageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - thumbRadius: 13, - ), - child: SfSlider.vertical( - min: 2.0, - max: 10.0, - interval: 1, - showTicks: true, - showLabels: true, - value: _value, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Thumb size support](images/thumb-and-overlay/vertical-slider-thumb-size.png) - -## Thumb color - -You can change the color of the thumb in the slider using the [`thumbColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/thumbColor.html) property. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class ThumbColorPage extends StatefulWidget { - @override - _ThumbColorPageState createState() => _ThumbColorPageState(); -} - -class _ThumbColorPageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - thumbColor: Colors.red, - ), - child: SfSlider( - min: 2.0, - max: 10.0, - interval: 1, - showTicks: true, - showLabels: true, - value: _value, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Thumb color support](images/thumb-and-overlay/slider-thumb-color.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalThumbColorPage extends StatefulWidget { - @override - _VerticalThumbColorPageState createState() => _VerticalThumbColorPageState(); -} - -class _VerticalThumbColorPageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - thumbColor: Colors.red, - ), - child: SfSlider.vertical( - min: 2.0, - max: 10.0, - interval: 1, - showTicks: true, - showLabels: true, - value: _value, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Thumb color support](images/thumb-and-overlay/vertical-slider-thumb-color.png) - -## Thumb stroke width and stroke color - -You can change the thumb stroke width using the [`thumbStrokeWidth`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/thumbStrokeWidth.html) property and thumb stroke color using the [`thumbStrokeColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/thumbStrokeColor.html) property. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class ThumbStrokePage extends StatefulWidget { - @override - _ThumbStrokePageState createState() => _ThumbStrokePageState(); -} - -class _ThumbStrokePageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - thumbStrokeWidth: 3, - thumbStrokeColor: Colors.red - ), - child: SfSlider( - min: 2.0, - max: 10.0, - interval: 1, - showTicks: true, - showLabels: true, - value: _value, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Thumb stroke color support](images/thumb-and-overlay/slider-thumb-stroke-color.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalThumbStrokePage extends StatefulWidget { - @override - _VerticalThumbStrokePageState createState() => _VerticalThumbStrokePageState(); -} - -class _VerticalThumbStrokePageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - thumbStrokeWidth: 3, - thumbStrokeColor: Colors.red - ), - child: SfSlider.vertical( - min: 2.0, - max: 10.0, - interval: 1, - showTicks: true, - showLabels: true, - value: _value, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Thumb stroke color support](images/thumb-and-overlay/vertical-slider-thumb-stroke-color.png) - - -## Thumb icon - -You can show the custom widgets like icon or text inside the thumb using the [`thumbIcon`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/thumbIcon.html) property. The `thumbIcon` widget is rendered inside the thumb. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class ThumbIconPage extends StatefulWidget { - @override - _ThumbIconPageState createState() => _ThumbIconPageState(); -} - -class _ThumbIconPageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: SfSliderTheme( - data: SfSliderThemeData( - thumbColor: Colors.white, - thumbRadius: 15, - thumbStrokeWidth: 2, - thumbStrokeColor: Colors.blue - ), - child: Center( - child: SfSlider( - min: 2.0, - max: 10.0, - interval: 1, - thumbIcon: const Icon( - Icons.arrow_forward_ios, - color: Colors.blue, - size: 20.0), - showLabels: true, - value: _value, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Thumb icon support](images/thumb-and-overlay/slider-thumb-icon.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalThumbIconPage extends StatefulWidget { - @override - _VerticalThumbIconPageState createState() => _VerticalThumbIconPageState(); -} - -class _VerticalThumbIconPageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: SfSliderTheme( - data: SfSliderThemeData( - thumbColor: Colors.white, - thumbRadius: 15, - thumbStrokeWidth: 2, - thumbStrokeColor: Colors.blue - ), - child: Center( - child: SfSlider.vertical( - min: 2.0, - max: 10.0, - interval: 1, - thumbIcon: const Icon( - Icons.keyboard_arrow_up_outlined, - color: Colors.blue, - size: 20.0), - showLabels: true, - value: _value, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Thumb icon support](images/thumb-and-overlay/vertical-slider-thumb-icon.png) - - -## Thumb overlay size - -You can change the size of the thumb overlay in the slider using the [`overlayRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/overlayRadius.html) property. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class OverlaySizePage extends StatefulWidget { - @override - _OverlaySizePageState createState() => _OverlaySizePageState(); -} - -class _OverlaySizePageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - overlayRadius: 30, - ), - child: SfSlider( - min: 2.0, - max: 10.0, - interval: 1, - showTicks: true, - showLabels: true, - value: _value, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Thumb overlay size support](images/thumb-and-overlay/slider-overlay-size.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalOverlaySizePage extends StatefulWidget { - @override - _VerticalOverlaySizePageState createState() => _VerticalOverlaySizePageState(); -} - -class _VerticalOverlaySizePageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - overlayRadius: 30, - ), - child: SfSlider.vertical( - min: 2.0, - max: 10.0, - interval: 1, - showTicks: true, - showLabels: true, - value: _value, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Thumb overlay size support](images/thumb-and-overlay/vertical-slider-overlay-size.png) - - -## Thumb overlay color - -You can change the color of the thumb overlay in the slider using the [`overlayColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/overlayColor.html) property. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class OverlayColorPage extends StatefulWidget { - @override - _OverlayColorPageState createState() => _OverlayColorPageState(); -} - -class _OverlayColorPageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - overlayColor: Colors.red[50], - ), - child: SfSlider( - min: 2.0, - max: 10.0, - interval: 1, - showTicks: true, - showLabels: true, - value: _value, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Thumb overlay color support](images/thumb-and-overlay/slider-overlay-color.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalOverlayColorPage extends StatefulWidget { - @override - _VerticalOverlayColorPageState createState() => _VerticalOverlayColorPageState(); -} - -class _VerticalOverlayColorPageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - overlayColor: Colors.red[50], - ), - child: SfSlider.vertical( - min: 2.0, - max: 10.0, - interval: 1, - showTicks: true, - showLabels: true, - value: _value, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Thumb overlay size support](images/thumb-and-overlay/vertical-slider-overlay-color.png) +--- +layout: post +title: Thumb and Thumb Overlay in Flutter Slider | Syncfusion® +description: Learn about thumb and thumb overlay customization in Syncfusion® Flutter Slider (SfSlider), including size, color, appearance, and styling options. +platform: flutter +control: SfSlider +documentation: ug +--- + +# Thumb and Thumb Overlay in Flutter Slider (SfSlider) + +This section explains how to customize the thumb and thumb overlay in the Flutter Slider. + +* Thumb - It is one of the elements which can be used to drag and change the selected value of the Flutter Slider. +* Thumb overlay - It is rendered around the thumb while interacting with it. + +N> You must import the `theme.dart` library from the [`Core`](https://pub.dev/packages/syncfusion_flutter_core) package to use [`SfSliderTheme`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderTheme-class.html) in all the examples shown below. + +## Thumb size + +You can change the size of the thumb in the slider using the [`thumbRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/thumbRadius.html) property. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class ThumbSizePage extends StatefulWidget { + @override + _ThumbSizePageState createState() => _ThumbSizePageState(); +} + +class _ThumbSizePageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + thumbRadius: 13, + ), + child: SfSlider( + min: 2.0, + max: 10.0, + interval: 1, + showTicks: true, + showLabels: true, + value: _value, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Thumb size support](images/thumb-and-overlay/slider-thumb-size.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalThumbSizePage extends StatefulWidget { + @override + _VerticalThumbSizePageState createState() => _VerticalThumbSizePageState(); +} + +class _VerticalThumbSizePageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + thumbRadius: 13, + ), + child: SfSlider.vertical( + min: 2.0, + max: 10.0, + interval: 1, + showTicks: true, + showLabels: true, + value: _value, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Thumb size support](images/thumb-and-overlay/vertical-slider-thumb-size.png) + +## Thumb color + +You can change the color of the thumb in the Flutter Slider using the [`thumbColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/thumbColor.html) property. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class ThumbColorPage extends StatefulWidget { + @override + _ThumbColorPageState createState() => _ThumbColorPageState(); +} + +class _ThumbColorPageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + thumbColor: Colors.red, + ), + child: SfSlider( + min: 2.0, + max: 10.0, + interval: 1, + showTicks: true, + showLabels: true, + value: _value, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Thumb color support](images/thumb-and-overlay/slider-thumb-color.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalThumbColorPage extends StatefulWidget { + @override + _VerticalThumbColorPageState createState() => _VerticalThumbColorPageState(); +} + +class _VerticalThumbColorPageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + thumbColor: Colors.red, + ), + child: SfSlider.vertical( + min: 2.0, + max: 10.0, + interval: 1, + showTicks: true, + showLabels: true, + value: _value, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Thumb color support](images/thumb-and-overlay/vertical-slider-thumb-color.png) + +## Thumb stroke width and stroke color + +You can change the thumb stroke width using the [`thumbStrokeWidth`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/thumbStrokeWidth.html) property and thumb stroke color using the [`thumbStrokeColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/thumbStrokeColor.html) property. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class ThumbStrokePage extends StatefulWidget { + @override + _ThumbStrokePageState createState() => _ThumbStrokePageState(); +} + +class _ThumbStrokePageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + thumbStrokeWidth: 3, + thumbStrokeColor: Colors.red + ), + child: SfSlider( + min: 2.0, + max: 10.0, + interval: 1, + showTicks: true, + showLabels: true, + value: _value, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Thumb stroke color support](images/thumb-and-overlay/slider-thumb-stroke-color.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalThumbStrokePage extends StatefulWidget { + @override + _VerticalThumbStrokePageState createState() => _VerticalThumbStrokePageState(); +} + +class _VerticalThumbStrokePageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + thumbStrokeWidth: 3, + thumbStrokeColor: Colors.red + ), + child: SfSlider.vertical( + min: 2.0, + max: 10.0, + interval: 1, + showTicks: true, + showLabels: true, + value: _value, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Thumb stroke color support](images/thumb-and-overlay/vertical-slider-thumb-stroke-color.png) + + +## Thumb icon + +You can show the custom widgets like icon or text inside the thumb using the [`thumbIcon`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/thumbIcon.html) property. The `thumbIcon` widget is rendered inside the thumb. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class ThumbIconPage extends StatefulWidget { + @override + _ThumbIconPageState createState() => _ThumbIconPageState(); +} + +class _ThumbIconPageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: SfSliderTheme( + data: SfSliderThemeData( + thumbColor: Colors.white, + thumbRadius: 15, + thumbStrokeWidth: 2, + thumbStrokeColor: Colors.blue + ), + child: Center( + child: SfSlider( + min: 2.0, + max: 10.0, + interval: 1, + thumbIcon: const Icon( + Icons.arrow_forward_ios, + color: Colors.blue, + size: 20.0), + showLabels: true, + value: _value, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Thumb icon support](images/thumb-and-overlay/slider-thumb-icon.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalThumbIconPage extends StatefulWidget { + @override + _VerticalThumbIconPageState createState() => _VerticalThumbIconPageState(); +} + +class _VerticalThumbIconPageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: SfSliderTheme( + data: SfSliderThemeData( + thumbColor: Colors.white, + thumbRadius: 15, + thumbStrokeWidth: 2, + thumbStrokeColor: Colors.blue + ), + child: Center( + child: SfSlider.vertical( + min: 2.0, + max: 10.0, + interval: 1, + thumbIcon: const Icon( + Icons.keyboard_arrow_up_outlined, + color: Colors.blue, + size: 20.0), + showLabels: true, + value: _value, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Thumb icon support](images/thumb-and-overlay/vertical-slider-thumb-icon.png) + + +## Thumb overlay size + +You can change the size of the thumb overlay in the Flutter Slider using the [`overlayRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/overlayRadius.html) property. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class OverlaySizePage extends StatefulWidget { + @override + _OverlaySizePageState createState() => _OverlaySizePageState(); +} + +class _OverlaySizePageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + overlayRadius: 30, + ), + child: SfSlider( + min: 2.0, + max: 10.0, + interval: 1, + showTicks: true, + showLabels: true, + value: _value, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Thumb overlay size support](images/thumb-and-overlay/slider-overlay-size.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalOverlaySizePage extends StatefulWidget { + @override + _VerticalOverlaySizePageState createState() => _VerticalOverlaySizePageState(); +} + +class _VerticalOverlaySizePageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + overlayRadius: 30, + ), + child: SfSlider.vertical( + min: 2.0, + max: 10.0, + interval: 1, + showTicks: true, + showLabels: true, + value: _value, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Thumb overlay size support](images/thumb-and-overlay/vertical-slider-overlay-size.png) + + +## Thumb overlay color + +You can change the color of the thumb overlay in the Flutter Slider using the [`overlayColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/overlayColor.html) property. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class OverlayColorPage extends StatefulWidget { + @override + _OverlayColorPageState createState() => _OverlayColorPageState(); +} + +class _OverlayColorPageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + overlayColor: Colors.red[50], + ), + child: SfSlider( + min: 2.0, + max: 10.0, + interval: 1, + showTicks: true, + showLabels: true, + value: _value, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Thumb overlay color support](images/thumb-and-overlay/slider-overlay-color.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalOverlayColorPage extends StatefulWidget { + @override + _VerticalOverlayColorPageState createState() => _VerticalOverlayColorPageState(); +} + +class _VerticalOverlayColorPageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + overlayColor: Colors.red[50], + ), + child: SfSlider.vertical( + min: 2.0, + max: 10.0, + interval: 1, + showTicks: true, + showLabels: true, + value: _value, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Thumb overlay size support](images/thumb-and-overlay/vertical-slider-overlay-color.png) diff --git a/Flutter/slider/ticks.md b/Flutter/slider/ticks.md index 4a1aa617d..6a3335869 100644 --- a/Flutter/slider/ticks.md +++ b/Flutter/slider/ticks.md @@ -1,654 +1,654 @@ ---- -layout: post -title: Ticks in Flutter Slider | Syncfusion® -description: Learn about tick support in Syncfusion® Flutter Slider (SfSlider), including major ticks, minor ticks, intervals, and customization options. -platform: flutter -control: SfSlider -documentation: ug ---- - -# Ticks in Flutter Slider (SfSlider) - -This section explains how to add major and minor ticks in the slider. - -N> You must import the `theme.dart` library from the [`Core`](https://pub.dev/packages/syncfusion_flutter_core) package to use [`SfSliderTheme`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderTheme-class.html) for customizing tick colors, sizes, and offsets shown in the examples below. - -## Show major ticks - -You can enable the major ticks on the track. It is a shape which is used to represent the points at each major interval on the track. The default value of [`showTicks`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/showTicks.html) property is `false`. - -For example, if [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html) is 0.0 and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) is 10.0 and [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/interval.html) is 2.0, the slider will render the major ticks at 0.0, 2.0, 4.0 and so on. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class MajorTicksPage extends StatefulWidget { - @override - _MajorTicksPageState createState() => _MajorTicksPageState(); -} - -class _MajorTicksPageState extends State { - double _value = 4.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider( - min: 0.0, - max: 10.0, - interval: 2, - showTicks: true, - showLabels: true, - value: _value, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Slider tick support](images/tick/major-tick.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalMajorTicksPage extends StatefulWidget { - @override - _VerticalMajorTicksPageState createState() => _VerticalMajorTicksPageState(); -} - -class _VerticalMajorTicksPageState extends State { - double _value = 4.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider.vertical( - min: 0.0, - max: 10.0, - interval: 2, - showTicks: true, - showLabels: true, - value: _value, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Slider tick support](images/tick/vertical-major-tick.png) - -N> Refer the [`tickShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/tickShape.html) and [`SfSliderThemeData`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData-class.html) for customizing the major tick's visual appearance. - -## Show minor ticks - -It is used to represent the number of smaller ticks between two major ticks. For example, if [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html) is 0.0 and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) is 10.0 and [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/interval.html) is 2.0, the slider will render the major ticks at 0.0, 2.0, 4.0 and so on. If [`minorTicksPerInterval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/minorTicksPerInterval.html) is 1, then smaller ticks will be rendered on 1.0 and 3.0 and so on. - -I> The default value of [`minorTicksPerInterval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/minorTicksPerInterval.html) property is null and it must be greater than 0. When null, no minor ticks are rendered. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class MinorTicksPage extends StatefulWidget { - @override - _MinorTicksPageState createState() => _MinorTicksPageState(); -} - -class _MinorTicksPageState extends State { - double _value = 4.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider( - min: 0.0, - max: 10.0, - interval: 2, - showTicks: true, - minorTicksPerInterval: 1, - showLabels: true, - value: _value, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Slider minor tick support](images/tick/minor-tick.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalMinorTicksPage extends StatefulWidget { - @override - _VerticalMinorTicksPageState createState() => _VerticalMinorTicksPageState(); -} - -class _VerticalMinorTicksPageState extends State { - double _value = 4.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider.vertical( - min: 0.0, - max: 10.0, - interval: 2, - showTicks: true, - minorTicksPerInterval: 1, - showLabels: true, - value: _value, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Slider minor tick support](images/tick/vertical-minor-tick.png) - -N> -* Refer the [`showTicks`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/showTicks.html) to know about the rendering major ticks at given interval. -* Refer the [`minorTickShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/minorTickShape.html) and [`SfSliderThemeData`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData-class.html) for customizing the minor tick's visual appearance. - -## Major ticks color - -You can change the active and inactive major ticks color of the slider using the [`activeTickColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeTickColor.html) and [`inactiveTickColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveTickColor.html) properties respectively. - -The active side of the slider is between the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html) and the thumb. - -The inactive side of the slider is between the thumb and the [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) value. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class MajorTicksColorPage extends StatefulWidget { - @override - _MajorTicksColorPageState createState() => _MajorTicksColorPageState(); -} - -class _MajorTicksColorPageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - activeTickColor: Colors.red, - inactiveTickColor: Colors.red[100], - ), - child: SfSlider( - min: 2.0, - max: 10.0, - value: _value, - interval: 1, - showTicks: true, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Major ticks color](images/tick/slider-major-ticks.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalMajorTicksColorPage extends StatefulWidget { - @override - _VerticalMajorTicksColorPageState createState() => _VerticalMajorTicksColorPageState(); -} - -class _VerticalMajorTicksColorPageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - activeTickColor: Colors.red, - inactiveTickColor: Colors.red[100], - ), - child: SfSlider.vertical( - min: 2.0, - max: 10.0, - value: _value, - interval: 1, - showTicks: true, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Major ticks color](images/tick/vertical-slider-major-ticks.png) - -## Minor ticks color - -You can change the active and inactive minor ticks color of the slider using the [`activeMinorTickColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeMinorTickColor.html) and [`inactiveMinorTickColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveMinorTickColor.html) properties respectively. - -The active side of the slider is between the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html) and the thumb. - -The inactive side of the slider is between the thumb and the [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) value. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class MinorTicksColorPage extends StatefulWidget { - @override - _MinorTicksColorPageState createState() => _MinorTicksColorPageState(); -} - -class _MinorTicksColorPageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - activeMinorTickColor: Colors.red, - inactiveMinorTickColor: Colors.red[200], - ), - child: SfSlider( - min: 2.0, - max: 10.0, - value: _value, - interval: 2, - minorTicksPerInterval: 1, - showTicks: true, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Minor ticks color](images/tick/slider-minor-ticks.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalMinorTicksColorPage extends StatefulWidget { - @override - _VerticalMinorTicksColorPageState createState() => _VerticalMinorTicksColorPageState(); -} - -class _VerticalMinorTicksColorPageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - activeMinorTickColor: Colors.red, - inactiveMinorTickColor: Colors.red[200], - ), - child: SfSlider.vertical( - min: 2.0, - max: 10.0, - value: _value, - interval: 2, - minorTicksPerInterval: 1, - showTicks: true, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Minor ticks color](images/tick/vertical-slider-minor-ticks.png) - -## Tick size - -You can change the major and minor ticks size of the slider using the [`tickSize`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/tickSize.html) and [`minorTickSize`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/minorTickSize.html) properties respectively. - -### Horizontal - -The default value of the [`tickSize`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/tickSize.html) property is `Size(1.0, 8.0)` and [`minorTickSize`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/minorTickSize.html) property is `Size(1.0, 5.0)`. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class TickSizePage extends StatefulWidget { - @override - _TickSizePageState createState() => _TickSizePageState(); -} - -class _TickSizePageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - tickSize: Size(3.0, 12.0), - minorTickSize: Size(3.0, 8.0), - ), - child: SfSlider( - min: 2.0, - max: 10.0, - interval: 2, - minorTicksPerInterval: 1, - showTicks: true, - value: _value, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Ticks size support](images/tick/slider-ticks-size.png) - -### Vertical - -The default value of the [`tickSize`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/tickSize.html) property is `Size(8.0, 1.0)` and [`minorTickSize`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/minorTickSize.html) property is `Size(5.0, 1.0)`. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalTickSizePage extends StatefulWidget { - @override - _VerticalTickSizePageState createState() => _VerticalTickSizePageState(); -} - -class _VerticalTickSizePageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - tickSize: Size(12.0, 3.0), - minorTickSize: Size(8.0, 3.0), - ), - child: SfSlider.vertical( - min: 2.0, - max: 10.0, - interval: 2, - minorTicksPerInterval: 1, - showTicks: true, - value: _value, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Ticks size support](images/tick/vertical-slider-ticks-size.png) - -## Ticks offset - -You can adjust the space between track and ticks of the slider using the [`tickOffset`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/tickOffset.html) property in the [`SfSliderThemeData`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData-class.html). The default value of the [`tickOffset`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/tickOffset.html) property is `null`. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class TicksOffsetPage extends StatefulWidget { - @override - _TicksOffsetPageState createState() => _TicksOffsetPageState(); -} - -class _TicksOffsetPageState extends State { - double _value = 4.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - tickOffset: Offset(0.0, 10.0), - ), - child: SfSlider( - min: 2.0, - max: 10.0, - interval: 2, - minorTicksPerInterval: 1, - showTicks: true, - value: _value, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Ticks offset support](images/tick/slider-ticks-offset.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalTicksOffsetPage extends StatefulWidget { - @override - _VerticalTicksOffsetPageState createState() => _VerticalTicksOffsetPageState(); -} - -class _VerticalTicksOffsetPageState extends State { - double _value = 4.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - tickOffset: Offset(0.0, 10.0), - ), - child: SfSlider.vertical( - min: 2.0, - max: 10.0, - interval: 2, - minorTicksPerInterval: 1, - showTicks: true, - value: _value, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - +--- +layout: post +title: Ticks in Flutter Slider | Syncfusion® +description: Learn about tick support in Syncfusion® Flutter Slider (SfSlider), including major ticks, minor ticks, intervals, and customization options. +platform: flutter +control: SfSlider +documentation: ug +--- + +# Ticks in Flutter Slider (SfSlider) + +This section explains how to add major and minor ticks in the Flutter Slider. + +N> You must import the `theme.dart` library from the [`Core`](https://pub.dev/packages/syncfusion_flutter_core) package to use [`SfSliderTheme`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderTheme-class.html) for customizing tick colors, sizes, and offsets shown in the examples below. + +## Show major ticks + +You can enable the major ticks on the track. It is a shape which is used to represent the points at each major interval on the track. The default value of [`showTicks`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/showTicks.html) property is `false`. + +For example, if [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html) is 0.0 and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) is 10.0 and [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/interval.html) is 2.0, the Flutter Slider will render the major ticks at 0.0, 2.0, 4.0 and so on. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class MajorTicksPage extends StatefulWidget { + @override + _MajorTicksPageState createState() => _MajorTicksPageState(); +} + +class _MajorTicksPageState extends State { + double _value = 4.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider( + min: 0.0, + max: 10.0, + interval: 2, + showTicks: true, + showLabels: true, + value: _value, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Slider tick support](images/tick/major-tick.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalMajorTicksPage extends StatefulWidget { + @override + _VerticalMajorTicksPageState createState() => _VerticalMajorTicksPageState(); +} + +class _VerticalMajorTicksPageState extends State { + double _value = 4.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider.vertical( + min: 0.0, + max: 10.0, + interval: 2, + showTicks: true, + showLabels: true, + value: _value, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Slider tick support](images/tick/vertical-major-tick.png) + +N> Refer the [`tickShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/tickShape.html) and [`SfSliderThemeData`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData-class.html) for customizing the major tick's visual appearance. + +## Show minor ticks + +It is used to represent the number of smaller ticks between two major ticks. For example, if [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html) is 0.0 and [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) is 10.0 and [`interval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/interval.html) is 2.0, the Flutter Slider will render the major ticks at 0.0, 2.0, 4.0 and so on. If [`minorTicksPerInterval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/minorTicksPerInterval.html) is 1, then smaller ticks will be rendered on 1.0 and 3.0 and so on. + +I> The default value of [`minorTicksPerInterval`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/minorTicksPerInterval.html) property is null and it must be greater than 0. When null, no minor ticks are rendered. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class MinorTicksPage extends StatefulWidget { + @override + _MinorTicksPageState createState() => _MinorTicksPageState(); +} + +class _MinorTicksPageState extends State { + double _value = 4.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider( + min: 0.0, + max: 10.0, + interval: 2, + showTicks: true, + minorTicksPerInterval: 1, + showLabels: true, + value: _value, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Slider minor tick support](images/tick/minor-tick.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalMinorTicksPage extends StatefulWidget { + @override + _VerticalMinorTicksPageState createState() => _VerticalMinorTicksPageState(); +} + +class _VerticalMinorTicksPageState extends State { + double _value = 4.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider.vertical( + min: 0.0, + max: 10.0, + interval: 2, + showTicks: true, + minorTicksPerInterval: 1, + showLabels: true, + value: _value, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Slider minor tick support](images/tick/vertical-minor-tick.png) + +N> +* Refer the [`showTicks`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/showTicks.html) to know about the rendering major ticks at given interval. +* Refer the [`minorTickShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/minorTickShape.html) and [`SfSliderThemeData`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData-class.html) for customizing the minor tick's visual appearance. + +## Major ticks color + +You can change the active and inactive major ticks color of the Flutter Slider using the [`activeTickColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeTickColor.html) and [`inactiveTickColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveTickColor.html) properties respectively. + +The active side of the Flutter Slider is between the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html) and the thumb. + +The inactive side of the Flutter Slider is between the thumb and the [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) value. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class MajorTicksColorPage extends StatefulWidget { + @override + _MajorTicksColorPageState createState() => _MajorTicksColorPageState(); +} + +class _MajorTicksColorPageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + activeTickColor: Colors.red, + inactiveTickColor: Colors.red[100], + ), + child: SfSlider( + min: 2.0, + max: 10.0, + value: _value, + interval: 1, + showTicks: true, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Major ticks color](images/tick/slider-major-ticks.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalMajorTicksColorPage extends StatefulWidget { + @override + _VerticalMajorTicksColorPageState createState() => _VerticalMajorTicksColorPageState(); +} + +class _VerticalMajorTicksColorPageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + activeTickColor: Colors.red, + inactiveTickColor: Colors.red[100], + ), + child: SfSlider.vertical( + min: 2.0, + max: 10.0, + value: _value, + interval: 1, + showTicks: true, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Major ticks color](images/tick/vertical-slider-major-ticks.png) + +## Minor ticks color + +You can change the active and inactive minor ticks color of the Flutter Slider using the [`activeMinorTickColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeMinorTickColor.html) and [`inactiveMinorTickColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveMinorTickColor.html) properties respectively. + +The active side of the Flutter Slider is between the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html) and the thumb. + +The inactive side of the Flutter Slider is between the thumb and the [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) value. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class MinorTicksColorPage extends StatefulWidget { + @override + _MinorTicksColorPageState createState() => _MinorTicksColorPageState(); +} + +class _MinorTicksColorPageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + activeMinorTickColor: Colors.red, + inactiveMinorTickColor: Colors.red[200], + ), + child: SfSlider( + min: 2.0, + max: 10.0, + value: _value, + interval: 2, + minorTicksPerInterval: 1, + showTicks: true, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Minor ticks color](images/tick/slider-minor-ticks.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalMinorTicksColorPage extends StatefulWidget { + @override + _VerticalMinorTicksColorPageState createState() => _VerticalMinorTicksColorPageState(); +} + +class _VerticalMinorTicksColorPageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + activeMinorTickColor: Colors.red, + inactiveMinorTickColor: Colors.red[200], + ), + child: SfSlider.vertical( + min: 2.0, + max: 10.0, + value: _value, + interval: 2, + minorTicksPerInterval: 1, + showTicks: true, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Minor ticks color](images/tick/vertical-slider-minor-ticks.png) + +## Tick size + +You can change the major and minor ticks size of the Flutter Slider using the [`tickSize`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/tickSize.html) and [`minorTickSize`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/minorTickSize.html) properties respectively. + +### Horizontal + +The default value of the [`tickSize`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/tickSize.html) property is `Size(1.0, 8.0)` and [`minorTickSize`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/minorTickSize.html) property is `Size(1.0, 5.0)`. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class TickSizePage extends StatefulWidget { + @override + _TickSizePageState createState() => _TickSizePageState(); +} + +class _TickSizePageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + tickSize: Size(3.0, 12.0), + minorTickSize: Size(3.0, 8.0), + ), + child: SfSlider( + min: 2.0, + max: 10.0, + interval: 2, + minorTicksPerInterval: 1, + showTicks: true, + value: _value, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Ticks size support](images/tick/slider-ticks-size.png) + +### Vertical + +The default value of the [`tickSize`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/tickSize.html) property is `Size(8.0, 1.0)` and [`minorTickSize`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/minorTickSize.html) property is `Size(5.0, 1.0)`. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalTickSizePage extends StatefulWidget { + @override + _VerticalTickSizePageState createState() => _VerticalTickSizePageState(); +} + +class _VerticalTickSizePageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + tickSize: Size(12.0, 3.0), + minorTickSize: Size(8.0, 3.0), + ), + child: SfSlider.vertical( + min: 2.0, + max: 10.0, + interval: 2, + minorTicksPerInterval: 1, + showTicks: true, + value: _value, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Ticks size support](images/tick/vertical-slider-ticks-size.png) + +## Ticks offset + +You can adjust the space between track and ticks of the Flutter Slider using the [`tickOffset`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/tickOffset.html) property in the [`SfSliderThemeData`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData-class.html). The default value of the [`tickOffset`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/tickOffset.html) property is `null`. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class TicksOffsetPage extends StatefulWidget { + @override + _TicksOffsetPageState createState() => _TicksOffsetPageState(); +} + +class _TicksOffsetPageState extends State { + double _value = 4.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + tickOffset: Offset(0.0, 10.0), + ), + child: SfSlider( + min: 2.0, + max: 10.0, + interval: 2, + minorTicksPerInterval: 1, + showTicks: true, + value: _value, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Ticks offset support](images/tick/slider-ticks-offset.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalTicksOffsetPage extends StatefulWidget { + @override + _VerticalTicksOffsetPageState createState() => _VerticalTicksOffsetPageState(); +} + +class _VerticalTicksOffsetPageState extends State { + double _value = 4.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + tickOffset: Offset(0.0, 10.0), + ), + child: SfSlider.vertical( + min: 2.0, + max: 10.0, + interval: 2, + minorTicksPerInterval: 1, + showTicks: true, + value: _value, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + ![Ticks offset support](images/tick/vertical-slider-ticks-offset.png) \ No newline at end of file diff --git a/Flutter/slider/tooltip.md b/Flutter/slider/tooltip.md index d8f2a825f..6ada55459 100644 --- a/Flutter/slider/tooltip.md +++ b/Flutter/slider/tooltip.md @@ -1,547 +1,547 @@ ---- -layout: post -title: Tooltip in Flutter Slider | Syncfusion -description: Step-by-step guide to configure tooltips in Syncfusion Flutter Slider—enable tooltips, format text, customize appearance, and control behavior. -platform: flutter -control: SfSlider -documentation: ug ---- - -# Flutter Slider Tooltip (SfSlider) - -This section explains how to add a tooltip in the slider. - -## Enable tooltip - -You can enable a tooltip for the thumb using the [`enableTooltip`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/enableTooltip.html) property. It is used to clearly indicate the current selection of the value during interaction. By default, tooltip text is formatted with either [`numberFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/numberFormat.html) or [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/dateFormat.html). - -I> By setting the value of [`shouldAlwaysShowTooltip`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/shouldAlwaysShowTooltip.html) to true, you can always show a tooltip without having to interact with the slider thumb. The default value is `false` and it works independent of the [`enableTooltip`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/enableTooltip.html) behavior. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class EnableTooltipPage extends StatefulWidget { - @override - _EnableTooltipPageState createState() => _EnableTooltipPageState(); -} - -class _EnableTooltipPageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider( - min: 0.0, - max: 10.0, - interval: 2, - showTicks: true, - showLabels: true, - enableTooltip: true, - value: _value, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Slider tooltip support](images/tooltip/show-tooltip.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalEnableTooltipPage extends StatefulWidget { - @override - _VerticalEnableTooltipPageState createState() => _VerticalEnableTooltipPageState(); -} - -class _VerticalEnableTooltipPageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider.vertical( - min: 0.0, - max: 10.0, - interval: 2, - showTicks: true, - showLabels: true, - enableTooltip: true, - value: _value, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Slider tooltip support](images/tooltip/vertical-show-tooltip.png) - - -N> -* Refer the [`tooltipTextFormatterCallback`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/tooltipTextFormatterCallback.html) for changing the default tooltip text. -* Refer the [`SfSliderThemeData`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData-class.html) for customizing the appearance of the tooltip text. - -## Tooltip shape - -You can show tooltip in rectangular or paddle shape using the [`tooltipShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/tooltipShape.html) property. The default value of the [`tooltipShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/tooltipShape.html) property is [`SfRectangularTooltipShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRectangularTooltipShape-class.html). - -N> The paddle tooltip shape is not applicable for vertical orientation of the sliders. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class TooltipShapePage extends StatefulWidget { - @override - _TooltipShapePageState createState() => _TooltipShapePageState(); -} - -class _TooltipShapePageState extends State { - double _value = 40.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider( - min: 0.0, - max: 100.0, - interval: 20, - showTicks: true, - showLabels: true, - enableTooltip: true, - tooltipShape: SfPaddleTooltipShape(), - value: _value, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Slider tooltip shape](images/tooltip/tooltip-shape.png) - -## Tooltip position - -N> This is only applicable for vertical orientation of the sliders. - -You can show tooltip in left or right positions using the [`tooltipPosition`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SliderTooltipPosition.html) property. The default value of the [`tooltipPosition`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SliderTooltipPosition.html) property is `SliderTooltipPosition.left`. - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class TooltipPositionPage extends StatefulWidget { - @override - _TooltipPositionPageState createState() => _TooltipPositionPageState(); -} - -class _TooltipPositionPageState extends State { - double _value = 40.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider.vertical( - min: 0.0, - max: 100.0, - interval: 20, - showTicks: true, - showLabels: true, - tooltipPosition: SliderTooltipPosition.right, - enableTooltip: true, - value: _value, - onChanged: (double newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Slider tooltip shape](images/tooltip/right_tooltip.png) - -## Tooltip text format - -By default it is formatted based on [`numberFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/numberFormat.html) property and [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/dateFormat.html) property based on whether it is date type [`SfSlider`](https://help.syncfusion.com/flutter/slider/getting-started#set-date-value) or numeric [`SfSlider`](https://help.syncfusion.com/flutter/slider/getting-started#set-numeric-value). - -You can format or change the whole tooltip label text using the [`tooltipTextFormatterCallback`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/tooltipTextFormatterCallback.html). Its arguments are, - -* actualValue – either `DateTime` or `double` based on given [`value`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/value.html). -* formattedText – If the actual value is `double`, it is formatted by [`numberFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/numberFormat.html) and if the actual value is `DateTime`, it is formatted by [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/dateFormat.html). - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class TooltipTextFormatPage extends StatefulWidget { - @override - _TooltipTextFormatPageState createState() => _TooltipTextFormatPageState(); -} - -class _TooltipTextFormatPageState extends State { - DateTime _value = DateTime(2010, 01, 01, 15, 00, 00); - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider( - min: DateTime(2010, 01, 01, 9, 00, 00), - max: DateTime(2010, 01, 01, 21, 05, 00), - value: _value, - interval: 3, - showTicks: true, - showLabels: true, - enableTooltip: true, - dateFormat: DateFormat('h:mm'), - dateIntervalType: DateIntervalType.hours, - tooltipTextFormatterCallback: (dynamic actualValue, String formattedText) { - return DateFormat('h:mm a').format(actualValue); - }, - onChanged: (DateTime newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Tooltip formatter support](images/tooltip/tooltip-formatter.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalTooltipTextFormatPage extends StatefulWidget { - @override - _VerticalTooltipTextFormatPageState createState() => _VerticalTooltipTextFormatPageState(); -} - -class _VerticalTooltipTextFormatPageState extends State { - DateTime _value = DateTime(2010, 01, 01, 15, 00, 00); - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSlider.vertical( - min: DateTime(2010, 01, 01, 9, 00, 00), - max: DateTime(2010, 01, 01, 21, 05, 00), - value: _value, - interval: 3, - showTicks: true, - showLabels: true, - enableTooltip: true, - dateFormat: DateFormat('h:mm'), - dateIntervalType: DateIntervalType.hours, - tooltipTextFormatterCallback: (dynamic actualValue, String formattedText) { - return DateFormat('h:mm a').format(actualValue); - }, - onChanged: (DateTime newValue) { - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Tooltip formatter support](images/tooltip/vertical-tooltip-formatter.png) - - -## Tooltip color - -You can change the background color of the tooltip in the slider using the [`tooltipBackgroundColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/tooltipBackgroundColor.html) property. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class TooltipColorPage extends StatefulWidget { - @override - _TooltipColorPageState createState() => _TooltipColorPageState(); -} - -class _TooltipColorPageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - tooltipBackgroundColor: Colors.red[300], - ), - child: SfSlider( - min: 2.0, - max: 10.0, - interval: 1, - showTicks: true, - showLabels: true, - enableTooltip: true, - value: _value, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Tooltip color support](images/tooltip/slider-tooltip-color.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalTooltipColorPage extends StatefulWidget { - @override - _VerticalTooltipColorPageState createState() => _VerticalTooltipColorPageState(); -} - -class _VerticalTooltipColorPageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - tooltipBackgroundColor: Colors.red[300], - ), - child: SfSlider.vertical( - min: 2.0, - max: 10.0, - interval: 1, - showTicks: true, - showLabels: true, - enableTooltip: true, - value: _value, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Tooltip color support](images/tooltip/vertical-slider-tooltip-color.png) - -## Tooltip label style - -You can change the appearance of the tooltip text in the slider using the [`tooltipTextStyle`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/tooltipTextStyle.html) property. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class TooltipLabelStylePage extends StatefulWidget { - @override - _TooltipLabelStylePageState createState() => _TooltipLabelStylePageState(); -} - -class _TooltipLabelStylePageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - tooltipTextStyle: TextStyle(color: Colors.red, fontSize: 16, fontStyle: FontStyle.italic), - ), - child: SfSlider( - min: 2.0, - max: 10.0, - interval: 1, - showTicks: true, - showLabels: true, - enableTooltip: true, - value: _value, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Tooltip style support](images/tooltip/slider-tooltip-style.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalTooltipLabelStylePage extends StatefulWidget { - @override - _VerticalTooltipLabelStylePageState createState() => _VerticalTooltipLabelStylePageState(); -} - -class _VerticalTooltipLabelStylePageState extends State { - double _value = 6.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - tooltipTextStyle: TextStyle(color: Colors.red, fontSize: 16, fontStyle: FontStyle.italic), - ), - child: SfSlider.vertical( - min: 2.0, - max: 10.0, - interval: 1, - showTicks: true, - showLabels: true, - enableTooltip: true, - value: _value, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Tooltip style support](images/tooltip/vertical-slider-tooltip-style.png) +--- +layout: post +title: Tooltip in Flutter Slider | Syncfusion +description: Step-by-step guide to configure tooltips in Syncfusion Flutter Slider—enable tooltips, format text, customize appearance, and control behavior. +platform: flutter +control: SfSlider +documentation: ug +--- + +# Flutter Slider Tooltip (SfSlider) + +This section explains how to add a tooltip in the Flutter Slider. + +## Enable tooltip + +You can enable a tooltip for the thumb using the [`enableTooltip`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/enableTooltip.html) property. It is used to clearly indicate the current selection of the value during interaction. By default, tooltip text is formatted with either [`numberFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/numberFormat.html) or [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/dateFormat.html). + +I> By setting the value of [`shouldAlwaysShowTooltip`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/shouldAlwaysShowTooltip.html) to true, you can always show a tooltip without having to interact with the slider thumb. The default value is `false` and it works independent of the [`enableTooltip`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/enableTooltip.html) behavior. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class EnableTooltipPage extends StatefulWidget { + @override + _EnableTooltipPageState createState() => _EnableTooltipPageState(); +} + +class _EnableTooltipPageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider( + min: 0.0, + max: 10.0, + interval: 2, + showTicks: true, + showLabels: true, + enableTooltip: true, + value: _value, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Slider tooltip support](images/tooltip/show-tooltip.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalEnableTooltipPage extends StatefulWidget { + @override + _VerticalEnableTooltipPageState createState() => _VerticalEnableTooltipPageState(); +} + +class _VerticalEnableTooltipPageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider.vertical( + min: 0.0, + max: 10.0, + interval: 2, + showTicks: true, + showLabels: true, + enableTooltip: true, + value: _value, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Slider tooltip support](images/tooltip/vertical-show-tooltip.png) + + +N> +* Refer the [`tooltipTextFormatterCallback`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/tooltipTextFormatterCallback.html) for changing the default tooltip text. +* Refer the [`SfSliderThemeData`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData-class.html) for customizing the appearance of the tooltip text. + +## Tooltip shape + +You can show tooltip in rectangular or paddle shape using the [`tooltipShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/tooltipShape.html) property. The default value of the [`tooltipShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/tooltipShape.html) property is [`SfRectangularTooltipShape`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfRectangularTooltipShape-class.html). + +N> The paddle tooltip shape is not applicable for vertical orientation of the sliders. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class TooltipShapePage extends StatefulWidget { + @override + _TooltipShapePageState createState() => _TooltipShapePageState(); +} + +class _TooltipShapePageState extends State { + double _value = 40.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider( + min: 0.0, + max: 100.0, + interval: 20, + showTicks: true, + showLabels: true, + enableTooltip: true, + tooltipShape: SfPaddleTooltipShape(), + value: _value, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Slider tooltip shape](images/tooltip/tooltip-shape.png) + +## Tooltip position + +N> This is only applicable for vertical orientation of the sliders. + +You can show tooltip in left or right positions using the [`tooltipPosition`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SliderTooltipPosition.html) property. The default value of the [`tooltipPosition`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SliderTooltipPosition.html) property is `SliderTooltipPosition.left`. + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class TooltipPositionPage extends StatefulWidget { + @override + _TooltipPositionPageState createState() => _TooltipPositionPageState(); +} + +class _TooltipPositionPageState extends State { + double _value = 40.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider.vertical( + min: 0.0, + max: 100.0, + interval: 20, + showTicks: true, + showLabels: true, + tooltipPosition: SliderTooltipPosition.right, + enableTooltip: true, + value: _value, + onChanged: (double newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Slider tooltip shape](images/tooltip/right_tooltip.png) + +## Tooltip text format + +By default it is formatted based on [`numberFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/numberFormat.html) property and [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/dateFormat.html) property based on whether it is date type [`SfSlider`](https://help.syncfusion.com/flutter/slider/getting-started#set-date-value) or numeric [`SfSlider`](https://help.syncfusion.com/flutter/slider/getting-started#set-numeric-value). + +You can format or change the whole tooltip label text using the [`tooltipTextFormatterCallback`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/tooltipTextFormatterCallback.html). Its arguments are, + +* actualValue – either `DateTime` or `double` based on given [`value`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/value.html). +* formattedText – If the actual value is `double`, it is formatted by [`numberFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/numberFormat.html) and if the actual value is `DateTime`, it is formatted by [`dateFormat`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/dateFormat.html). + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class TooltipTextFormatPage extends StatefulWidget { + @override + _TooltipTextFormatPageState createState() => _TooltipTextFormatPageState(); +} + +class _TooltipTextFormatPageState extends State { + DateTime _value = DateTime(2010, 01, 01, 15, 00, 00); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider( + min: DateTime(2010, 01, 01, 9, 00, 00), + max: DateTime(2010, 01, 01, 21, 05, 00), + value: _value, + interval: 3, + showTicks: true, + showLabels: true, + enableTooltip: true, + dateFormat: DateFormat('h:mm'), + dateIntervalType: DateIntervalType.hours, + tooltipTextFormatterCallback: (dynamic actualValue, String formattedText) { + return DateFormat('h:mm a').format(actualValue); + }, + onChanged: (DateTime newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Tooltip formatter support](images/tooltip/tooltip-formatter.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalTooltipTextFormatPage extends StatefulWidget { + @override + _VerticalTooltipTextFormatPageState createState() => _VerticalTooltipTextFormatPageState(); +} + +class _VerticalTooltipTextFormatPageState extends State { + DateTime _value = DateTime(2010, 01, 01, 15, 00, 00); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSlider.vertical( + min: DateTime(2010, 01, 01, 9, 00, 00), + max: DateTime(2010, 01, 01, 21, 05, 00), + value: _value, + interval: 3, + showTicks: true, + showLabels: true, + enableTooltip: true, + dateFormat: DateFormat('h:mm'), + dateIntervalType: DateIntervalType.hours, + tooltipTextFormatterCallback: (dynamic actualValue, String formattedText) { + return DateFormat('h:mm a').format(actualValue); + }, + onChanged: (DateTime newValue) { + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Tooltip formatter support](images/tooltip/vertical-tooltip-formatter.png) + + +## Tooltip color + +You can change the background color of the tooltip in the Flutter Slider using the [`tooltipBackgroundColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/tooltipBackgroundColor.html) property. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class TooltipColorPage extends StatefulWidget { + @override + _TooltipColorPageState createState() => _TooltipColorPageState(); +} + +class _TooltipColorPageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + tooltipBackgroundColor: Colors.red[300], + ), + child: SfSlider( + min: 2.0, + max: 10.0, + interval: 1, + showTicks: true, + showLabels: true, + enableTooltip: true, + value: _value, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Tooltip color support](images/tooltip/slider-tooltip-color.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalTooltipColorPage extends StatefulWidget { + @override + _VerticalTooltipColorPageState createState() => _VerticalTooltipColorPageState(); +} + +class _VerticalTooltipColorPageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + tooltipBackgroundColor: Colors.red[300], + ), + child: SfSlider.vertical( + min: 2.0, + max: 10.0, + interval: 1, + showTicks: true, + showLabels: true, + enableTooltip: true, + value: _value, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Tooltip color support](images/tooltip/vertical-slider-tooltip-color.png) + +## Tooltip label style + +You can change the appearance of the tooltip text in the Flutter Slider using the [`tooltipTextStyle`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/tooltipTextStyle.html) property. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class TooltipLabelStylePage extends StatefulWidget { + @override + _TooltipLabelStylePageState createState() => _TooltipLabelStylePageState(); +} + +class _TooltipLabelStylePageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + tooltipTextStyle: TextStyle(color: Colors.red, fontSize: 16, fontStyle: FontStyle.italic), + ), + child: SfSlider( + min: 2.0, + max: 10.0, + interval: 1, + showTicks: true, + showLabels: true, + enableTooltip: true, + value: _value, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Tooltip style support](images/tooltip/slider-tooltip-style.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalTooltipLabelStylePage extends StatefulWidget { + @override + _VerticalTooltipLabelStylePageState createState() => _VerticalTooltipLabelStylePageState(); +} + +class _VerticalTooltipLabelStylePageState extends State { + double _value = 6.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + tooltipTextStyle: TextStyle(color: Colors.red, fontSize: 16, fontStyle: FontStyle.italic), + ), + child: SfSlider.vertical( + min: 2.0, + max: 10.0, + interval: 1, + showTicks: true, + showLabels: true, + enableTooltip: true, + value: _value, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Tooltip style support](images/tooltip/vertical-slider-tooltip-style.png) diff --git a/Flutter/slider/track.md b/Flutter/slider/track.md index 152c6e6f0..6cc2c434d 100644 --- a/Flutter/slider/track.md +++ b/Flutter/slider/track.md @@ -1,328 +1,328 @@ ---- -layout: post -title: Track in Flutter Slider | Syncfusion® -description: Learn about track customization in Syncfusion® Flutter Slider (SfSlider), including track appearance, active and inactive tracks, and styling options. -platform: flutter -control: SfSlider -documentation: ug ---- - -# Track in Flutter Slider (SfSlider) - -This section explains how to customize the track in the slider. - -N> You must import the `theme.dart` library from the [`Core`](https://pub.dev/packages/syncfusion_flutter_core) package to use [`SfSliderTheme`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderTheme-class.html) in all the examples shown below. - -## Track color - -You can change the active and inactive track color of the slider using the [`activeTrackColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeTrackColor.html) and [`inactiveTrackColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveTrackColor.html) properties respectively. - -The active side of the slider is between the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html) value and the thumb. - -The inactive side of the slider is between the thumb and the [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) value. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class TrackColorPage extends StatefulWidget { - @override - _TrackColorPageState createState() => _TrackColorPageState(); -} - -class _TrackColorPageState extends State { - double _value = 5.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - activeTrackColor: Colors.red, - inactiveTrackColor: Colors.red[100], - ), - child: SfSlider( - min: 2.0, - max: 10.0, - value: _value, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Track color support](images/track/slider-track-color.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalTrackColorPage extends StatefulWidget { - @override - _VerticalTrackColorPageState createState() => _VerticalTrackColorPageState(); -} - -class _VerticalTrackColorPageState extends State { - double _value = 5.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - activeTrackColor: Colors.red, - inactiveTrackColor: Colors.red[100], - ), - child: SfSlider.vertical( - min: 2.0, - max: 10.0, - value: _value, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Track color support](images/track/vertical_slider_track_color.png) - -## Track height - -You can change the track height of the slider using the [`activeTrackHeight`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeTrackHeight.html) and [`inactiveTrackHeight`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveTrackHeight.html) properties. The default value of the [`activeTrackHeight`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeTrackHeight.html) and the [`inactiveTrackHeight`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveTrackHeight.html) properties are `6.0` and `4.0`. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class TrackHeightPage extends StatefulWidget { - @override - _TrackHeightPageState createState() => _TrackHeightPageState(); -} - -class _TrackHeightPageState extends State { - double _value = 5.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - activeTrackHeight: 8, - inactiveTrackHeight: 8, - ), - child: SfSlider( - min: 2.0, - max: 10.0, - value: _value, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Track size support](images/track/slider-track-size.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalTrackHeightPage extends StatefulWidget { - @override - _VerticalTrackHeightPageState createState() => _VerticalTrackHeightPageState(); -} - -class _VerticalTrackHeightPageState extends State { - double _value = 5.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - activeTrackHeight: 8, - inactiveTrackHeight: 8, - ), - child: SfSlider.vertical( - min: 2.0, - max: 10.0, - value: _value, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Track size support](images/track/vertical_slider_track_size.png) - -## Track corner radius - -You can change the corner of the track to be round in the slider using the [`trackCornerRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/trackCornerRadius.html) property. The default value of the [`trackCornerRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/trackCornerRadius.html) property is `1.0`. - -### Horizontal - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class TrackCornerRadiusPage extends StatefulWidget { - @override - _TrackCornerRadiusPageState createState() => _TrackCornerRadiusPageState(); -} - -class _TrackCornerRadiusPageState extends State { - double _value = 5.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - // Track height is increased so that the rounded corners are clearly visible. - activeTrackHeight: 10, - inactiveTrackHeight: 10, - trackCornerRadius: 5, - ), - child: SfSlider( - min: 2.0, - max: 10.0, - value: _value, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Track corner radius support](images/track/slider-track-corner-radius.png) - -### Vertical - -{% tabs %} -{% highlight Dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_core/theme.dart'; -import 'package:syncfusion_flutter_sliders/sliders.dart'; - -class VerticalTrackCornerRadiusPage extends StatefulWidget { - @override - _VerticalTrackCornerRadiusPageState createState() => _VerticalTrackCornerRadiusPageState(); -} - -class _VerticalTrackCornerRadiusPageState extends State { - double _value = 5.0; - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SfSliderTheme( - data: SfSliderThemeData( - // Track height is increased so that the rounded corners are clearly visible. - activeTrackHeight: 10, - inactiveTrackHeight: 10, - trackCornerRadius: 5, - ), - child: SfSlider.vertical( - min: 2.0, - max: 10.0, - value: _value, - onChanged: (double newValue){ - setState(() { - _value = newValue; - }); - }, - ), - ) - ) - ) - ); - } -} - -{% endhighlight %} -{% endtabs %} - -![Track corner radius support](images/track/vertical_slider_track_corner_radius.png) +--- +layout: post +title: Track in Flutter Slider | Syncfusion® +description: Learn about track customization in Syncfusion® Flutter Slider (SfSlider), including track appearance, active and inactive tracks, and styling options. +platform: flutter +control: SfSlider +documentation: ug +--- + +# Track in Flutter Slider (SfSlider) + +This section explains how to customize the track in the slider. + +N> You must import the `theme.dart` library from the [`Core`](https://pub.dev/packages/syncfusion_flutter_core) package to use [`SfSliderTheme`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderTheme-class.html) in all the examples shown below. + +## Track color + +You can change the active and inactive track color of the Flutter Slider using the [`activeTrackColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeTrackColor.html) and [`inactiveTrackColor`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveTrackColor.html) properties respectively. + +The active side of the Flutter Slider is between the [`min`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/min.html) value and the thumb. + +The inactive side of the Flutter Slider is between the thumb and the [`max`](https://pub.dev/documentation/syncfusion_flutter_sliders/latest/sliders/SfSlider/max.html) value. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class TrackColorPage extends StatefulWidget { + @override + _TrackColorPageState createState() => _TrackColorPageState(); +} + +class _TrackColorPageState extends State { + double _value = 5.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + activeTrackColor: Colors.red, + inactiveTrackColor: Colors.red[100], + ), + child: SfSlider( + min: 2.0, + max: 10.0, + value: _value, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Track color support](images/track/slider-track-color.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalTrackColorPage extends StatefulWidget { + @override + _VerticalTrackColorPageState createState() => _VerticalTrackColorPageState(); +} + +class _VerticalTrackColorPageState extends State { + double _value = 5.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + activeTrackColor: Colors.red, + inactiveTrackColor: Colors.red[100], + ), + child: SfSlider.vertical( + min: 2.0, + max: 10.0, + value: _value, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Track color support](images/track/vertical_slider_track_color.png) + +## Track height + +You can change the track height of the Flutter Slider using the [`activeTrackHeight`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeTrackHeight.html) and [`inactiveTrackHeight`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveTrackHeight.html) properties. The default value of the [`activeTrackHeight`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/activeTrackHeight.html) and the [`inactiveTrackHeight`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/inactiveTrackHeight.html) properties are `6.0` and `4.0`. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class TrackHeightPage extends StatefulWidget { + @override + _TrackHeightPageState createState() => _TrackHeightPageState(); +} + +class _TrackHeightPageState extends State { + double _value = 5.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + activeTrackHeight: 8, + inactiveTrackHeight: 8, + ), + child: SfSlider( + min: 2.0, + max: 10.0, + value: _value, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Track size support](images/track/slider-track-size.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalTrackHeightPage extends StatefulWidget { + @override + _VerticalTrackHeightPageState createState() => _VerticalTrackHeightPageState(); +} + +class _VerticalTrackHeightPageState extends State { + double _value = 5.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + activeTrackHeight: 8, + inactiveTrackHeight: 8, + ), + child: SfSlider.vertical( + min: 2.0, + max: 10.0, + value: _value, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Track size support](images/track/vertical_slider_track_size.png) + +## Track corner radius + +You can change the corner of the track to be round in the Slider using the [`trackCornerRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/trackCornerRadius.html) property. The default value of the [`trackCornerRadius`](https://pub.dev/documentation/syncfusion_flutter_core/latest/theme/SfSliderThemeData/trackCornerRadius.html) property is `1.0`. + +### Horizontal + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class TrackCornerRadiusPage extends StatefulWidget { + @override + _TrackCornerRadiusPageState createState() => _TrackCornerRadiusPageState(); +} + +class _TrackCornerRadiusPageState extends State { + double _value = 5.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + // Track height is increased so that the rounded corners are clearly visible. + activeTrackHeight: 10, + inactiveTrackHeight: 10, + trackCornerRadius: 5, + ), + child: SfSlider( + min: 2.0, + max: 10.0, + value: _value, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Track corner radius support](images/track/slider-track-corner-radius.png) + +### Vertical + +{% tabs %} +{% highlight Dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_core/theme.dart'; +import 'package:syncfusion_flutter_sliders/sliders.dart'; + +class VerticalTrackCornerRadiusPage extends StatefulWidget { + @override + _VerticalTrackCornerRadiusPageState createState() => _VerticalTrackCornerRadiusPageState(); +} + +class _VerticalTrackCornerRadiusPageState extends State { + double _value = 5.0; + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SfSliderTheme( + data: SfSliderThemeData( + // Track height is increased so that the rounded corners are clearly visible. + activeTrackHeight: 10, + inactiveTrackHeight: 10, + trackCornerRadius: 5, + ), + child: SfSlider.vertical( + min: 2.0, + max: 10.0, + value: _value, + onChanged: (double newValue){ + setState(() { + _value = newValue; + }); + }, + ), + ) + ) + ) + ); + } +} + +{% endhighlight %} +{% endtabs %} + +![Track corner radius support](images/track/vertical_slider_track_corner_radius.png) diff --git a/Flutter/treemap/drilldown.md b/Flutter/treemap/drilldown.md index f9619df50..5017a414b 100644 --- a/Flutter/treemap/drilldown.md +++ b/Flutter/treemap/drilldown.md @@ -1,424 +1,424 @@ ---- -layout: post -title: Drilldown in Flutter Treemap | Syncfusion® -description: Learn about drilldown support in Syncfusion® Flutter Treemap (SfTreemap), including hierarchical navigation, drilldown levels, and interactive data exploration. -platform: flutter -control: SfTreemap -documentation: ug ---- - -# Drilldown in Flutter Treemap (SfTreemap) - -The drilldown feature provides better visualization of a larger set of hierarchical-level data. - -To learn more about the drilldown feature in Flutter Treemap, you can watch this video. - - - - -## Enable drilldown - -You can drill down the tiles by setting the [`enableDrilldown`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/enableDrilldown.html) property to `true`. In the UI, you can only see one level tiles at a time. When you tap a tile, it expands to the size of the viewport and loads its descendant tiles with smoother animation. - -The widget returned by the [`TreemapBreadcrumbs.builder`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapBreadcrumbs/builder.html) will be added to the breadcrumbs item. While drilling down the tiles, it is called with the tapped tile details. - -Selection for touch and mouse-enabled devices, and tooltip for touch devices, will work only for the tiles that don’t have descendants. - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -class TreemapDrilldownExample extends StatefulWidget { - const TreemapDrilldownExample({super.key}); - - @override - State createState() => - _TreemapDrilldownExampleState(); -} - -class _TreemapDrilldownExampleState extends State { - late List _source; - late Map _colors; - - @override - void initState() { - _source = [ - const CarSale(carName: 'Hyundai', model: 'Elantra', totalScale: 198210), - const CarSale(carName: 'Hyundai', model: 'Sonata', totalScale: 131803), - const CarSale(carName: 'Hyundai', model: 'Tucson', totalScale: 114735), - const CarSale(carName: 'Hyundai', model: 'Santa Fe', totalScale: 133171), - const CarSale(carName: 'Hyundai', model: 'Accent', totalScale: 58955), - const CarSale(carName: 'Hyundai', model: 'Veloster', totalScale: 12658), - const CarSale(carName: 'Hyundai', model: 'loniq', totalScale: 11197), - const CarSale(carName: 'Hyundai', model: 'Azera', totalScale: 3060), - const CarSale(carName: 'Benz', model: 'C-Class', totalScale: 77447), - const CarSale(carName: 'Benz', model: 'GLE-Class', totalScale: 54595), - const CarSale(carName: 'Benz', model: 'E/CLS-Class', totalScale: 51312), - const CarSale(carName: 'Benz', model: 'GLC-Class', totalScale: 48643), - const CarSale(carName: 'Benz', model: 'GLS-Class', totalScale: 322548), - const CarSale(carName: 'Benz', model: 'Sprinter', totalScale: 27415), - const CarSale(carName: 'Benz', model: 'CLA-Class', totalScale: 20669), - const CarSale(carName: 'Benz', model: 'GLA-Class', totalScale: 24104), - const CarSale(carName: 'Benz', model: 'S-Class', totalScale: 15888), - const CarSale(carName: 'Benz', model: 'Metris', totalScale: 7579), - const CarSale(carName: 'BMW', model: '3-Series', totalScale: 59449), - const CarSale(carName: 'BMW', model: 'X5', totalScale: 50815), - const CarSale(carName: 'BMW', model: 'X3', totalScale: 40691), - const CarSale(carName: 'BMW', model: '5-Series', totalScale: 40658), - const CarSale(carName: 'BMW', model: '4-Series', totalScale: 39634), - const CarSale(carName: 'BMW', model: '2-Series', totalScale: 11737), - const CarSale(carName: 'BMW', model: '7-Series', totalScale: 9276), - const CarSale(carName: 'BMW', model: 'X1', totalScale: 30826), - const CarSale(carName: 'BMW', model: 'X6', totalScale: 6780), - const CarSale(carName: 'BMW', model: 'X4', totalScale: 5198), - const CarSale(carName: 'BMW', model: '6-Series', totalScale: 3355), - const CarSale(carName: 'Jeep', model: 'Grand Cherokee', totalScale: 240696), - const CarSale(carName: 'Jeep', model: 'Cherokee', totalScale: 169822), - const CarSale(carName: 'Jeep', model: 'Renegade', totalScale: 103434), - const CarSale(carName: 'Jeep', model: 'Wrangler', totalScale: 190522), - const CarSale(carName: 'Jeep', model: 'Compass', totalScale: 83523), - const CarSale(carName: 'Jeep', model: 'Patriot', totalScale: 10735), - const CarSale(carName: 'Nissan', model: 'Rogue', totalScale: 403465), - const CarSale(carName: 'Nissan', model: 'Sentra', totalScale: 218451), - const CarSale(carName: 'Nissan', model: 'Murano', totalScale: 76732), - const CarSale(carName: 'Nissan', model: 'Frontier', totalScale: 74360), - const CarSale(carName: 'Nissan', model: 'Altima', totalScale: 254996), - const CarSale(carName: 'Nissan', model: 'Versa', totalScale: 106772), - const CarSale(carName: 'Nissan', model: 'Pathfinder', totalScale: 81065), - const CarSale(carName: 'Nissan', model: 'Maxima', totalScale: 67627), - const CarSale(carName: 'Nissan', model: 'Titan', totalScale: 52924), - const CarSale(carName: 'Nissan', model: 'Armada', totalScale: 35667), - const CarSale(carName: 'Nissan', model: 'NV', totalScale: 17858), - const CarSale(carName: 'Nissan', model: 'NV200', totalScale: 18602), - const CarSale(carName: 'Nissan', model: 'Duke', totalScale: 10157), - const CarSale(carName: 'Honda', model: 'Rogue', totalScale: 403465), - const CarSale(carName: 'Honda', model: 'Sentra', totalScale: 218451), - const CarSale(carName: 'Honda', model: 'Murano', totalScale: 76732), - const CarSale(carName: 'Honda', model: 'Frontier', totalScale: 74360), - const CarSale(carName: 'Honda', model: 'Altima', totalScale: 254996), - const CarSale(carName: 'Honda', model: 'Versa', totalScale: 106772), - const CarSale(carName: 'Honda', model: 'Maxima', totalScale: 67627), - const CarSale(carName: 'Honda', model: 'Titan', totalScale: 52924), - const CarSale(carName: 'Honda', model: 'Armada', totalScale: 35667), - const CarSale(carName: 'Honda', model: 'NV', totalScale: 17858), - const CarSale(carName: 'Honda', model: 'NV200', totalScale: 18602), - const CarSale(carName: 'Honda', model: 'Duke', totalScale: 10157), - const CarSale(carName: 'Ford', model: 'F-Series', totalScale: 896764), - const CarSale(carName: 'Ford', model: 'Explorer', totalScale: 271134), - const CarSale(carName: 'Ford', model: 'Fusion', totalScale: 209623), - const CarSale(carName: 'Ford', model: 'Focus', totalScale: 158385), - const CarSale(carName: 'Ford', model: 'Edge', totalScale: 142603), - const CarSale(carName: 'Ford', model: 'Transit', totalScale: 127340), - const CarSale(carName: 'Ford', model: 'Mustang', totalScale: 81866), - const CarSale(carName: 'Ford', model: 'Escape', totalScale: 308286), - const CarSale(carName: 'Ford', model: 'E-Series', totalScale: 53304), - const CarSale(carName: 'Ford', model: 'Expedition', totalScale: 51833), - const CarSale(carName: 'Ford', model: 'Fiesta', totalScale: 46249), - const CarSale(carName: 'Ford', model: 'Taurus', totalScale: 41326), - const CarSale(carName: 'Ford', model: 'Flex', totalScale: 22389), - const CarSale(carName: 'Ford', model: 'Transit Connect', totalScale: 34473), - ]; - - _colors = { - 'Hyundai': const Color.fromRGBO(220, 103, 171, 1.0), - 'BMW': const Color.fromRGBO(160, 220, 103, 1.0), - 'Benz': const Color.fromRGBO(220, 210, 103, 1.0), - 'Nissan': const Color.fromRGBO(163, 103, 220, 1.0), - 'Jeep': const Color.fromRGBO(220, 105, 103, 1.0), - 'Ford': const Color.fromRGBO(103, 183, 220, 1.0), - 'Honda': const Color.fromRGBO(103, 220, 187, 1.0), - }; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: Container( - height: 400, - width: 400, - child: SfTreemap( - dataCount: _source.length, - weightValueMapper: (int index) { - return _source[index].totalScale!; - }, - enableDrilldown: true, - breadcrumbs: TreemapBreadcrumbs( - builder: (BuildContext context, TreemapTile tile, bool isCurrent) { - return Text(tile.group, style: const TextStyle(color: Colors.black)); - }, - ), - levels: [ - TreemapLevel( - groupMapper: (int index) => _source[index].carName, - labelBuilder: (BuildContext context, TreemapTile tile) { - return Padding( - padding: const EdgeInsets.only(left: 5.0, top: 5.0), - child: Text( - tile.group, - style: const TextStyle(color: Colors.black), - overflow: TextOverflow.ellipsis, - ), - ); - }, - colorValueMapper: (TreemapTile tile) { - return _colors[_source[tile.indices[0]].carName]; - }, - ), - TreemapLevel( - groupMapper: (int index) { - return _source[index].model; - }, - colorValueMapper: (TreemapTile tile) { - return _colors[_source[tile.indices[0]].carName]; - }, - labelBuilder: (BuildContext context, TreemapTile tile) { - return Padding( - padding: const EdgeInsets.only(left: 5.0, top: 5.0), - child: Text( - tile.group, - style: const TextStyle(color: Colors.black), - overflow: TextOverflow.ellipsis, - ), - ); - }, - ), - ], - ), - ), - ), - ); - } -} - -class CarSale { - const CarSale({ - required this.carName, - this.model, - this.version, - this.versionNumber, - this.totalScale, - }); - - final String carName; - final String? model; - final String? version; - final String? versionNumber; - final double? totalScale; -} - -{% endhighlight %} -{% endtabs %} - -![Treemap drilldown](images/drilldown/drilldown.gif) - -## Breadcrumb customization - -The breadcrumb is used to display information about the drilled item and provides an option to navigate back to the previous level. You can customize the breadcrumb items using the following properties: - -* **Position** - Positions the breadcrumbs either at the top or bottom of the treemap. The default value of the [`position`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapBreadcrumbs/position.html) is [`TreemapBreadcrumbPosition.top`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapBreadcrumbPosition.html#top). -* **Divider** - Used to add a separator between two breadcrumbs. - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -class TreemapBreadcrumbCustomizationExample extends StatefulWidget { - const TreemapBreadcrumbCustomizationExample({super.key}); - - @override - State createState() => - _TreemapBreadcrumbCustomizationExampleState(); -} - -class _TreemapBreadcrumbCustomizationExampleState - extends State { - late List _source; - late Map _colors; - - @override - void initState() { - _source = [ - const CarSale(carName: 'Hyundai', model: 'Elantra', totalScale: 198210), - const CarSale(carName: 'Hyundai', model: 'Sonata', totalScale: 131803), - const CarSale(carName: 'Hyundai', model: 'Tucson', totalScale: 114735), - const CarSale(carName: 'Hyundai', model: 'Santa Fe', totalScale: 133171), - const CarSale(carName: 'Hyundai', model: 'Accent', totalScale: 58955), - const CarSale(carName: 'Hyundai', model: 'Veloster', totalScale: 12658), - const CarSale(carName: 'Hyundai', model: 'loniq', totalScale: 11197), - const CarSale(carName: 'Hyundai', model: 'Azera', totalScale: 3060), - const CarSale(carName: 'Benz', model: 'C-Class', totalScale: 77447), - const CarSale(carName: 'Benz', model: 'GLE-Class', totalScale: 54595), - const CarSale(carName: 'Benz', model: 'E/CLS-Class', totalScale: 51312), - const CarSale(carName: 'Benz', model: 'GLC-Class', totalScale: 48643), - const CarSale(carName: 'Benz', model: 'GLS-Class', totalScale: 322548), - const CarSale(carName: 'Benz', model: 'Sprinter', totalScale: 27415), - const CarSale(carName: 'Benz', model: 'CLA-Class', totalScale: 20669), - const CarSale(carName: 'Benz', model: 'GLA-Class', totalScale: 24104), - const CarSale(carName: 'Benz', model: 'S-Class', totalScale: 15888), - const CarSale(carName: 'Benz', model: 'Metris', totalScale: 7579), - const CarSale(carName: 'BMW', model: '3-Series', totalScale: 59449), - const CarSale(carName: 'BMW', model: 'X5', totalScale: 50815), - const CarSale(carName: 'BMW', model: 'X3', totalScale: 40691), - const CarSale(carName: 'BMW', model: '5-Series', totalScale: 40658), - const CarSale(carName: 'BMW', model: '4-Series', totalScale: 39634), - const CarSale(carName: 'BMW', model: '2-Series', totalScale: 11737), - const CarSale(carName: 'BMW', model: '7-Series', totalScale: 9276), - const CarSale(carName: 'BMW', model: 'X1', totalScale: 30826), - const CarSale(carName: 'BMW', model: 'X6', totalScale: 6780), - const CarSale(carName: 'BMW', model: 'X4', totalScale: 5198), - const CarSale(carName: 'BMW', model: '6-Series', totalScale: 3355), - const CarSale(carName: 'Jeep', model: 'Grand Cherokee', totalScale: 240696), - const CarSale(carName: 'Jeep', model: 'Cherokee', totalScale: 169822), - const CarSale(carName: 'Jeep', model: 'Renegade', totalScale: 103434), - const CarSale(carName: 'Jeep', model: 'Wrangler', totalScale: 190522), - const CarSale(carName: 'Jeep', model: 'Compass', totalScale: 83523), - const CarSale(carName: 'Jeep', model: 'Patriot', totalScale: 10735), - const CarSale(carName: 'Nissan', model: 'Rogue', totalScale: 403465), - const CarSale(carName: 'Nissan', model: 'Sentra', totalScale: 218451), - const CarSale(carName: 'Nissan', model: 'Murano', totalScale: 76732), - const CarSale(carName: 'Nissan', model: 'Frontier', totalScale: 74360), - const CarSale(carName: 'Nissan', model: 'Altima', totalScale: 254996), - const CarSale(carName: 'Nissan', model: 'Versa', totalScale: 106772), - const CarSale(carName: 'Nissan', model: 'Pathfinder', totalScale: 81065), - const CarSale(carName: 'Nissan', model: 'Maxima', totalScale: 67627), - const CarSale(carName: 'Nissan', model: 'Titan', totalScale: 52924), - const CarSale(carName: 'Nissan', model: 'Armada', totalScale: 35667), - const CarSale(carName: 'Nissan', model: 'NV', totalScale: 17858), - const CarSale(carName: 'Nissan', model: 'NV200', totalScale: 18602), - const CarSale(carName: 'Nissan', model: 'Duke', totalScale: 10157), - const CarSale(carName: 'Honda', model: 'Rogue', totalScale: 403465), - const CarSale(carName: 'Honda', model: 'Sentra', totalScale: 218451), - const CarSale(carName: 'Honda', model: 'Murano', totalScale: 76732), - const CarSale(carName: 'Honda', model: 'Frontier', totalScale: 74360), - const CarSale(carName: 'Honda', model: 'Altima', totalScale: 254996), - const CarSale(carName: 'Honda', model: 'Versa', totalScale: 106772), - const CarSale(carName: 'Honda', model: 'Maxima', totalScale: 67627), - const CarSale(carName: 'Honda', model: 'Titan', totalScale: 52924), - const CarSale(carName: 'Honda', model: 'Armada', totalScale: 35667), - const CarSale(carName: 'Honda', model: 'NV', totalScale: 17858), - const CarSale(carName: 'Honda', model: 'NV200', totalScale: 18602), - const CarSale(carName: 'Honda', model: 'Duke', totalScale: 10157), - const CarSale(carName: 'Ford', model: 'F-Series', totalScale: 896764), - const CarSale(carName: 'Ford', model: 'Explorer', totalScale: 271134), - const CarSale(carName: 'Ford', model: 'Fusion', totalScale: 209623), - const CarSale(carName: 'Ford', model: 'Focus', totalScale: 158385), - const CarSale(carName: 'Ford', model: 'Edge', totalScale: 142603), - const CarSale(carName: 'Ford', model: 'Transit', totalScale: 127340), - const CarSale(carName: 'Ford', model: 'Mustang', totalScale: 81866), - const CarSale(carName: 'Ford', model: 'Escape', totalScale: 308286), - const CarSale(carName: 'Ford', model: 'E-Series', totalScale: 53304), - const CarSale(carName: 'Ford', model: 'Expedition', totalScale: 51833), - const CarSale(carName: 'Ford', model: 'Fiesta', totalScale: 46249), - const CarSale(carName: 'Ford', model: 'Taurus', totalScale: 41326), - const CarSale(carName: 'Ford', model: 'Flex', totalScale: 22389), - const CarSale(carName: 'Ford', model: 'Transit Connect', totalScale: 34473), - ]; - - _colors = { - 'Hyundai': const Color.fromRGBO(220, 103, 171, 1.0), - 'BMW': const Color.fromRGBO(160, 220, 103, 1.0), - 'Benz': const Color.fromRGBO(220, 210, 103, 1.0), - 'Nissan': const Color.fromRGBO(163, 103, 220, 1.0), - 'Jeep': const Color.fromRGBO(220, 105, 103, 1.0), - 'Ford': const Color.fromRGBO(103, 183, 220, 1.0), - 'Honda': const Color.fromRGBO(103, 220, 187, 1.0), - }; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: Container( - height: 400, - width: 400, - child: SfTreemap( - dataCount: _source.length, - weightValueMapper: (int index) { - return _source[index].totalScale!; - }, - enableDrilldown: true, - breadcrumbs: TreemapBreadcrumbs( - builder: (BuildContext context, TreemapTile tile, bool isCurrent) { - if (tile.group == 'Home') { - return const Icon(Icons.home, color: Colors.black); - } - - return Text( - tile.group, - style: const TextStyle(color: Colors.black), - ); - }, - divider: const Icon(Icons.chevron_right, color: Colors.black), - position: TreemapBreadcrumbPosition.top, - ), - levels: [ - TreemapLevel( - groupMapper: (int index) => _source[index].carName, - labelBuilder: (BuildContext context, TreemapTile tile) { - return Padding( - padding: const EdgeInsets.only(left: 5.0, top: 5.0), - child: Text( - tile.group, - style: const TextStyle(color: Colors.black), - overflow: TextOverflow.ellipsis, - ), - ); - }, - colorValueMapper: (TreemapTile tile) { - return _colors[_source[tile.indices[0]].carName]; - }, - ), - TreemapLevel( - groupMapper: (int index) { - return _source[index].model; - }, - colorValueMapper: (TreemapTile tile) { - return _colors[_source[tile.indices[0]].carName]; - }, - labelBuilder: (BuildContext context, TreemapTile tile) { - return Padding( - padding: const EdgeInsets.only(left: 5.0, top: 5.0), - child: Text( - tile.group, - style: const TextStyle(color: Colors.black), - overflow: TextOverflow.ellipsis, - ), - ); - }, - ), - ], - ), - ), - ), - ); - } -} - -class CarSale { - const CarSale({ - required this.carName, - this.model, - this.version, - this.versionNumber, - this.totalScale, - }); - - final String carName; - final String? model; - final String? version; - final String? versionNumber; - final double? totalScale; -} - -{% endhighlight %} -{% endtabs %} - +--- +layout: post +title: Drilldown in Flutter Treemap | Syncfusion® +description: Learn about drilldown support in Syncfusion® Flutter Treemap (SfTreemap), including hierarchical navigation, drilldown levels, and interactive data exploration. +platform: flutter +control: SfTreemap +documentation: ug +--- + +# Drilldown in Flutter Treemap (SfTreemap) + +The drilldown feature provides better visualization of a larger set of hierarchical-level data. + +To learn more about the drilldown feature in Flutter Treemap, you can watch this video. + + + + +## Enable drilldown + +You can drill down the tiles by setting the [`enableDrilldown`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/enableDrilldown.html) property to `true`. In the UI, you can only see one level tiles at a time. When you tap a tile, it expands to the size of the viewport and loads its descendant tiles with smoother animation. + +The widget returned by the [`TreemapBreadcrumbs.builder`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapBreadcrumbs/builder.html) will be added to the breadcrumbs item. While drilling down the tiles, it is called with the tapped tile details. + +Selection for touch and mouse-enabled devices, and tooltip for touch devices, will work only for the tiles that don’t have descendants. + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +class TreemapDrilldownExample extends StatefulWidget { + const TreemapDrilldownExample({super.key}); + + @override + State createState() => + _TreemapDrilldownExampleState(); +} + +class _TreemapDrilldownExampleState extends State { + late List _source; + late Map _colors; + + @override + void initState() { + _source = [ + const CarSale(carName: 'Hyundai', model: 'Elantra', totalScale: 198210), + const CarSale(carName: 'Hyundai', model: 'Sonata', totalScale: 131803), + const CarSale(carName: 'Hyundai', model: 'Tucson', totalScale: 114735), + const CarSale(carName: 'Hyundai', model: 'Santa Fe', totalScale: 133171), + const CarSale(carName: 'Hyundai', model: 'Accent', totalScale: 58955), + const CarSale(carName: 'Hyundai', model: 'Veloster', totalScale: 12658), + const CarSale(carName: 'Hyundai', model: 'loniq', totalScale: 11197), + const CarSale(carName: 'Hyundai', model: 'Azera', totalScale: 3060), + const CarSale(carName: 'Benz', model: 'C-Class', totalScale: 77447), + const CarSale(carName: 'Benz', model: 'GLE-Class', totalScale: 54595), + const CarSale(carName: 'Benz', model: 'E/CLS-Class', totalScale: 51312), + const CarSale(carName: 'Benz', model: 'GLC-Class', totalScale: 48643), + const CarSale(carName: 'Benz', model: 'GLS-Class', totalScale: 322548), + const CarSale(carName: 'Benz', model: 'Sprinter', totalScale: 27415), + const CarSale(carName: 'Benz', model: 'CLA-Class', totalScale: 20669), + const CarSale(carName: 'Benz', model: 'GLA-Class', totalScale: 24104), + const CarSale(carName: 'Benz', model: 'S-Class', totalScale: 15888), + const CarSale(carName: 'Benz', model: 'Metris', totalScale: 7579), + const CarSale(carName: 'BMW', model: '3-Series', totalScale: 59449), + const CarSale(carName: 'BMW', model: 'X5', totalScale: 50815), + const CarSale(carName: 'BMW', model: 'X3', totalScale: 40691), + const CarSale(carName: 'BMW', model: '5-Series', totalScale: 40658), + const CarSale(carName: 'BMW', model: '4-Series', totalScale: 39634), + const CarSale(carName: 'BMW', model: '2-Series', totalScale: 11737), + const CarSale(carName: 'BMW', model: '7-Series', totalScale: 9276), + const CarSale(carName: 'BMW', model: 'X1', totalScale: 30826), + const CarSale(carName: 'BMW', model: 'X6', totalScale: 6780), + const CarSale(carName: 'BMW', model: 'X4', totalScale: 5198), + const CarSale(carName: 'BMW', model: '6-Series', totalScale: 3355), + const CarSale(carName: 'Jeep', model: 'Grand Cherokee', totalScale: 240696), + const CarSale(carName: 'Jeep', model: 'Cherokee', totalScale: 169822), + const CarSale(carName: 'Jeep', model: 'Renegade', totalScale: 103434), + const CarSale(carName: 'Jeep', model: 'Wrangler', totalScale: 190522), + const CarSale(carName: 'Jeep', model: 'Compass', totalScale: 83523), + const CarSale(carName: 'Jeep', model: 'Patriot', totalScale: 10735), + const CarSale(carName: 'Nissan', model: 'Rogue', totalScale: 403465), + const CarSale(carName: 'Nissan', model: 'Sentra', totalScale: 218451), + const CarSale(carName: 'Nissan', model: 'Murano', totalScale: 76732), + const CarSale(carName: 'Nissan', model: 'Frontier', totalScale: 74360), + const CarSale(carName: 'Nissan', model: 'Altima', totalScale: 254996), + const CarSale(carName: 'Nissan', model: 'Versa', totalScale: 106772), + const CarSale(carName: 'Nissan', model: 'Pathfinder', totalScale: 81065), + const CarSale(carName: 'Nissan', model: 'Maxima', totalScale: 67627), + const CarSale(carName: 'Nissan', model: 'Titan', totalScale: 52924), + const CarSale(carName: 'Nissan', model: 'Armada', totalScale: 35667), + const CarSale(carName: 'Nissan', model: 'NV', totalScale: 17858), + const CarSale(carName: 'Nissan', model: 'NV200', totalScale: 18602), + const CarSale(carName: 'Nissan', model: 'Duke', totalScale: 10157), + const CarSale(carName: 'Honda', model: 'Rogue', totalScale: 403465), + const CarSale(carName: 'Honda', model: 'Sentra', totalScale: 218451), + const CarSale(carName: 'Honda', model: 'Murano', totalScale: 76732), + const CarSale(carName: 'Honda', model: 'Frontier', totalScale: 74360), + const CarSale(carName: 'Honda', model: 'Altima', totalScale: 254996), + const CarSale(carName: 'Honda', model: 'Versa', totalScale: 106772), + const CarSale(carName: 'Honda', model: 'Maxima', totalScale: 67627), + const CarSale(carName: 'Honda', model: 'Titan', totalScale: 52924), + const CarSale(carName: 'Honda', model: 'Armada', totalScale: 35667), + const CarSale(carName: 'Honda', model: 'NV', totalScale: 17858), + const CarSale(carName: 'Honda', model: 'NV200', totalScale: 18602), + const CarSale(carName: 'Honda', model: 'Duke', totalScale: 10157), + const CarSale(carName: 'Ford', model: 'F-Series', totalScale: 896764), + const CarSale(carName: 'Ford', model: 'Explorer', totalScale: 271134), + const CarSale(carName: 'Ford', model: 'Fusion', totalScale: 209623), + const CarSale(carName: 'Ford', model: 'Focus', totalScale: 158385), + const CarSale(carName: 'Ford', model: 'Edge', totalScale: 142603), + const CarSale(carName: 'Ford', model: 'Transit', totalScale: 127340), + const CarSale(carName: 'Ford', model: 'Mustang', totalScale: 81866), + const CarSale(carName: 'Ford', model: 'Escape', totalScale: 308286), + const CarSale(carName: 'Ford', model: 'E-Series', totalScale: 53304), + const CarSale(carName: 'Ford', model: 'Expedition', totalScale: 51833), + const CarSale(carName: 'Ford', model: 'Fiesta', totalScale: 46249), + const CarSale(carName: 'Ford', model: 'Taurus', totalScale: 41326), + const CarSale(carName: 'Ford', model: 'Flex', totalScale: 22389), + const CarSale(carName: 'Ford', model: 'Transit Connect', totalScale: 34473), + ]; + + _colors = { + 'Hyundai': const Color.fromRGBO(220, 103, 171, 1.0), + 'BMW': const Color.fromRGBO(160, 220, 103, 1.0), + 'Benz': const Color.fromRGBO(220, 210, 103, 1.0), + 'Nissan': const Color.fromRGBO(163, 103, 220, 1.0), + 'Jeep': const Color.fromRGBO(220, 105, 103, 1.0), + 'Ford': const Color.fromRGBO(103, 183, 220, 1.0), + 'Honda': const Color.fromRGBO(103, 220, 187, 1.0), + }; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Container( + height: 400, + width: 400, + child: SfTreemap( + dataCount: _source.length, + weightValueMapper: (int index) { + return _source[index].totalScale!; + }, + enableDrilldown: true, + breadcrumbs: TreemapBreadcrumbs( + builder: (BuildContext context, TreemapTile tile, bool isCurrent) { + return Text(tile.group, style: const TextStyle(color: Colors.black)); + }, + ), + levels: [ + TreemapLevel( + groupMapper: (int index) => _source[index].carName, + labelBuilder: (BuildContext context, TreemapTile tile) { + return Padding( + padding: const EdgeInsets.only(left: 5.0, top: 5.0), + child: Text( + tile.group, + style: const TextStyle(color: Colors.black), + overflow: TextOverflow.ellipsis, + ), + ); + }, + colorValueMapper: (TreemapTile tile) { + return _colors[_source[tile.indices[0]].carName]; + }, + ), + TreemapLevel( + groupMapper: (int index) { + return _source[index].model; + }, + colorValueMapper: (TreemapTile tile) { + return _colors[_source[tile.indices[0]].carName]; + }, + labelBuilder: (BuildContext context, TreemapTile tile) { + return Padding( + padding: const EdgeInsets.only(left: 5.0, top: 5.0), + child: Text( + tile.group, + style: const TextStyle(color: Colors.black), + overflow: TextOverflow.ellipsis, + ), + ); + }, + ), + ], + ), + ), + ), + ); + } +} + +class CarSale { + const CarSale({ + required this.carName, + this.model, + this.version, + this.versionNumber, + this.totalScale, + }); + + final String carName; + final String? model; + final String? version; + final String? versionNumber; + final double? totalScale; +} + +{% endhighlight %} +{% endtabs %} + +![Treemap drilldown](images/drilldown/drilldown.gif) + +## Breadcrumb customization + +The breadcrumb is used to display information about the drilled item and provides an option to navigate back to the previous level. You can customize the breadcrumb items using the following properties: + +* **Position** - Positions the breadcrumbs either at the top or bottom of the Flutter Treemap. The default value of the [`position`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapBreadcrumbs/position.html) is [`TreemapBreadcrumbPosition.top`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapBreadcrumbPosition.html#top). +* **Divider** - Used to add a separator between two breadcrumbs. + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +class TreemapBreadcrumbCustomizationExample extends StatefulWidget { + const TreemapBreadcrumbCustomizationExample({super.key}); + + @override + State createState() => + _TreemapBreadcrumbCustomizationExampleState(); +} + +class _TreemapBreadcrumbCustomizationExampleState + extends State { + late List _source; + late Map _colors; + + @override + void initState() { + _source = [ + const CarSale(carName: 'Hyundai', model: 'Elantra', totalScale: 198210), + const CarSale(carName: 'Hyundai', model: 'Sonata', totalScale: 131803), + const CarSale(carName: 'Hyundai', model: 'Tucson', totalScale: 114735), + const CarSale(carName: 'Hyundai', model: 'Santa Fe', totalScale: 133171), + const CarSale(carName: 'Hyundai', model: 'Accent', totalScale: 58955), + const CarSale(carName: 'Hyundai', model: 'Veloster', totalScale: 12658), + const CarSale(carName: 'Hyundai', model: 'loniq', totalScale: 11197), + const CarSale(carName: 'Hyundai', model: 'Azera', totalScale: 3060), + const CarSale(carName: 'Benz', model: 'C-Class', totalScale: 77447), + const CarSale(carName: 'Benz', model: 'GLE-Class', totalScale: 54595), + const CarSale(carName: 'Benz', model: 'E/CLS-Class', totalScale: 51312), + const CarSale(carName: 'Benz', model: 'GLC-Class', totalScale: 48643), + const CarSale(carName: 'Benz', model: 'GLS-Class', totalScale: 322548), + const CarSale(carName: 'Benz', model: 'Sprinter', totalScale: 27415), + const CarSale(carName: 'Benz', model: 'CLA-Class', totalScale: 20669), + const CarSale(carName: 'Benz', model: 'GLA-Class', totalScale: 24104), + const CarSale(carName: 'Benz', model: 'S-Class', totalScale: 15888), + const CarSale(carName: 'Benz', model: 'Metris', totalScale: 7579), + const CarSale(carName: 'BMW', model: '3-Series', totalScale: 59449), + const CarSale(carName: 'BMW', model: 'X5', totalScale: 50815), + const CarSale(carName: 'BMW', model: 'X3', totalScale: 40691), + const CarSale(carName: 'BMW', model: '5-Series', totalScale: 40658), + const CarSale(carName: 'BMW', model: '4-Series', totalScale: 39634), + const CarSale(carName: 'BMW', model: '2-Series', totalScale: 11737), + const CarSale(carName: 'BMW', model: '7-Series', totalScale: 9276), + const CarSale(carName: 'BMW', model: 'X1', totalScale: 30826), + const CarSale(carName: 'BMW', model: 'X6', totalScale: 6780), + const CarSale(carName: 'BMW', model: 'X4', totalScale: 5198), + const CarSale(carName: 'BMW', model: '6-Series', totalScale: 3355), + const CarSale(carName: 'Jeep', model: 'Grand Cherokee', totalScale: 240696), + const CarSale(carName: 'Jeep', model: 'Cherokee', totalScale: 169822), + const CarSale(carName: 'Jeep', model: 'Renegade', totalScale: 103434), + const CarSale(carName: 'Jeep', model: 'Wrangler', totalScale: 190522), + const CarSale(carName: 'Jeep', model: 'Compass', totalScale: 83523), + const CarSale(carName: 'Jeep', model: 'Patriot', totalScale: 10735), + const CarSale(carName: 'Nissan', model: 'Rogue', totalScale: 403465), + const CarSale(carName: 'Nissan', model: 'Sentra', totalScale: 218451), + const CarSale(carName: 'Nissan', model: 'Murano', totalScale: 76732), + const CarSale(carName: 'Nissan', model: 'Frontier', totalScale: 74360), + const CarSale(carName: 'Nissan', model: 'Altima', totalScale: 254996), + const CarSale(carName: 'Nissan', model: 'Versa', totalScale: 106772), + const CarSale(carName: 'Nissan', model: 'Pathfinder', totalScale: 81065), + const CarSale(carName: 'Nissan', model: 'Maxima', totalScale: 67627), + const CarSale(carName: 'Nissan', model: 'Titan', totalScale: 52924), + const CarSale(carName: 'Nissan', model: 'Armada', totalScale: 35667), + const CarSale(carName: 'Nissan', model: 'NV', totalScale: 17858), + const CarSale(carName: 'Nissan', model: 'NV200', totalScale: 18602), + const CarSale(carName: 'Nissan', model: 'Duke', totalScale: 10157), + const CarSale(carName: 'Honda', model: 'Rogue', totalScale: 403465), + const CarSale(carName: 'Honda', model: 'Sentra', totalScale: 218451), + const CarSale(carName: 'Honda', model: 'Murano', totalScale: 76732), + const CarSale(carName: 'Honda', model: 'Frontier', totalScale: 74360), + const CarSale(carName: 'Honda', model: 'Altima', totalScale: 254996), + const CarSale(carName: 'Honda', model: 'Versa', totalScale: 106772), + const CarSale(carName: 'Honda', model: 'Maxima', totalScale: 67627), + const CarSale(carName: 'Honda', model: 'Titan', totalScale: 52924), + const CarSale(carName: 'Honda', model: 'Armada', totalScale: 35667), + const CarSale(carName: 'Honda', model: 'NV', totalScale: 17858), + const CarSale(carName: 'Honda', model: 'NV200', totalScale: 18602), + const CarSale(carName: 'Honda', model: 'Duke', totalScale: 10157), + const CarSale(carName: 'Ford', model: 'F-Series', totalScale: 896764), + const CarSale(carName: 'Ford', model: 'Explorer', totalScale: 271134), + const CarSale(carName: 'Ford', model: 'Fusion', totalScale: 209623), + const CarSale(carName: 'Ford', model: 'Focus', totalScale: 158385), + const CarSale(carName: 'Ford', model: 'Edge', totalScale: 142603), + const CarSale(carName: 'Ford', model: 'Transit', totalScale: 127340), + const CarSale(carName: 'Ford', model: 'Mustang', totalScale: 81866), + const CarSale(carName: 'Ford', model: 'Escape', totalScale: 308286), + const CarSale(carName: 'Ford', model: 'E-Series', totalScale: 53304), + const CarSale(carName: 'Ford', model: 'Expedition', totalScale: 51833), + const CarSale(carName: 'Ford', model: 'Fiesta', totalScale: 46249), + const CarSale(carName: 'Ford', model: 'Taurus', totalScale: 41326), + const CarSale(carName: 'Ford', model: 'Flex', totalScale: 22389), + const CarSale(carName: 'Ford', model: 'Transit Connect', totalScale: 34473), + ]; + + _colors = { + 'Hyundai': const Color.fromRGBO(220, 103, 171, 1.0), + 'BMW': const Color.fromRGBO(160, 220, 103, 1.0), + 'Benz': const Color.fromRGBO(220, 210, 103, 1.0), + 'Nissan': const Color.fromRGBO(163, 103, 220, 1.0), + 'Jeep': const Color.fromRGBO(220, 105, 103, 1.0), + 'Ford': const Color.fromRGBO(103, 183, 220, 1.0), + 'Honda': const Color.fromRGBO(103, 220, 187, 1.0), + }; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Container( + height: 400, + width: 400, + child: SfTreemap( + dataCount: _source.length, + weightValueMapper: (int index) { + return _source[index].totalScale!; + }, + enableDrilldown: true, + breadcrumbs: TreemapBreadcrumbs( + builder: (BuildContext context, TreemapTile tile, bool isCurrent) { + if (tile.group == 'Home') { + return const Icon(Icons.home, color: Colors.black); + } + + return Text( + tile.group, + style: const TextStyle(color: Colors.black), + ); + }, + divider: const Icon(Icons.chevron_right, color: Colors.black), + position: TreemapBreadcrumbPosition.top, + ), + levels: [ + TreemapLevel( + groupMapper: (int index) => _source[index].carName, + labelBuilder: (BuildContext context, TreemapTile tile) { + return Padding( + padding: const EdgeInsets.only(left: 5.0, top: 5.0), + child: Text( + tile.group, + style: const TextStyle(color: Colors.black), + overflow: TextOverflow.ellipsis, + ), + ); + }, + colorValueMapper: (TreemapTile tile) { + return _colors[_source[tile.indices[0]].carName]; + }, + ), + TreemapLevel( + groupMapper: (int index) { + return _source[index].model; + }, + colorValueMapper: (TreemapTile tile) { + return _colors[_source[tile.indices[0]].carName]; + }, + labelBuilder: (BuildContext context, TreemapTile tile) { + return Padding( + padding: const EdgeInsets.only(left: 5.0, top: 5.0), + child: Text( + tile.group, + style: const TextStyle(color: Colors.black), + overflow: TextOverflow.ellipsis, + ), + ); + }, + ), + ], + ), + ), + ), + ); + } +} + +class CarSale { + const CarSale({ + required this.carName, + this.model, + this.version, + this.versionNumber, + this.totalScale, + }); + + final String carName; + final String? model; + final String? version; + final String? versionNumber; + final double? totalScale; +} + +{% endhighlight %} +{% endtabs %} + ![Treemap drilldown](images/drilldown/breadcrumb_customization.gif) \ No newline at end of file diff --git a/Flutter/treemap/getting-started.md b/Flutter/treemap/getting-started.md index ad343587b..1fb511eeb 100644 --- a/Flutter/treemap/getting-started.md +++ b/Flutter/treemap/getting-started.md @@ -1,511 +1,511 @@ ---- -layout: post -title: Getting Started with Flutter Treemap | Syncfusion® -description: Learn how to get started with the Syncfusion® Flutter Treemap (SfTreemap). Explore setup, hierarchical data visualization, and customization options. -platform: flutter -control: SfTreemap -documentation: ug ---- - -# Getting Started with Flutter Treemap (SfTreemap) - -This section explains the steps required to add the treemap widget and enable its features such as labels, tooltip, assigning colors based on region, and legends. This section covers only the basic features needed to get started with Syncfusion® treemap. - -To get started quickly with our Flutter Treemap widget, you can refer to this video. - - - - -## Add Flutter treemap to an application - -Create a simple project using the instructions given in the [Getting Started with your first Flutter app](https://docs.flutter.dev/get-started/test-drive#choose-your-ide) documentation. - -**Add dependency** - -Add the Syncfusion® Flutter Treemap dependency to your pubspec.yaml file. - -{% tabs %} -{% highlight dart %} - -dependencies: - syncfusion_flutter_treemap: ^xx.x.xx -{% endhighlight %} -{% endtabs %} - -N> Here **xx.x.xx** denotes the current version of [`Syncfusion Flutter Treemap`](https://pub.dev/packages/syncfusion_flutter_treemap/versions) package. It is recommended to use the latest available version from pub.dev. - -**Get packages** - -Run the following command to get the required packages. - -{% tabs %} -{% highlight dart %} - -$ flutter pub get - -{% endhighlight %} -{% endtabs %} - -**Import package** - -Import the following package in your Dart code. - -{% tabs %} -{% highlight dart %} - -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -{% endhighlight %} -{% endtabs %} - -## Initialize treemap and populate data source - -After importing the package, initialize the treemap widget as a child of any widget. - -To populate the data source, set its count to the [`dataCount`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/dataCount.html) property of the treemap. The data will be grouped based on the values returned from the [`TreemapLevel.groupMapper`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/groupMapper.html) callback. You can have more than one TreemapLevel in the [`levels`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/levels.html) collection to form a hierarchical treemap. The quantitative value of the underlying data has to be returned from the [`weightValueMapper`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/weightValueMapper.html) callback. Based on this value, every tile (rectangle) will have its size. - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -class TreemapExample extends StatefulWidget { - const TreemapExample({super.key}); - - @override - State createState() => _TreemapExampleState(); -} - -class _TreemapExampleState extends State { - late List _source; - - @override - void initState() { - _source = [ - const SocialMediaUsers( - country: 'India', - socialMedia: 'Facebook', - usersInMillions: 25.4, - ), - const SocialMediaUsers( - country: 'USA', - socialMedia: 'Instagram', - usersInMillions: 19.11, - ), - const SocialMediaUsers( - country: 'Japan', - socialMedia: 'Facebook', - usersInMillions: 13.3, - ), - const SocialMediaUsers( - country: 'Germany', - socialMedia: 'Instagram', - usersInMillions: 10.65, - ), - const SocialMediaUsers( - country: 'France', - socialMedia: 'Twitter', - usersInMillions: 7.54, - ), - const SocialMediaUsers( - country: 'UK', - socialMedia: 'Instagram', - usersInMillions: 4.93, - ), - ]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: Container( - height: 400, - width: 400, - child: SfTreemap( - dataCount: _source.length, - weightValueMapper: (int index) { - return _source[index].usersInMillions; - }, - levels: [ - TreemapLevel( - groupMapper: (int index) { - return _source[index].country; - }, - ), - ], - ), - ), - ), - ); - } -} - -class SocialMediaUsers { - const SocialMediaUsers({ - required this.country, - required this.socialMedia, - required this.usersInMillions, - }); - - final String country; - final String socialMedia; - final double usersInMillions; -} - -{% endhighlight %} -{% endtabs %} - -![Treemap default view](images/getting-started/default-view.png) - -N> -* Refer the [`SfTreemap.levels`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/levels.html), for adding flat or hierarchical structured treemap. -* Refer the [`SfTreemap.colorMappers`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/colorMappers.html), for customizing the tiles color. - -## Add labels - -You can add any type of custom widgets to the tiles as labels based on the index using the [`TreemapLevel.labelBuilder`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/labelBuilder.html) property. The following example extends the initial sample by adding a label builder. - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -class TreemapExample extends StatefulWidget { - const TreemapExample({super.key}); - - @override - State createState() => _TreemapExampleState(); -} - -class _TreemapExampleState extends State { - late List _source; - - @override - void initState() { - _source = [ - const SocialMediaUsers( - country: 'India', - socialMedia: 'Facebook', - usersInMillions: 25.4, - ), - const SocialMediaUsers( - country: 'USA', - socialMedia: 'Instagram', - usersInMillions: 19.11, - ), - const SocialMediaUsers( - country: 'Japan', - socialMedia: 'Facebook', - usersInMillions: 13.3, - ), - const SocialMediaUsers( - country: 'Germany', - socialMedia: 'Instagram', - usersInMillions: 10.65, - ), - const SocialMediaUsers( - country: 'France', - socialMedia: 'Twitter', - usersInMillions: 7.54, - ), - const SocialMediaUsers( - country: 'UK', - socialMedia: 'Instagram', - usersInMillions: 4.93, - ), - ]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: Container( - height: 400, - width: 400, - child: SfTreemap( - dataCount: _source.length, - weightValueMapper: (int index) { - return _source[index].usersInMillions; - }, - levels: [ - TreemapLevel( - groupMapper: (int index) { - return _source[index].country; - }, - labelBuilder: (BuildContext context, TreemapTile tile) { - return Padding( - padding: const EdgeInsets.only(left: 2.5, right: 2.4, top: 1), - child: Text( - tile.group, - style: const TextStyle(color: Colors.black), - ), - ); - }, - ), - ], - ), - ), - ), - ); - } -} - -class SocialMediaUsers { - const SocialMediaUsers({ - required this.country, - required this.socialMedia, - required this.usersInMillions, - }); - - final String country; - final String socialMedia; - final double usersInMillions; -} - -{% endhighlight %} -{% endtabs %} - -![Treemap labels](images/getting-started/labels.png) - -## Add tooltip - -You can enable tooltip for any tile in the treemap and return a fully customized widget using the [`tooltipBuilder`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/tooltipBuilder.html) property. The following example extends the initial sample by adding a tooltip builder. - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -class TreemapExample extends StatefulWidget { - const TreemapExample({super.key}); - - @override - State createState() => _TreemapExampleState(); -} - -class _TreemapExampleState extends State { - late List _source; - - @override - void initState() { - _source = [ - const SocialMediaUsers( - country: 'India', - socialMedia: 'Facebook', - usersInMillions: 25.4, - ), - const SocialMediaUsers( - country: 'USA', - socialMedia: 'Instagram', - usersInMillions: 19.11, - ), - const SocialMediaUsers( - country: 'Japan', - socialMedia: 'Facebook', - usersInMillions: 13.3, - ), - const SocialMediaUsers( - country: 'Germany', - socialMedia: 'Instagram', - usersInMillions: 10.65, - ), - const SocialMediaUsers( - country: 'France', - socialMedia: 'Twitter', - usersInMillions: 7.54, - ), - const SocialMediaUsers( - country: 'UK', - socialMedia: 'Instagram', - usersInMillions: 4.93, - ), - ]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: Container( - height: 400, - width: 400, - child: SfTreemap( - dataCount: _source.length, - weightValueMapper: (int index) { - return _source[index].usersInMillions; - }, - levels: [ - TreemapLevel( - groupMapper: (int index) { - return _source[index].country; - }, - labelBuilder: (BuildContext context, TreemapTile tile) { - return Padding( - padding: const EdgeInsets.only(left: 2.5, right: 2.4, top: 1), - child: Text( - tile.group, - style: const TextStyle(color: Colors.black), - ), - ); - }, - tooltipBuilder: (BuildContext context, TreemapTile tile) { - return Padding( - padding: const EdgeInsets.only(left: 5, right: 5, top: 2, bottom: 3), - child: Text( - 'Country : ${tile.group}\nSocial media : ${tile.weight}M', - style: const TextStyle(color: Colors.black), - ), - ); - }, - ), - ], - ), - ), - ), - ); - } -} - -class SocialMediaUsers { - const SocialMediaUsers({ - required this.country, - required this.socialMedia, - required this.usersInMillions, - }); - - final String country; - final String socialMedia; - final double usersInMillions; -} - -{% endhighlight %} -{% endtabs %} - -![Treemap tooltip](images/getting-started/tooltip.png) - -## Add legend - -You can show legend by initializing the [`legend`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/legend.html) property in the [`SfTreemap`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap-class.html). It is possible to customize the legend item's color and text using the [`SfTreemap.colorMappers`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/colorMappers.html) property. The following example extends the initial sample by adding legend support. - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -class TreemapExample extends StatefulWidget { - const TreemapExample({super.key}); - - @override - State createState() => _TreemapExampleState(); -} - -class _TreemapExampleState extends State { - late List _source; - - @override - void initState() { - _source = [ - const SocialMediaUsers( - country: 'India', - socialMedia: 'Facebook', - usersInMillions: 25.4, - ), - const SocialMediaUsers( - country: 'USA', - socialMedia: 'Instagram', - usersInMillions: 19.11, - ), - const SocialMediaUsers( - country: 'Japan', - socialMedia: 'Facebook', - usersInMillions: 13.3, - ), - const SocialMediaUsers( - country: 'Germany', - socialMedia: 'Instagram', - usersInMillions: 10.65, - ), - const SocialMediaUsers( - country: 'France', - socialMedia: 'Twitter', - usersInMillions: 7.54, - ), - const SocialMediaUsers( - country: 'UK', - socialMedia: 'Instagram', - usersInMillions: 4.93, - ), - ]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: Container( - height: 400, - width: 400, - child: SfTreemap( - dataCount: _source.length, - weightValueMapper: (int index) { - return _source[index].usersInMillions; - }, - levels: [ - TreemapLevel( - groupMapper: (int index) { - return _source[index].country; - }, - labelBuilder: (BuildContext context, TreemapTile tile) { - return Padding( - padding: const EdgeInsets.only(left: 2.5, right: 2.4, top: 1), - child: Text( - tile.group, - style: const TextStyle(color: Colors.black), - ), - ); - }, - tooltipBuilder: (BuildContext context, TreemapTile tile) { - return Padding( - padding: const EdgeInsets.only(left: 5, right: 5, top: 2, bottom: 3), - child: Text( - 'Country : ${tile.group}\nSocial media : ${tile.weight}M', - style: const TextStyle(color: Colors.black), - ), - ); - }, - ), - ], - legend: TreemapLegend(), - ), - ), - ), - ); - } -} - -class SocialMediaUsers { - const SocialMediaUsers({ - required this.country, - required this.socialMedia, - required this.usersInMillions, - }); - - final String country; - final String socialMedia; - final double usersInMillions; -} - -{% endhighlight %} -{% endtabs %} - +--- +layout: post +title: Getting Started with Flutter Treemap | Syncfusion® +description: Learn how to get started with the Syncfusion® Flutter Treemap (SfTreemap). Explore setup, hierarchical data visualization, and customization options. +platform: flutter +control: SfTreemap +documentation: ug +--- + +# Getting Started with Flutter Treemap (SfTreemap) + +This section explains the steps required to add the Flutter Treemap widget and enable its features such as labels, tooltip, assigning colors based on region, and legends. This section covers only the basic features needed to get started with Syncfusion® Flutter Treemap. + +To get started quickly with our Flutter Treemap widget, you can refer to this video. + + + + +## Add Flutter Treemap to an application + +Create a simple project using the instructions given in the [Getting Started with your first Flutter app](https://docs.flutter.dev/get-started/test-drive#choose-your-ide) documentation. + +**Add dependency** + +Add the Syncfusion® Flutter Treemap dependency to your pubspec.yaml file. + +{% tabs %} +{% highlight dart %} + +dependencies: + syncfusion_flutter_treemap: ^xx.x.xx +{% endhighlight %} +{% endtabs %} + +N> Here **xx.x.xx** denotes the current version of [`Syncfusion Flutter Treemap`](https://pub.dev/packages/syncfusion_flutter_treemap/versions) package. It is recommended to use the latest available version from pub.dev. + +**Get packages** + +Run the following command to get the required packages. + +{% tabs %} +{% highlight dart %} + +$ flutter pub get + +{% endhighlight %} +{% endtabs %} + +**Import package** + +Import the following package in your Dart code. + +{% tabs %} +{% highlight dart %} + +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +{% endhighlight %} +{% endtabs %} + +## Initialize treemap and populate data source + +After importing the package, initialize the Flutter Treemap widget as a child of any widget. + +To populate the data source, set its count to the [`dataCount`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/dataCount.html) property of the Flutter Treemap. The data will be grouped based on the values returned from the [`TreemapLevel.groupMapper`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/groupMapper.html) callback. You can have more than one TreemapLevel in the [`levels`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/levels.html) collection to form a hierarchical treemap. The quantitative value of the underlying data has to be returned from the [`weightValueMapper`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/weightValueMapper.html) callback. Based on this value, every tile (rectangle) will have its size. + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +class TreemapExample extends StatefulWidget { + const TreemapExample({super.key}); + + @override + State createState() => _TreemapExampleState(); +} + +class _TreemapExampleState extends State { + late List _source; + + @override + void initState() { + _source = [ + const SocialMediaUsers( + country: 'India', + socialMedia: 'Facebook', + usersInMillions: 25.4, + ), + const SocialMediaUsers( + country: 'USA', + socialMedia: 'Instagram', + usersInMillions: 19.11, + ), + const SocialMediaUsers( + country: 'Japan', + socialMedia: 'Facebook', + usersInMillions: 13.3, + ), + const SocialMediaUsers( + country: 'Germany', + socialMedia: 'Instagram', + usersInMillions: 10.65, + ), + const SocialMediaUsers( + country: 'France', + socialMedia: 'Twitter', + usersInMillions: 7.54, + ), + const SocialMediaUsers( + country: 'UK', + socialMedia: 'Instagram', + usersInMillions: 4.93, + ), + ]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Container( + height: 400, + width: 400, + child: SfTreemap( + dataCount: _source.length, + weightValueMapper: (int index) { + return _source[index].usersInMillions; + }, + levels: [ + TreemapLevel( + groupMapper: (int index) { + return _source[index].country; + }, + ), + ], + ), + ), + ), + ); + } +} + +class SocialMediaUsers { + const SocialMediaUsers({ + required this.country, + required this.socialMedia, + required this.usersInMillions, + }); + + final String country; + final String socialMedia; + final double usersInMillions; +} + +{% endhighlight %} +{% endtabs %} + +![Treemap default view](images/getting-started/default-view.png) + +N> +* Refer the [`SfTreemap.levels`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/levels.html), for adding flat or hierarchical structured treemap. +* Refer the [`SfTreemap.colorMappers`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/colorMappers.html), for customizing the tiles color. + +## Add labels + +You can add any type of custom widgets to the tiles as labels based on the index using the [`TreemapLevel.labelBuilder`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/labelBuilder.html) property. The following example extends the initial sample by adding a label builder. + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +class TreemapExample extends StatefulWidget { + const TreemapExample({super.key}); + + @override + State createState() => _TreemapExampleState(); +} + +class _TreemapExampleState extends State { + late List _source; + + @override + void initState() { + _source = [ + const SocialMediaUsers( + country: 'India', + socialMedia: 'Facebook', + usersInMillions: 25.4, + ), + const SocialMediaUsers( + country: 'USA', + socialMedia: 'Instagram', + usersInMillions: 19.11, + ), + const SocialMediaUsers( + country: 'Japan', + socialMedia: 'Facebook', + usersInMillions: 13.3, + ), + const SocialMediaUsers( + country: 'Germany', + socialMedia: 'Instagram', + usersInMillions: 10.65, + ), + const SocialMediaUsers( + country: 'France', + socialMedia: 'Twitter', + usersInMillions: 7.54, + ), + const SocialMediaUsers( + country: 'UK', + socialMedia: 'Instagram', + usersInMillions: 4.93, + ), + ]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Container( + height: 400, + width: 400, + child: SfTreemap( + dataCount: _source.length, + weightValueMapper: (int index) { + return _source[index].usersInMillions; + }, + levels: [ + TreemapLevel( + groupMapper: (int index) { + return _source[index].country; + }, + labelBuilder: (BuildContext context, TreemapTile tile) { + return Padding( + padding: const EdgeInsets.only(left: 2.5, right: 2.4, top: 1), + child: Text( + tile.group, + style: const TextStyle(color: Colors.black), + ), + ); + }, + ), + ], + ), + ), + ), + ); + } +} + +class SocialMediaUsers { + const SocialMediaUsers({ + required this.country, + required this.socialMedia, + required this.usersInMillions, + }); + + final String country; + final String socialMedia; + final double usersInMillions; +} + +{% endhighlight %} +{% endtabs %} + +![Treemap labels](images/getting-started/labels.png) + +## Add tooltip + +You can enable tooltip for any tile in the Flutter Treemap and return a fully customized widget using the [`tooltipBuilder`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/tooltipBuilder.html) property. The following example extends the initial sample by adding a tooltip builder. + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +class TreemapExample extends StatefulWidget { + const TreemapExample({super.key}); + + @override + State createState() => _TreemapExampleState(); +} + +class _TreemapExampleState extends State { + late List _source; + + @override + void initState() { + _source = [ + const SocialMediaUsers( + country: 'India', + socialMedia: 'Facebook', + usersInMillions: 25.4, + ), + const SocialMediaUsers( + country: 'USA', + socialMedia: 'Instagram', + usersInMillions: 19.11, + ), + const SocialMediaUsers( + country: 'Japan', + socialMedia: 'Facebook', + usersInMillions: 13.3, + ), + const SocialMediaUsers( + country: 'Germany', + socialMedia: 'Instagram', + usersInMillions: 10.65, + ), + const SocialMediaUsers( + country: 'France', + socialMedia: 'Twitter', + usersInMillions: 7.54, + ), + const SocialMediaUsers( + country: 'UK', + socialMedia: 'Instagram', + usersInMillions: 4.93, + ), + ]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Container( + height: 400, + width: 400, + child: SfTreemap( + dataCount: _source.length, + weightValueMapper: (int index) { + return _source[index].usersInMillions; + }, + levels: [ + TreemapLevel( + groupMapper: (int index) { + return _source[index].country; + }, + labelBuilder: (BuildContext context, TreemapTile tile) { + return Padding( + padding: const EdgeInsets.only(left: 2.5, right: 2.4, top: 1), + child: Text( + tile.group, + style: const TextStyle(color: Colors.black), + ), + ); + }, + tooltipBuilder: (BuildContext context, TreemapTile tile) { + return Padding( + padding: const EdgeInsets.only(left: 5, right: 5, top: 2, bottom: 3), + child: Text( + 'Country : ${tile.group}\nSocial media : ${tile.weight}M', + style: const TextStyle(color: Colors.black), + ), + ); + }, + ), + ], + ), + ), + ), + ); + } +} + +class SocialMediaUsers { + const SocialMediaUsers({ + required this.country, + required this.socialMedia, + required this.usersInMillions, + }); + + final String country; + final String socialMedia; + final double usersInMillions; +} + +{% endhighlight %} +{% endtabs %} + +![Treemap tooltip](images/getting-started/tooltip.png) + +## Add legend + +You can show legend by initializing the [`legend`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/legend.html) property in the [`SfTreemap`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap-class.html). It is possible to customize the legend item's color and text using the [`SfTreemap.colorMappers`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/colorMappers.html) property. The following example extends the initial sample by adding legend support. + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +class TreemapExample extends StatefulWidget { + const TreemapExample({super.key}); + + @override + State createState() => _TreemapExampleState(); +} + +class _TreemapExampleState extends State { + late List _source; + + @override + void initState() { + _source = [ + const SocialMediaUsers( + country: 'India', + socialMedia: 'Facebook', + usersInMillions: 25.4, + ), + const SocialMediaUsers( + country: 'USA', + socialMedia: 'Instagram', + usersInMillions: 19.11, + ), + const SocialMediaUsers( + country: 'Japan', + socialMedia: 'Facebook', + usersInMillions: 13.3, + ), + const SocialMediaUsers( + country: 'Germany', + socialMedia: 'Instagram', + usersInMillions: 10.65, + ), + const SocialMediaUsers( + country: 'France', + socialMedia: 'Twitter', + usersInMillions: 7.54, + ), + const SocialMediaUsers( + country: 'UK', + socialMedia: 'Instagram', + usersInMillions: 4.93, + ), + ]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Container( + height: 400, + width: 400, + child: SfTreemap( + dataCount: _source.length, + weightValueMapper: (int index) { + return _source[index].usersInMillions; + }, + levels: [ + TreemapLevel( + groupMapper: (int index) { + return _source[index].country; + }, + labelBuilder: (BuildContext context, TreemapTile tile) { + return Padding( + padding: const EdgeInsets.only(left: 2.5, right: 2.4, top: 1), + child: Text( + tile.group, + style: const TextStyle(color: Colors.black), + ), + ); + }, + tooltipBuilder: (BuildContext context, TreemapTile tile) { + return Padding( + padding: const EdgeInsets.only(left: 5, right: 5, top: 2, bottom: 3), + child: Text( + 'Country : ${tile.group}\nSocial media : ${tile.weight}M', + style: const TextStyle(color: Colors.black), + ), + ); + }, + ), + ], + legend: TreemapLegend(), + ), + ), + ), + ); + } +} + +class SocialMediaUsers { + const SocialMediaUsers({ + required this.country, + required this.socialMedia, + required this.usersInMillions, + }); + + final String country; + final String socialMedia; + final double usersInMillions; +} + +{% endhighlight %} +{% endtabs %} + ![Treemap legend](images/getting-started/legend.png) \ No newline at end of file diff --git a/Flutter/treemap/legend.md b/Flutter/treemap/legend.md index 1fa0649c6..ec1b2c2b3 100644 --- a/Flutter/treemap/legend.md +++ b/Flutter/treemap/legend.md @@ -1,1845 +1,1845 @@ ---- -layout: post -title: Legend in Flutter Treemap | Syncfusion® -description: Learn about legend support in Syncfusion® Flutter Treemap (SfTreemap), including legend customization, color mapping, positioning, and styling options. -platform: flutter -control: SfTreemap -documentation: ug ---- - -# Legend in Flutter Treemap (SfTreemap) - -The legend provides clarity about the data plotted on the treemap. - -## Enable default legend - -To display a legend, initialize the [`SfTreemap.legend`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/legend.html) property. By default, the legend item's text is rendered based on the value of [`TreemapLevel.groupMapper`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/groupMapper.html) property. The default value of the [`legend`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/legend.html) property is `null`. - -The examples in this section use the same data source and differ only in the legend constructor. - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -class DefaultLegendExample extends StatefulWidget { - const DefaultLegendExample({super.key}); - - @override - State createState() => _DefaultLegendExampleState(); -} - -class _DefaultLegendExampleState extends State { - late List _source; - - @override - void initState() { - _source = [ - SocialMediaUsers('India', 'Facebook', 25.4), - SocialMediaUsers('USA', 'Instagram', 19.11), - SocialMediaUsers('Japan', 'Facebook', 13.3), - SocialMediaUsers('Germany', 'Instagram', 10.65), - SocialMediaUsers('France', 'Twitter', 7.54), - SocialMediaUsers('UK', 'Instagram', 4.93), - ]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: SizedBox( - height: 400, - width: 400, - child: SfTreemap( - dataCount: _source.length, - weightValueMapper: (int index) { - return _source[index].usersInMillions; - }, - levels: [ - TreemapLevel( - groupMapper: (int index) { - return _source[index].country; - }, - ), - ], - legend: TreemapLegend(), - ), - ), - ), - ); - } -} - -class SocialMediaUsers { - const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); - - final String country; - final String socialMedia; - final double usersInMillions; -} - -{% endhighlight %} -{% endtabs %} - -![default legend](images/legend/default-legend.png) - -N> -* Refer the [`TreemapLegend.bar`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/TreemapLegend.bar.html), to display a bar-shaped legend. - -## Bar shape legend - -You can show bar shape legend by initializing the [`SfTreemap.legend`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/legend.html) property as [`TreemapLegend.bar`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/TreemapLegend.bar.html). By default, the legend item's text is rendered based on the value of [`TreemapLevel.groupMapper`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/groupMapper.html) property. - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -class BarLegendExample extends StatefulWidget { - const BarLegendExample({super.key}); - - @override - State createState() => _BarLegendExampleState(); -} - -class _BarLegendExampleState extends State { - late List _source; - - @override - void initState() { - _source = [ - SocialMediaUsers('India', 'Facebook', 25.4), - SocialMediaUsers('USA', 'Instagram', 19.11), - SocialMediaUsers('Japan', 'Facebook', 13.3), - SocialMediaUsers('Germany', 'Instagram', 10.65), - SocialMediaUsers('France', 'Twitter', 7.54), - SocialMediaUsers('UK', 'Instagram', 4.93), - ]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: SizedBox( - height: 400, - width: 400, - child: SfTreemap( - dataCount: _source.length, - weightValueMapper: (int index) { - return _source[index].usersInMillions; - }, - levels: [ - TreemapLevel( - groupMapper: (int index) { - return _source[index].country; - }, - ), - ], - legend: TreemapLegend.bar(), - ), - ), - ), - ); - } -} - -class SocialMediaUsers { - const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); - - final String country; - final String socialMedia; - final double usersInMillions; -} - -{% endhighlight %} -{% endtabs %} - -![bar legend](images/legend/bar-legend.png) - -N> -* Refer the [`TreemapLegend`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/TreemapLegend.html), for the default legend display options. - -## Icon and text customization - -Legend icons and text are customized based on the [`TreemapLevel.color`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/color.html) and [`TreemapLevel.groupMapper`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/groupMapper.html) properties by default. It is possible to customize the legend icon colors and texts using the [`TreemapColorMapper.color`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/color.html) based on the [`TreemapColorMapper.value`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/value.html) or [`TreemapColorMapper.from`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/from.html) and [`TreemapColorMapper.to`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/to.html) properties. You can also customize the legend item's text using the [`TreemapColorMapper.name`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/name.html) when setting the [`TreemapColorMapper.range`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/TreemapColorMapper.range.html) color mapper constructor. - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -class IconTextCustomizationExample extends StatefulWidget { - const IconTextCustomizationExample({super.key}); - - @override - State createState() => - _IconTextCustomizationExampleState(); -} - -class _IconTextCustomizationExampleState extends State { - late List _source; - late List _colorMappers; - - @override - void initState() { - _source = [ - SocialMediaUsers('India', 'Facebook', 25.4), - SocialMediaUsers('USA', 'Instagram', 19.11), - SocialMediaUsers('Japan', 'Facebook', 13.3), - SocialMediaUsers('Germany', 'Instagram', 10.65), - SocialMediaUsers('France', 'Twitter', 7.54), - SocialMediaUsers('UK', 'Instagram', 4.93), - ]; - - _colorMappers = [ - TreemapColorMapper.range(from: 0, to: 10, color: Colors.blue[200]!), - TreemapColorMapper.range(from: 10, to: 20, color: Colors.deepOrange), - TreemapColorMapper.range(from: 20, to: 30, color: Colors.blue[800]!), - ]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: SfTreemap( - dataCount: _source.length, - weightValueMapper: (int index) { - return _source[index].usersInMillions; - }, - levels: [ - TreemapLevel( - padding: const EdgeInsets.all(1.5), - groupMapper: (int index) { - return _source[index].country; - }, - colorValueMapper: (TreemapTile tile) { - return tile.weight; - }, - ), - ], - colorMappers: _colorMappers, - legend: TreemapLegend.bar(), - ), - ); - } -} - -class SocialMediaUsers { - const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); - - final String country; - final String socialMedia; - final double usersInMillions; -} - -{% endhighlight %} -{% endtabs %} - -![legend icon color](images/legend/icon-color.png) - -## First segment label customization - -You can customize the first segment label of the legend by using the [`TreemapColorMapper.name`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/name.html) property with curly braces. The value inside the first pair of curly braces will be used as the start label for the segment, and the value inside the second pair will be used as the end label. - -By default, the [`TreemapColorMapper.from`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/from.html) value appears at the start of the first segment, and the [`TreemapColorMapper.to`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/to.html) value appears at the end. - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -class FirstSegmentLabelExample extends StatefulWidget { - const FirstSegmentLabelExample({super.key}); - - @override - State createState() => - _FirstSegmentLabelExampleState(); -} - -class _FirstSegmentLabelExampleState extends State { - late List _source; - late List _colorMappers; - - @override - void initState() { - _source = [ - SocialMediaUsers('India', 'Facebook', 25.4), - SocialMediaUsers('USA', 'Instagram', 19.11), - SocialMediaUsers('Japan', 'Facebook', 13.3), - SocialMediaUsers('Germany', 'Instagram', 10.65), - SocialMediaUsers('France', 'Twitter', 7.54), - SocialMediaUsers('UK', 'Instagram', 4.93), - ]; - - _colorMappers = [ - TreemapColorMapper.range( - from: 0, to: 10, color: Colors.blue[200]!, name: '{0M},{10M}'), - TreemapColorMapper.range( - from: 10, to: 20, color: Colors.deepOrange, name: '20M'), - TreemapColorMapper.range( - from: 20, to: 30, color: Colors.blue[800]!, name: '30M'), - ]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: SfTreemap( - dataCount: _source.length, - weightValueMapper: (int index) { - return _source[index].usersInMillions; - }, - levels: [ - TreemapLevel( - padding: const EdgeInsets.all(1.5), - groupMapper: (int index) { - return _source[index].country; - }, - colorValueMapper: (TreemapTile tile) { - return tile.weight; - }, - ), - ], - colorMappers: _colorMappers, - legend: TreemapLegend.bar(), - ), - ); - } -} - -class SocialMediaUsers { - const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); - - final String country; - final String socialMedia; - final double usersInMillions; -} - -{% endhighlight %} -{% endtabs %} - -![First label customization](images/legend/first-label-customization.png) - -## Scrollbar visibility - -You can control the visibility of the scrollbar in the treemap legend using the [`shouldAlwaysShowScrollbar`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/shouldAlwaysShowScrollbar.html) property. When set to `true`, the scrollbar for the legend will always be visible, making it easier to see and navigate through legend items, even if all items fit within the available space. - -The default value is `false`, so the scrollbar appears in legend only when the legend items exceed the available space and scrolling is needed. - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -class ScrollbarVisibilityExample extends StatefulWidget { - const ScrollbarVisibilityExample({super.key}); - - @override - State createState() => - _ScrollbarVisibilityExampleState(); -} - -class _ScrollbarVisibilityExampleState extends State { - late List _source; - - @override - void initState() { - _source = [ - SocialMediaUsers('India', 'Facebook', 25.4), - SocialMediaUsers('USA', 'Instagram', 19.11), - SocialMediaUsers('Japan', 'Facebook', 13.3), - SocialMediaUsers('Germany', 'Instagram', 10.65), - SocialMediaUsers('France', 'Twitter', 7.54), - SocialMediaUsers('UK', 'Instagram', 4.93), - ]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: SizedBox( - height: 400, - width: 400, - child: SfTreemap( - dataCount: _source.length, - weightValueMapper: (int index) { - return _source[index].usersInMillions; - }, - levels: [ - TreemapLevel( - groupMapper: (int index) { - return _source[index].country; - }, - ), - ], - legend: TreemapLegend( - shouldAlwaysShowScrollbar: true, - overflowMode: TreemapLegendOverflowMode.scroll, - ), - ), - ), - ), - ); - } -} - -class SocialMediaUsers { - const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); - - final String country; - final String socialMedia; - final double usersInMillions; -} - -{% endhighlight %} -{% endtabs %} - -## Title - -You can set a title specifically for the legend in the treemap by using the [`title`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/title.html) property. This property lets you display a descriptive heading for the legend, helping users understand what the legend represents within the treemap. - -By default, the value of the legend's [`title`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/title.html) property is `null`, indicating that no title is displayed for the legend, unless it is specified explicitly. - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -class LegendTitleExample extends StatefulWidget { - const LegendTitleExample({super.key}); - - @override - State createState() => _LegendTitleExampleState(); -} - -class _LegendTitleExampleState extends State { - late List _source; - - @override - void initState() { - _source = [ - SocialMediaUsers('India', 'Facebook', 25.4), - SocialMediaUsers('USA', 'Instagram', 19.11), - SocialMediaUsers('Japan', 'Facebook', 13.3), - SocialMediaUsers('Germany', 'Instagram', 10.65), - SocialMediaUsers('France', 'Twitter', 7.54), - SocialMediaUsers('UK', 'Instagram', 4.93), - ]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: SizedBox( - height: 400, - width: 400, - child: SfTreemap( - dataCount: _source.length, - weightValueMapper: (int index) { - return _source[index].usersInMillions; - }, - levels: [ - TreemapLevel( - groupMapper: (int index) { - return _source[index].country; - }, - ), - ], - legend: TreemapLegend( - title: Text('Social media users'), - ), - ), - ), - ), - ); - } -} - -class SocialMediaUsers { - const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); - - final String country; - final String socialMedia; - final double usersInMillions; -} - -{% endhighlight %} -{% endtabs %} - -![legend title](images/legend/legend-title.png) - -## Position - -You can position the legend items in different directions using the [`TreemapLegend.position`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/position.html) property. The default value of the [position`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/position.html) property is [`TreemapLegendPosition.top`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegendPosition.html). The possible values are [`left`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegendPosition.html#left), [`right`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegendPosition.html#right), [`top`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegendPosition.html#top), and [`bottom`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegendPosition.html#bottom). - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -class LegendPositionExample extends StatefulWidget { - const LegendPositionExample({super.key}); - - @override - State createState() => _LegendPositionExampleState(); -} - -class _LegendPositionExampleState extends State { - late List _source; - - @override - void initState() { - _source = [ - SocialMediaUsers('India', 'Facebook', 25.4), - SocialMediaUsers('USA', 'Instagram', 19.11), - SocialMediaUsers('Japan', 'Facebook', 13.3), - SocialMediaUsers('Germany', 'Instagram', 10.65), - SocialMediaUsers('France', 'Twitter', 7.54), - SocialMediaUsers('UK', 'Instagram', 4.93), - ]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: SizedBox( - height: 400, - width: 400, - child: SfTreemap( - dataCount: _source.length, - weightValueMapper: (int index) { - return _source[index].usersInMillions; - }, - levels: [ - TreemapLevel( - groupMapper: (int index) { - return _source[index].country; - }, - ), - ], - legend: TreemapLegend( - position: TreemapLegendPosition.bottom, - ), - ), - ), - ), - ); - } -} - -class SocialMediaUsers { - const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); - - final String country; - final String socialMedia; - final double usersInMillions; -} - -{% endhighlight %} -{% endtabs %} - -![legend position](images/legend/legend-position.png) - -N> -* Refer the [`offset`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/offset.html), for placing the legend in custom position. - -## Offset - -You can place the legend in a custom position using the [`TreemapLegend.offset`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/offset.html) property. The default value of the [`offset`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/offset.html) property is `null`. - -If the property [`TreemapLegend.offset`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/offset.html) has been set with the property [`TreemapLegend.position`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/position.html) as top, then the legend will be placed at the top but with an absolute position, meaning it will not take a dedicated position and will be drawn at the top of the map. - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -class LegendOffsetExample extends StatefulWidget { - const LegendOffsetExample({super.key}); - - @override - State createState() => _LegendOffsetExampleState(); -} - -class _LegendOffsetExampleState extends State { - late List _source; - - @override - void initState() { - _source = [ - SocialMediaUsers('India', 'Facebook', 25.4), - SocialMediaUsers('USA', 'Instagram', 19.11), - SocialMediaUsers('Japan', 'Facebook', 13.3), - SocialMediaUsers('Germany', 'Instagram', 10.65), - SocialMediaUsers('France', 'Twitter', 7.54), - SocialMediaUsers('UK', 'Instagram', 4.93), - ]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: SizedBox( - height: 400, - width: 400, - child: SfTreemap( - dataCount: _source.length, - weightValueMapper: (int index) { - return _source[index].usersInMillions; - }, - levels: [ - TreemapLevel( - groupMapper: (int index) { - return _source[index].country; - }, - ), - ], - legend: TreemapLegend( - offset: const Offset(70, 250), - ), - ), - ), - ), - ); - } -} - -class SocialMediaUsers { - const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); - - final String country; - final String socialMedia; - final double usersInMillions; -} - -{% endhighlight %} -{% endtabs %} - -![legend offset](images/legend/legend-offset.png) - -## Overflow mode - -For default legend - -You can wrap or scroll the legend items using the [`TreemapLegend.overflowMode`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/overflowMode.html) property. The default value of the [`overflowMode`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/overflowMode.html) property is [`TreemapLegendOverflowMode.wrap`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegendOverflowMode.html). The possible values are [`scroll`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegendOverflowMode.html#scroll) and [`wrap`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegendOverflowMode.html#wrap). - -If the legend position is `left` or `right`, then the default scroll direction is `vertical`. - -If the legend position is `top` or `bottom`, then the default scroll direction is `horizontal`. - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -class OverflowModeExample extends StatefulWidget { - const OverflowModeExample({super.key}); - - @override - State createState() => _OverflowModeExampleState(); -} - -class _OverflowModeExampleState extends State { - late List _source; - - @override - void initState() { - _source = [ - SocialMediaUsers('India', 'Facebook', 25.4), - SocialMediaUsers('USA', 'Instagram', 19.11), - SocialMediaUsers('Japan', 'Facebook', 13.3), - SocialMediaUsers('China', 'Facebook', 12.3), - SocialMediaUsers('Germany', 'Instagram', 10.65), - SocialMediaUsers('France', 'Twitter', 7.54), - SocialMediaUsers('South America', 'Twitter', 5.54), - SocialMediaUsers('United Kingdom', 'Instagram', 4.93), - ]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: SizedBox( - height: 400, - width: 400, - child: SfTreemap( - dataCount: _source.length, - weightValueMapper: (int index) { - return _source[index].usersInMillions; - }, - levels: [ - TreemapLevel( - groupMapper: (int index) { - return _source[index].country; - }, - ), - ], - legend: TreemapLegend( - overflowMode: TreemapLegendOverflowMode.scroll, - ), - ), - ), - ), - ); - } -} - -class SocialMediaUsers { - const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); - - final String country; - final String socialMedia; - final double usersInMillions; -} - -{% endhighlight %} -{% endtabs %} - -![default legend overflow mode](images/legend/default-legend-overflow-mode.gif) - -For bar legend - -You can wrap or scroll the bar legend items using the [`TreemapLegend.overflowMode`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/overflowMode.html) property. The default value of the `overflowMode` property is [`TreemapLegendOverflowMode.scroll`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegendOverflowMode.html). The possible values are `scroll` and `wrap`. - -If the legend position is `left` or `right`, then the default scroll direction is `vertical`. - -If the legend position is `top` or `bottom`, then the default scroll direction is `horizontal`. - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -class BarOverflowModeExample extends StatefulWidget { - const BarOverflowModeExample({super.key}); - - @override - State createState() => _BarOverflowModeExampleState(); -} - -class _BarOverflowModeExampleState extends State { - late List _source; - - @override - void initState() { - _source = [ - SocialMediaUsers('India', 'Facebook', 25.4), - SocialMediaUsers('USA', 'Instagram', 19.11), - SocialMediaUsers('Japan', 'Facebook', 13.3), - SocialMediaUsers('Germany', 'Instagram', 10.65), - SocialMediaUsers('France', 'Twitter', 7.54), - SocialMediaUsers('UK', 'Instagram', 4.93), - ]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: SizedBox( - height: 400, - width: 400, - child: SfTreemap( - dataCount: _source.length, - weightValueMapper: (int index) { - return _source[index].usersInMillions; - }, - levels: [ - TreemapLevel( - groupMapper: (int index) { - return _source[index].country; - }, - ), - ], - legend: TreemapLegend.bar( - overflowMode: TreemapLegendOverflowMode.scroll, - ), - ), - ), - ), - ); - } -} - -class SocialMediaUsers { - const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); - - final String country; - final String socialMedia; - final double usersInMillions; -} - -{% endhighlight %} -{% endtabs %} - -![bar legend overflow mode](images/legend/bar-legend-overflow-mode.gif) - -N> -* Refer the [`iconSize`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/TreemapLegend.html), for changing the size of the icon. - -## Text style - -You can customize the legend item's text style using the [`TreemapLegend.textStyle`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/textStyle.html) property. - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -class TextStyleExample extends StatefulWidget { - const TextStyleExample({super.key}); - - @override - State createState() => _TextStyleExampleState(); -} - -class _TextStyleExampleState extends State { - late List _source; - - @override - void initState() { - _source = [ - SocialMediaUsers('India', 'Facebook', 25.4), - SocialMediaUsers('USA', 'Instagram', 19.11), - SocialMediaUsers('Japan', 'Facebook', 13.3), - SocialMediaUsers('Germany', 'Instagram', 10.65), - SocialMediaUsers('France', 'Twitter', 7.54), - SocialMediaUsers('UK', 'Instagram', 4.93), - ]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: SizedBox( - height: 400, - width: 400, - child: SfTreemap( - dataCount: _source.length, - weightValueMapper: (int index) { - return _source[index].usersInMillions; - }, - levels: [ - TreemapLevel( - groupMapper: (int index) { - return _source[index].country; - }, - ), - ], - legend: TreemapLegend( - textStyle: const TextStyle( - color: Colors.red, - fontSize: 14, - fontWeight: FontWeight.bold, - fontStyle: FontStyle.italic, - ), - ), - ), - ), - ), - ); - } -} - -class SocialMediaUsers { - const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); - - final String country; - final String socialMedia; - final double usersInMillions; -} - -{% endhighlight %} -{% endtabs %} - -![legend text style](images/legend/text-style.png) - -## Default legend appearance customization - -You can customize the legend items using the following properties. - -* **iconType** - Used to change the icon shape. The default value of the [`iconType`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/TreemapLegend.html) argument in the constructor is [`TreemapIconType.circle`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapIconType.html#circle). The possible values are [`circle`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapIconType.html#circle), [`rectangle`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapIconType.html#rectangle), [`triangle`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapIconType.html#triangle), and [`diamond`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapIconType.html#diamond). -* **iconSize** - Used to change the size of the icon. The default value of [`iconSize`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/TreemapLegend.html) argument in the constructor is `Size(8.0, 8.0)`. -* **spacing** - Used to provide space between the each legend items. The default value of the [`spacing`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/spacing.html) argument in the constructor is `10.0`. -* **direction** - Used to arrange the legend items in either horizontal or vertical direction. The default value of [`direction`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/direction.html) property is `horizontal`, if the value of the [`position`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/position.html) property is [`top`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegendPosition.html#top), [`bottom`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegendPosition.html#bottom) and defaults to `vertical`, if the value of the [`position`] property is [`left`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegendPosition.html#left) or [`right`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegendPosition.html#right). -* **padding** - Used to set padding around the legend. The default value of the [`padding`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/padding.html) property is `EdgeInsets.all(10.0)`. - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -class LegendAppearanceExample extends StatefulWidget { - const LegendAppearanceExample({super.key}); - - @override - State createState() => - _LegendAppearanceExampleState(); -} - -class _LegendAppearanceExampleState extends State { - late List _source; - - @override - void initState() { - _source = [ - SocialMediaUsers('India', 'Facebook', 25.4), - SocialMediaUsers('USA', 'Instagram', 19.11), - SocialMediaUsers('Japan', 'Facebook', 13.3), - SocialMediaUsers('Germany', 'Instagram', 10.65), - SocialMediaUsers('France', 'Twitter', 7.54), - SocialMediaUsers('UK', 'Instagram', 4.93), - ]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: SizedBox( - height: 400, - width: 400, - child: SfTreemap( - dataCount: _source.length, - weightValueMapper: (int index) { - return _source[index].usersInMillions; - }, - levels: [ - TreemapLevel( - groupMapper: (int index) { - return _source[index].country; - }, - ), - ], - legend: TreemapLegend( - iconType: TreemapIconType.triangle, - iconSize: const Size(12.0, 12.0), - spacing: 15, - padding: const EdgeInsets.all(12.0), - direction: Axis.vertical, - ), - ), - ), - ), - ); - } -} - -class SocialMediaUsers { - const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); - - final String country; - final String socialMedia; - final double usersInMillions; -} - -{% endhighlight %} -{% endtabs %} - -![Legend items customization](images/legend/legend-items-customization.png) - -N> -* Refer the `position`, for setting the position of the legend. - -## Bar legend segment painting style - -### Solid - -You can set solid color for the legend bar by using the [`TreemapLegendPaintingStyle.solid`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegendPaintingStyle.html#solid). By defaults [`TreemapLegendPaintingStyle`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegendPaintingStyle.html) will be [`solid`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegendPaintingStyle.html#solid). - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -class SolidBarLegendExample extends StatefulWidget { - const SolidBarLegendExample({super.key}); - - @override - State createState() => _SolidBarLegendExampleState(); -} - -class _SolidBarLegendExampleState extends State { - late List _source; - late List _colorMappers; - - @override - void initState() { - _source = [ - SocialMediaUsers('India', 'Facebook', 25.4), - SocialMediaUsers('USA', 'Instagram', 19.11), - SocialMediaUsers('Japan', 'Facebook', 13.3), - SocialMediaUsers('Germany', 'Instagram', 10.65), - SocialMediaUsers('France', 'Twitter', 7.54), - SocialMediaUsers('UK', 'Instagram', 4.93), - ]; - - _colorMappers = [ - TreemapColorMapper.range(from: 0, to: 10, color: Colors.blue[200]!), - TreemapColorMapper.range(from: 10, to: 20, color: Colors.deepOrange), - TreemapColorMapper.range(from: 20, to: 30, color: Colors.blue[800]!), - ]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: SfTreemap( - dataCount: _source.length, - weightValueMapper: (int index) { - return _source[index].usersInMillions; - }, - levels: [ - TreemapLevel( - padding: const EdgeInsets.all(1.5), - groupMapper: (int index) { - return _source[index].country; - }, - colorValueMapper: (TreemapTile tile) { - return tile.weight; - }, - ), - ], - colorMappers: _colorMappers, - legend: TreemapLegend.bar( - segmentPaintingStyle: TreemapLegendPaintingStyle.solid, - ), - ), - ); - } -} - -class SocialMediaUsers { - const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); - - final String country; - final String socialMedia; - final double usersInMillions; -} - -{% endhighlight %} -{% endtabs %} - -![Bar legend solid type](images/legend/bar-legend-solid-type.png) - -### Gradient - -You can set gradient color for the legend bar by using the [`TreemapLegendPaintingStyle.gradient`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegendPaintingStyle.html#gradient). - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -class GradientBarLegendExample extends StatefulWidget { - const GradientBarLegendExample({super.key}); - - @override - State createState() => - _GradientBarLegendExampleState(); -} - -class _GradientBarLegendExampleState extends State { - late List _source; - late List _colorMappers; - - @override - void initState() { - _source = [ - SocialMediaUsers('India', 'Facebook', 25.4), - SocialMediaUsers('USA', 'Instagram', 19.11), - SocialMediaUsers('Japan', 'Facebook', 13.3), - SocialMediaUsers('Germany', 'Instagram', 10.65), - SocialMediaUsers('France', 'Twitter', 7.54), - SocialMediaUsers('UK', 'Instagram', 4.93), - ]; - - _colorMappers = [ - TreemapColorMapper.range(from: 0, to: 10, color: Colors.blue[200]!), - TreemapColorMapper.range(from: 10, to: 20, color: Colors.deepOrange), - TreemapColorMapper.range(from: 20, to: 30, color: Colors.blue[800]!), - ]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: SfTreemap( - dataCount: _source.length, - weightValueMapper: (int index) { - return _source[index].usersInMillions; - }, - levels: [ - TreemapLevel( - padding: const EdgeInsets.all(1.5), - groupMapper: (int index) { - return _source[index].country; - }, - colorValueMapper: (TreemapTile tile) { - return tile.weight; - }, - ), - ], - colorMappers: _colorMappers, - legend: TreemapLegend.bar( - segmentPaintingStyle: TreemapLegendPaintingStyle.gradient, - ), - ), - ); - } -} - -class SocialMediaUsers { - const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); - - final String country; - final String socialMedia; - final double usersInMillions; -} - -{% endhighlight %} -{% endtabs %} - -![Bar legend gradient type](images/legend/bar-legend-gradient-type.png) - -## Bar legend appearance customization - -You can customize the legend items using the following properties. - -* **segmentSize** - Used to change the size of individual legend bar segments. When gradient paint style is applied, [`segmentSize`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/TreemapLegend.bar.html) argument in the constructor will update the whole legend bar. The default value of the [`segmentSize`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/TreemapLegend.bar.html) property is `Size(80.0, 12.0)`. -* **labelOverflow** - Used to remove or trim the legend labels based on the bar legend size.The default value of the [`labelOverflow`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/TreemapLegend.bar.html) argument in the constructor will be `TreemapLabelOverflow.visible`. -* **edgeLabelsPlacement** - Used to place the edge labels either inside or outside of the bar legend. The default value of the [`edgeLabelsPlacement`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/TreemapLegend.bar.html) argument in the constructor will be `TreemapLegendEdgeLabelsPlacement.inside`. -* **spacing** - Used to provide space between the each legend items. The default value of the [`spacing`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/TreemapLegend.bar.html) is `2.0`. This is not applicable for gradient legend. -* **direction** - Used to arrange the legend items in either horizontal or vertical direction. The default value of [`direction`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/TreemapLegend.bar.html) property is `horizontal`, if the value of the `position` property is `top`, `bottom` and defaults to `vertical`, if the value of the [`position`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/TreemapLegend.bar.html) property is `left` or `right`. -* **padding** - Used to set padding around the legend. The default value of the [`padding`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/TreemapLegend.bar.html) property is `EdgeInsets.all(10.0)`. - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -class BarLegendAppearanceExample extends StatefulWidget { - const BarLegendAppearanceExample({super.key}); - - @override - State createState() => - _BarLegendAppearanceExampleState(); -} - -class _BarLegendAppearanceExampleState extends State { - late List _source; - - @override - void initState() { - _source = [ - SocialMediaUsers('India', 'Facebook', 25.4), - SocialMediaUsers('USA', 'Instagram', 19.11), - SocialMediaUsers('Japan', 'Facebook', 13.3), - SocialMediaUsers('Germany', 'Instagram', 10.65), - SocialMediaUsers('United Kingdom', 'Instagram', 4.93), - SocialMediaUsers('France', 'Twitter', 7.54), - ]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: SizedBox( - height: 400, - width: 400, - child: SfTreemap( - dataCount: _source.length, - weightValueMapper: (int index) { - return _source[index].usersInMillions; - }, - levels: [ - TreemapLevel( - groupMapper: (int index) { - return _source[index].country; - }, - ), - ], - legend: TreemapLegend.bar( - segmentSize: const Size(60, 12), - labelOverflow: TreemapLabelOverflow.ellipsis, - edgeLabelsPlacement: TreemapLegendEdgeLabelsPlacement.center, - padding: const EdgeInsets.all(12), - direction: Axis.horizontal, - spacing: 5, - ), - ), - ), - ), - ); - } -} - -class SocialMediaUsers { - const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); - - final String country; - final String socialMedia; - final double usersInMillions; -} - -{% endhighlight %} -{% endtabs %} - -![Bar legend customization](images/legend/bar-legend-customization.png) - -## Bar legend labels placement - -You can place the labels either between the segments or on the segments using the [`labelsPlacement`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/TreemapLegend.bar.html) property. - -Labels placement for range color mapper - -The labels are positioned between the segments when setting range color mapper without setting color mapper [`TreemapColorMapper.name`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/name.html) property. The [`TreemapColorMapper.from`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/from.html) value of the first item is positioned at starting point of the first segment and the [`TreemapColorMapper.to`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/to.html) value of the first item is placed at the first segment end position. For other segments, the values of [`TreemapColorMapper.to`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/to.html) is positioned as label between the other segments. - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -class LabelPlacementRangeColorMapperExample extends StatefulWidget { - const LabelPlacementRangeColorMapperExample({super.key}); - - @override - State createState() => - _LabelPlacementRangeColorMapperExampleState(); -} - -class _LabelPlacementRangeColorMapperExampleState extends State { - late List _source; - late List _colorMappers; - - @override - void initState() { - _source = [ - SocialMediaUsers('India', 'Facebook', 25.4), - SocialMediaUsers('USA', 'Instagram', 19.11), - SocialMediaUsers('Japan', 'Facebook', 13.3), - SocialMediaUsers('Germany', 'Instagram', 10.65), - SocialMediaUsers('France', 'Twitter', 7.54), - SocialMediaUsers('UK', 'Instagram', 4.93), - ]; - - _colorMappers = [ - TreemapColorMapper.range(from: 0, to: 10, color: Colors.blue[200]!), - TreemapColorMapper.range(from: 10, to: 20, color: Colors.deepOrange), - TreemapColorMapper.range(from: 20, to: 30, color: Colors.blue[800]!), - ]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: SfTreemap( - dataCount: _source.length, - weightValueMapper: (int index) { - return _source[index].usersInMillions; - }, - levels: [ - TreemapLevel( - padding: const EdgeInsets.all(1.5), - groupMapper: (int index) { - return _source[index].country; - }, - colorValueMapper: (TreemapTile tile) { - return tile.weight; - }, - ), - ], - colorMappers: _colorMappers, - legend: TreemapLegend.bar( - labelsPlacement: TreemapLegendLabelsPlacement.betweenItems, - segmentPaintingStyle: TreemapLegendPaintingStyle.gradient, - ), - ), - ); - } -} - -class SocialMediaUsers { - const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); - - final String country; - final String socialMedia; - final double usersInMillions; -} - -{% endhighlight %} -{% endtabs %} - -![Bar legend labels placement](images/legend/bar-legend-range-color-mapper-default.png) - -The labels are positioned between the segments when setting range color mapper along with setting color mapper [`TreemapColorMapper.name`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/name.html) property. The [`TreemapColorMapper.from`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/from.html) value of the first item is positioned at starting point of the first segment and the [`TreemapColorMapper.name`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/name.html) value of the first item is placed at the first segment end position. For Other segments, the value of [`TreemapColorMapper.name`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/name.html) is positioned as label between the segments. - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -class NamedRangeColorMapperExample extends StatefulWidget { - const NamedRangeColorMapperExample({super.key}); - - @override - State createState() => - _NamedRangeColorMapperExampleState(); -} - -class _NamedRangeColorMapperExampleState extends State { - late List _source; - late List _colorMappers; - - @override - void initState() { - _source = [ - SocialMediaUsers('India', 'Facebook', 25.4), - SocialMediaUsers('USA', 'Instagram', 19.11), - SocialMediaUsers('Japan', 'Facebook', 13.3), - SocialMediaUsers('Germany', 'Instagram', 10.65), - SocialMediaUsers('France', 'Twitter', 7.54), - SocialMediaUsers('UK', 'Instagram', 4.93), - ]; - - _colorMappers = [ - TreemapColorMapper.range( - from: 0, to: 10, color: Colors.blue[200]!, name: '<10'), - TreemapColorMapper.range( - from: 10, to: 20, color: Colors.deepOrange, name: '10 - 20'), - TreemapColorMapper.range( - from: 20, to: 30, color: Colors.blue[800]!, name: '20 - 30'), - ]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: SfTreemap( - dataCount: _source.length, - weightValueMapper: (int index) { - return _source[index].usersInMillions; - }, - levels: [ - TreemapLevel( - padding: const EdgeInsets.all(1.5), - groupMapper: (int index) { - return _source[index].country; - }, - colorValueMapper: (TreemapTile tile) { - return tile.weight; - }, - ), - ], - colorMappers: _colorMappers, - legend: TreemapLegend.bar( - labelsPlacement: TreemapLegendLabelsPlacement.betweenItems, - segmentPaintingStyle: TreemapLegendPaintingStyle.gradient, - ), - ), - ); - } -} - -class SocialMediaUsers { - const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); - - final String country; - final String socialMedia; - final double usersInMillions; -} - -{% endhighlight %} -{% endtabs %} - -![Bar legend labels placement](images/legend/bar-legend-range-color-mapper-with-text.png) - -The labels are positioned at the center of the segments when setting the [`labelsPlacement`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/TreemapLegend.bar.html) property to [`TreemapLegendLabelsPlacement.onItem`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegendLabelsPlacement.html#onItem). The labels will based on the value of [`TreemapColorMapper.name`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/name.html) property. If the value of [`TreemapColorMapper.name`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/name.html) property is null, labels will be based on the values of [`TreemapColorMapper.from`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/from.html) and [`TreemapColorMapper.to`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/to.html) properties. - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -class BarLegendLabelPlacementExample extends StatefulWidget { - const BarLegendLabelPlacementExample({super.key}); - - @override - State createState() => - _BarLegendLabelPlacementExampleState(); -} - -class _BarLegendLabelPlacementExampleState extends State { - - late List _source; - late List _colorMappers; - - @override - void initState() { - _source = [ - SocialMediaUsers('India', 'Facebook', 25.4), - SocialMediaUsers('USA', 'Instagram', 19.11), - SocialMediaUsers('Japan', 'Facebook', 13.3), - SocialMediaUsers('Germany', 'Instagram', 10.65), - SocialMediaUsers('France', 'Twitter', 7.54), - SocialMediaUsers('UK', 'Instagram', 4.93), - ]; - - _colorMappers = [ - TreemapColorMapper.range( - from: 0, to: 10, color: Colors.blue[200]!, name: '<10'), - TreemapColorMapper.range( - from: 10, to: 20, color: Colors.deepOrange, name: '10 - 20'), - TreemapColorMapper.range( - from: 20, to: 30, color: Colors.blue[800]!, name: '20 - 30'), - ]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: SfTreemap( - dataCount: _source.length, - weightValueMapper: (int index) { - return _source[index].usersInMillions; - }, - levels: [ - TreemapLevel( - padding: const EdgeInsets.all(1.5), - groupMapper: (int index) { - return _source[index].country; - }, - colorValueMapper: (TreemapTile tile) { - return tile.weight; - }, - ), - ], - colorMappers: _colorMappers, - legend: TreemapLegend.bar( - labelsPlacement: TreemapLegendLabelsPlacement.onItem, - edgeLabelsPlacement: TreemapLegendEdgeLabelsPlacement.center, - segmentPaintingStyle: TreemapLegendPaintingStyle.gradient, - ), - ), - ); - } -} - -class SocialMediaUsers { - const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); - - final String country; - final String socialMedia; - final double usersInMillions; -} - -{% endhighlight %} -{% endtabs %} - -![Bar legend labels placement](images/legend/bar-legend-range-color-mapper-onItem.png) - -Labels placement for equal color mapper - -The [`labelsPlacement`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/labelsPlacement.html) option is not applicable for the legend label applied with equal color mapper. By default, the labels are positioned at center of the segment. - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -class PointerCustomizationExample extends StatefulWidget { - const PointerCustomizationExample({super.key}); - - @override - State createState() => - _PointerCustomizationExampleState(); -} - -class _PointerCustomizationExampleState extends State { - - late List _source; - late List _colorMappers; - - @override - void initState() { - _source = [ - SocialMediaUsers('India', 'Facebook', 25.4), - SocialMediaUsers('USA', 'Instagram', 19.11), - SocialMediaUsers('Japan', 'Facebook', 13.3), - SocialMediaUsers('Germany', 'Instagram', 10.65), - SocialMediaUsers('France', 'Twitter', 7.54), - SocialMediaUsers('UK', 'Instagram', 4.93), - ]; - - _colorMappers = [ - TreemapColorMapper.value(value: 'Facebook', color: Colors.blue[200]!), - TreemapColorMapper.value(value: 'Instagram', color: Colors.deepOrange), - TreemapColorMapper.value(value: 'Twitter', color: Colors.blue[800]!), - ]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: SfTreemap( - dataCount: _source.length, - weightValueMapper: (int index) { - return _source[index].usersInMillions; - }, - levels: [ - TreemapLevel( - padding: const EdgeInsets.all(2.5), - groupMapper: (int index) { - return _source[index].country; - }, - labelBuilder: (BuildContext context, TreemapTile tile) { - return Text(_source[tile.indices[0]].socialMedia); - }, - colorValueMapper: (TreemapTile tile) { - return _source[tile.indices[0]].socialMedia; - }, - ), - ], - colorMappers: _colorMappers, - legend: TreemapLegend.bar( - edgeLabelsPlacement: TreemapLegendEdgeLabelsPlacement.center, - segmentPaintingStyle: TreemapLegendPaintingStyle.gradient, - ), - ), - ); - } -} - -class SocialMediaUsers { - const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); - - final String country; - final String socialMedia; - final double usersInMillions; -} - -{% endhighlight %} -{% endtabs %} - -![Bar legend labels placement](images/legend/bar-legend-equal-color-mapper-default.png) - -## Show pointer - -You may show a pointer on the solid or gradient bar legend while hovering over a tile using the [`showPointerOnHover`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/showPointerOnHover.html) property. The default value of the [`showPointerOnHover`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/showPointerOnHover.html) property is `false`. - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -class ShowPointerExample extends StatefulWidget { - const ShowPointerExample({super.key}); - - @override - State createState() => _ShowPointerExampleState(); -} - -class _ShowPointerExampleState extends State { - late List _population; - late List _colorMappers; - - @override - void initState() { - _population = [ - IndianPopulation('Gujarat', 54612), - IndianPopulation('Bangalore', 473069), - IndianPopulation('Chennai', 210312), - IndianPopulation('Andra', 95419), - IndianPopulation('Kashmir', 80599), - IndianPopulation('Delhi', 39000), - IndianPopulation('Mumbai', 122897), - IndianPopulation('Kolkatta', 184135), - ]; - - _colorMappers = [ - TreemapColorMapper.range(from: 0, to: 10, color: Colors.blueGrey), - TreemapColorMapper.range(from: 10, to: 20, color: Colors.green), - TreemapColorMapper.range(from: 20, to: 30, color: Colors.lime), - TreemapColorMapper.range(from: 30, to: 50, color: Colors.teal), - ]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: SizedBox( - height: 400, - width: 400, - child: SfTreemap( - dataCount: _population.length, - weightValueMapper: (int index) => - _population[index].population.toDouble(), - colorMappers: _colorMappers, - legend: TreemapLegend.bar( - segmentPaintingStyle: TreemapLegendPaintingStyle.gradient, - showPointerOnHover: true, - ), - levels: [ - TreemapLevel( - groupMapper: (int index) { - return _population[index].state; - }, - colorValueMapper: (TreemapTile tile) { - return _population[tile.indices[0]].population / 10000; - }, - ) - ], - ), - ), - ), - ); - } -} - -class IndianPopulation { - const IndianPopulation(this.state, this.population); - - final String state; - final int population; -} - -{% endhighlight %} -{% endtabs %} - -![Bar legend pointer](images/legend/bar-legend-pointer.gif) - -## Pointer builder - -It returns a widget for the given value. - -The pointer is used to indicate the exact color of the hovering tile on the legend segment. - -The [`pointerBuilder`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/pointerBuilder.html) will be called when the user interacts with the tiles i.e., while tapping in touch devices and hovering in the mouse enabled devices. - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -class PointerBuilderExample extends StatefulWidget { - const PointerBuilderExample({super.key}); - - @override - State createState() => _PointerBuilderExampleState(); -} - -class _PointerBuilderExampleState extends State { - late List _population; - late List _colorMappers; - - @override - void initState() { - _population = [ - IndianPopulation('Gujarat', 54612), - IndianPopulation('Bangalore', 473069), - IndianPopulation('Chennai', 210312), - IndianPopulation('Andra', 95419), - IndianPopulation('Kashmir', 80599), - IndianPopulation('Delhi', 39000), - IndianPopulation('Mumbai', 122897), - IndianPopulation('Kolkatta', 184135), - ]; - - _colorMappers = [ - TreemapColorMapper.range(from: 0, to: 10, color: Colors.blueGrey), - TreemapColorMapper.range(from: 10, to: 20, color: Colors.green), - TreemapColorMapper.range(from: 20, to: 30, color: Colors.lime), - TreemapColorMapper.range(from: 30, to: 50, color: Colors.teal), - ]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: SizedBox( - height: 400, - width: 400, - child: SfTreemap( - dataCount: _population.length, - weightValueMapper: (int index) => - _population[index].population.toDouble(), - colorMappers: _colorMappers, - legend: TreemapLegend.bar( - segmentPaintingStyle: TreemapLegendPaintingStyle.gradient, - showPointerOnHover: true, - pointerBuilder: (BuildContext context, dynamic value) { - return const Icon(Icons.arrow_downward, size: 15); - }, - ), - levels: [ - TreemapLevel( - groupMapper: (int index) { - return _population[index].state; - }, - colorValueMapper: (TreemapTile tile) { - return _population[tile.indices[0]].population / 10000; - }, - ) - ], - ), - ), - ), - ); - } -} - -class IndianPopulation { - const IndianPopulation(this.state, this.population); - - final String state; - final int population; -} - -{% endhighlight %} -{% endtabs %} - -![Bar legend custom pointer](images/legend/bar-legend-custom-pointer.png) - -## Pointer customization - -You can customize the size and color of the pointer using the [`pointerSize`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/pointerSize.html) and [`pointerColor`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/pointerColor.html) properties. The default value of the [`pointerSize`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/pointerSize.html) property is `Size(16, 12)`. - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -class PointerCustomizationExample extends StatefulWidget { - const PointerCustomizationExample({super.key}); - - @override - State createState() => - _PointerCustomizationExampleState(); -} - -class _PointerCustomizationExampleState extends State { - late List _population; - late List _colorMappers; - - @override - void initState() { - _population = [ - IndianPopulation('Gujarat', 54612), - IndianPopulation('Bangalore', 473069), - IndianPopulation('Chennai', 210312), - IndianPopulation('Andra', 95419), - IndianPopulation('Kashmir', 80599), - IndianPopulation('Delhi', 39000), - IndianPopulation('Mumbai', 122897), - IndianPopulation('Kolkatta', 184135), - ]; - - _colorMappers = [ - TreemapColorMapper.range(from: 0, to: 10, color: Colors.blueGrey), - TreemapColorMapper.range(from: 10, to: 20, color: Colors.green), - TreemapColorMapper.range(from: 20, to: 30, color: Colors.lime), - TreemapColorMapper.range(from: 30, to: 50, color: Colors.teal), - ]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: SizedBox( - height: 400, - width: 400, - child: SfTreemap( - dataCount: _population.length, - weightValueMapper: (int index) => - _population[index].population.toDouble(), - colorMappers: _colorMappers, - legend: TreemapLegend.bar( - segmentPaintingStyle: TreemapLegendPaintingStyle.gradient, - showPointerOnHover: true, - pointerSize: const Size(20, 20), - pointerColor: Colors.deepPurple, - ), - levels: [ - TreemapLevel( - groupMapper: (int index) { - return _population[index].state; - }, - colorValueMapper: (TreemapTile tile) { - return _population[tile.indices[0]].population / 10000; - }, - ) - ], - ), - ), - ), - ); - } -} - -class IndianPopulation { - const IndianPopulation(this.state, this.population); - - final String state; - final int population; -} - -{% endhighlight %} -{% endtabs %} - +--- +layout: post +title: Legend in Flutter Treemap | Syncfusion® +description: Learn about legend support in Syncfusion® Flutter Treemap (SfTreemap), including legend customization, color mapping, positioning, and styling options. +platform: flutter +control: SfTreemap +documentation: ug +--- + +# Legend in Flutter Treemap (SfTreemap) + +The legend provides clarity about the data plotted on the treemap. + +## Enable default legend + +To display a legend, initialize the [`SfTreemap.legend`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/legend.html) property. By default, the legend item's text is rendered based on the value of [`TreemapLevel.groupMapper`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/groupMapper.html) property. The default value of the [`legend`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/legend.html) property is `null`. + +The examples in this section use the same data source and differ only in the legend constructor. + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +class DefaultLegendExample extends StatefulWidget { + const DefaultLegendExample({super.key}); + + @override + State createState() => _DefaultLegendExampleState(); +} + +class _DefaultLegendExampleState extends State { + late List _source; + + @override + void initState() { + _source = [ + SocialMediaUsers('India', 'Facebook', 25.4), + SocialMediaUsers('USA', 'Instagram', 19.11), + SocialMediaUsers('Japan', 'Facebook', 13.3), + SocialMediaUsers('Germany', 'Instagram', 10.65), + SocialMediaUsers('France', 'Twitter', 7.54), + SocialMediaUsers('UK', 'Instagram', 4.93), + ]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: SizedBox( + height: 400, + width: 400, + child: SfTreemap( + dataCount: _source.length, + weightValueMapper: (int index) { + return _source[index].usersInMillions; + }, + levels: [ + TreemapLevel( + groupMapper: (int index) { + return _source[index].country; + }, + ), + ], + legend: TreemapLegend(), + ), + ), + ), + ); + } +} + +class SocialMediaUsers { + const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); + + final String country; + final String socialMedia; + final double usersInMillions; +} + +{% endhighlight %} +{% endtabs %} + +![default legend](images/legend/default-legend.png) + +N> +* Refer the [`TreemapLegend.bar`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/TreemapLegend.bar.html), to display a bar-shaped legend. + +## Bar shape legend + +You can show bar shape legend by initializing the [`SfTreemap.legend`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/legend.html) property as [`TreemapLegend.bar`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/TreemapLegend.bar.html). By default, the legend item's text is rendered based on the value of [`TreemapLevel.groupMapper`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/groupMapper.html) property. + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +class BarLegendExample extends StatefulWidget { + const BarLegendExample({super.key}); + + @override + State createState() => _BarLegendExampleState(); +} + +class _BarLegendExampleState extends State { + late List _source; + + @override + void initState() { + _source = [ + SocialMediaUsers('India', 'Facebook', 25.4), + SocialMediaUsers('USA', 'Instagram', 19.11), + SocialMediaUsers('Japan', 'Facebook', 13.3), + SocialMediaUsers('Germany', 'Instagram', 10.65), + SocialMediaUsers('France', 'Twitter', 7.54), + SocialMediaUsers('UK', 'Instagram', 4.93), + ]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: SizedBox( + height: 400, + width: 400, + child: SfTreemap( + dataCount: _source.length, + weightValueMapper: (int index) { + return _source[index].usersInMillions; + }, + levels: [ + TreemapLevel( + groupMapper: (int index) { + return _source[index].country; + }, + ), + ], + legend: TreemapLegend.bar(), + ), + ), + ), + ); + } +} + +class SocialMediaUsers { + const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); + + final String country; + final String socialMedia; + final double usersInMillions; +} + +{% endhighlight %} +{% endtabs %} + +![bar legend](images/legend/bar-legend.png) + +N> +* Refer the [`TreemapLegend`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/TreemapLegend.html), for the default legend display options. + +## Icon and text customization + +Legend icons and text are customized based on the [`TreemapLevel.color`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/color.html) and [`TreemapLevel.groupMapper`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/groupMapper.html) properties by default. It is possible to customize the legend icon colors and texts using the [`TreemapColorMapper.color`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/color.html) based on the [`TreemapColorMapper.value`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/value.html) or [`TreemapColorMapper.from`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/from.html) and [`TreemapColorMapper.to`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/to.html) properties. You can also customize the legend item's text using the [`TreemapColorMapper.name`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/name.html) when setting the [`TreemapColorMapper.range`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/TreemapColorMapper.range.html) color mapper constructor. + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +class IconTextCustomizationExample extends StatefulWidget { + const IconTextCustomizationExample({super.key}); + + @override + State createState() => + _IconTextCustomizationExampleState(); +} + +class _IconTextCustomizationExampleState extends State { + late List _source; + late List _colorMappers; + + @override + void initState() { + _source = [ + SocialMediaUsers('India', 'Facebook', 25.4), + SocialMediaUsers('USA', 'Instagram', 19.11), + SocialMediaUsers('Japan', 'Facebook', 13.3), + SocialMediaUsers('Germany', 'Instagram', 10.65), + SocialMediaUsers('France', 'Twitter', 7.54), + SocialMediaUsers('UK', 'Instagram', 4.93), + ]; + + _colorMappers = [ + TreemapColorMapper.range(from: 0, to: 10, color: Colors.blue[200]!), + TreemapColorMapper.range(from: 10, to: 20, color: Colors.deepOrange), + TreemapColorMapper.range(from: 20, to: 30, color: Colors.blue[800]!), + ]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SfTreemap( + dataCount: _source.length, + weightValueMapper: (int index) { + return _source[index].usersInMillions; + }, + levels: [ + TreemapLevel( + padding: const EdgeInsets.all(1.5), + groupMapper: (int index) { + return _source[index].country; + }, + colorValueMapper: (TreemapTile tile) { + return tile.weight; + }, + ), + ], + colorMappers: _colorMappers, + legend: TreemapLegend.bar(), + ), + ); + } +} + +class SocialMediaUsers { + const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); + + final String country; + final String socialMedia; + final double usersInMillions; +} + +{% endhighlight %} +{% endtabs %} + +![legend icon color](images/legend/icon-color.png) + +## First segment label customization + +You can customize the first segment label of the legend by using the [`TreemapColorMapper.name`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/name.html) property with curly braces. The value inside the first pair of curly braces will be used as the start label for the segment, and the value inside the second pair will be used as the end label. + +By default, the [`TreemapColorMapper.from`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/from.html) value appears at the start of the first segment, and the [`TreemapColorMapper.to`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/to.html) value appears at the end. + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +class FirstSegmentLabelExample extends StatefulWidget { + const FirstSegmentLabelExample({super.key}); + + @override + State createState() => + _FirstSegmentLabelExampleState(); +} + +class _FirstSegmentLabelExampleState extends State { + late List _source; + late List _colorMappers; + + @override + void initState() { + _source = [ + SocialMediaUsers('India', 'Facebook', 25.4), + SocialMediaUsers('USA', 'Instagram', 19.11), + SocialMediaUsers('Japan', 'Facebook', 13.3), + SocialMediaUsers('Germany', 'Instagram', 10.65), + SocialMediaUsers('France', 'Twitter', 7.54), + SocialMediaUsers('UK', 'Instagram', 4.93), + ]; + + _colorMappers = [ + TreemapColorMapper.range( + from: 0, to: 10, color: Colors.blue[200]!, name: '{0M},{10M}'), + TreemapColorMapper.range( + from: 10, to: 20, color: Colors.deepOrange, name: '20M'), + TreemapColorMapper.range( + from: 20, to: 30, color: Colors.blue[800]!, name: '30M'), + ]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SfTreemap( + dataCount: _source.length, + weightValueMapper: (int index) { + return _source[index].usersInMillions; + }, + levels: [ + TreemapLevel( + padding: const EdgeInsets.all(1.5), + groupMapper: (int index) { + return _source[index].country; + }, + colorValueMapper: (TreemapTile tile) { + return tile.weight; + }, + ), + ], + colorMappers: _colorMappers, + legend: TreemapLegend.bar(), + ), + ); + } +} + +class SocialMediaUsers { + const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); + + final String country; + final String socialMedia; + final double usersInMillions; +} + +{% endhighlight %} +{% endtabs %} + +![First label customization](images/legend/first-label-customization.png) + +## Scrollbar visibility + +You can control the visibility of the scrollbar in the treemap legend using the [`shouldAlwaysShowScrollbar`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/shouldAlwaysShowScrollbar.html) property. When set to `true`, the scrollbar for the legend will always be visible, making it easier to see and navigate through legend items, even if all items fit within the available space. + +The default value is `false`, so the scrollbar appears in legend only when the legend items exceed the available space and scrolling is needed. + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +class ScrollbarVisibilityExample extends StatefulWidget { + const ScrollbarVisibilityExample({super.key}); + + @override + State createState() => + _ScrollbarVisibilityExampleState(); +} + +class _ScrollbarVisibilityExampleState extends State { + late List _source; + + @override + void initState() { + _source = [ + SocialMediaUsers('India', 'Facebook', 25.4), + SocialMediaUsers('USA', 'Instagram', 19.11), + SocialMediaUsers('Japan', 'Facebook', 13.3), + SocialMediaUsers('Germany', 'Instagram', 10.65), + SocialMediaUsers('France', 'Twitter', 7.54), + SocialMediaUsers('UK', 'Instagram', 4.93), + ]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: SizedBox( + height: 400, + width: 400, + child: SfTreemap( + dataCount: _source.length, + weightValueMapper: (int index) { + return _source[index].usersInMillions; + }, + levels: [ + TreemapLevel( + groupMapper: (int index) { + return _source[index].country; + }, + ), + ], + legend: TreemapLegend( + shouldAlwaysShowScrollbar: true, + overflowMode: TreemapLegendOverflowMode.scroll, + ), + ), + ), + ), + ); + } +} + +class SocialMediaUsers { + const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); + + final String country; + final String socialMedia; + final double usersInMillions; +} + +{% endhighlight %} +{% endtabs %} + +## Title + +You can set a title specifically for the legend in the Flutter Treemap by using the [`title`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/title.html) property. This property lets you display a descriptive heading for the legend, helping users understand what the legend represents within the Flutter Treemap. + +By default, the value of the legend's [`title`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/title.html) property is `null`, indicating that no title is displayed for the legend, unless it is specified explicitly. + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +class LegendTitleExample extends StatefulWidget { + const LegendTitleExample({super.key}); + + @override + State createState() => _LegendTitleExampleState(); +} + +class _LegendTitleExampleState extends State { + late List _source; + + @override + void initState() { + _source = [ + SocialMediaUsers('India', 'Facebook', 25.4), + SocialMediaUsers('USA', 'Instagram', 19.11), + SocialMediaUsers('Japan', 'Facebook', 13.3), + SocialMediaUsers('Germany', 'Instagram', 10.65), + SocialMediaUsers('France', 'Twitter', 7.54), + SocialMediaUsers('UK', 'Instagram', 4.93), + ]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: SizedBox( + height: 400, + width: 400, + child: SfTreemap( + dataCount: _source.length, + weightValueMapper: (int index) { + return _source[index].usersInMillions; + }, + levels: [ + TreemapLevel( + groupMapper: (int index) { + return _source[index].country; + }, + ), + ], + legend: TreemapLegend( + title: Text('Social media users'), + ), + ), + ), + ), + ); + } +} + +class SocialMediaUsers { + const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); + + final String country; + final String socialMedia; + final double usersInMillions; +} + +{% endhighlight %} +{% endtabs %} + +![legend title](images/legend/legend-title.png) + +## Position + +You can position the legend items in different directions using the [`TreemapLegend.position`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/position.html) property. The default value of the [position`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/position.html) property is [`TreemapLegendPosition.top`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegendPosition.html). The possible values are [`left`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegendPosition.html#left), [`right`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegendPosition.html#right), [`top`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegendPosition.html#top), and [`bottom`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegendPosition.html#bottom). + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +class LegendPositionExample extends StatefulWidget { + const LegendPositionExample({super.key}); + + @override + State createState() => _LegendPositionExampleState(); +} + +class _LegendPositionExampleState extends State { + late List _source; + + @override + void initState() { + _source = [ + SocialMediaUsers('India', 'Facebook', 25.4), + SocialMediaUsers('USA', 'Instagram', 19.11), + SocialMediaUsers('Japan', 'Facebook', 13.3), + SocialMediaUsers('Germany', 'Instagram', 10.65), + SocialMediaUsers('France', 'Twitter', 7.54), + SocialMediaUsers('UK', 'Instagram', 4.93), + ]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: SizedBox( + height: 400, + width: 400, + child: SfTreemap( + dataCount: _source.length, + weightValueMapper: (int index) { + return _source[index].usersInMillions; + }, + levels: [ + TreemapLevel( + groupMapper: (int index) { + return _source[index].country; + }, + ), + ], + legend: TreemapLegend( + position: TreemapLegendPosition.bottom, + ), + ), + ), + ), + ); + } +} + +class SocialMediaUsers { + const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); + + final String country; + final String socialMedia; + final double usersInMillions; +} + +{% endhighlight %} +{% endtabs %} + +![legend position](images/legend/legend-position.png) + +N> +* Refer the [`offset`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/offset.html), for placing the legend in custom position. + +## Offset + +You can place the legend in a custom position using the [`TreemapLegend.offset`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/offset.html) property. The default value of the [`offset`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/offset.html) property is `null`. + +If the property [`TreemapLegend.offset`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/offset.html) has been set with the property [`TreemapLegend.position`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/position.html) as top, then the legend will be placed at the top but with an absolute position, meaning it will not take a dedicated position and will be drawn at the top of the Flutter Treemap. + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +class LegendOffsetExample extends StatefulWidget { + const LegendOffsetExample({super.key}); + + @override + State createState() => _LegendOffsetExampleState(); +} + +class _LegendOffsetExampleState extends State { + late List _source; + + @override + void initState() { + _source = [ + SocialMediaUsers('India', 'Facebook', 25.4), + SocialMediaUsers('USA', 'Instagram', 19.11), + SocialMediaUsers('Japan', 'Facebook', 13.3), + SocialMediaUsers('Germany', 'Instagram', 10.65), + SocialMediaUsers('France', 'Twitter', 7.54), + SocialMediaUsers('UK', 'Instagram', 4.93), + ]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: SizedBox( + height: 400, + width: 400, + child: SfTreemap( + dataCount: _source.length, + weightValueMapper: (int index) { + return _source[index].usersInMillions; + }, + levels: [ + TreemapLevel( + groupMapper: (int index) { + return _source[index].country; + }, + ), + ], + legend: TreemapLegend( + offset: const Offset(70, 250), + ), + ), + ), + ), + ); + } +} + +class SocialMediaUsers { + const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); + + final String country; + final String socialMedia; + final double usersInMillions; +} + +{% endhighlight %} +{% endtabs %} + +![legend offset](images/legend/legend-offset.png) + +## Overflow mode + +For default legend + +You can wrap or scroll the legend items using the [`TreemapLegend.overflowMode`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/overflowMode.html) property. The default value of the [`overflowMode`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/overflowMode.html) property is [`TreemapLegendOverflowMode.wrap`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegendOverflowMode.html). The possible values are [`scroll`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegendOverflowMode.html#scroll) and [`wrap`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegendOverflowMode.html#wrap). + +If the legend position is `left` or `right`, then the default scroll direction is `vertical`. + +If the legend position is `top` or `bottom`, then the default scroll direction is `horizontal`. + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +class OverflowModeExample extends StatefulWidget { + const OverflowModeExample({super.key}); + + @override + State createState() => _OverflowModeExampleState(); +} + +class _OverflowModeExampleState extends State { + late List _source; + + @override + void initState() { + _source = [ + SocialMediaUsers('India', 'Facebook', 25.4), + SocialMediaUsers('USA', 'Instagram', 19.11), + SocialMediaUsers('Japan', 'Facebook', 13.3), + SocialMediaUsers('China', 'Facebook', 12.3), + SocialMediaUsers('Germany', 'Instagram', 10.65), + SocialMediaUsers('France', 'Twitter', 7.54), + SocialMediaUsers('South America', 'Twitter', 5.54), + SocialMediaUsers('United Kingdom', 'Instagram', 4.93), + ]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: SizedBox( + height: 400, + width: 400, + child: SfTreemap( + dataCount: _source.length, + weightValueMapper: (int index) { + return _source[index].usersInMillions; + }, + levels: [ + TreemapLevel( + groupMapper: (int index) { + return _source[index].country; + }, + ), + ], + legend: TreemapLegend( + overflowMode: TreemapLegendOverflowMode.scroll, + ), + ), + ), + ), + ); + } +} + +class SocialMediaUsers { + const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); + + final String country; + final String socialMedia; + final double usersInMillions; +} + +{% endhighlight %} +{% endtabs %} + +![default legend overflow mode](images/legend/default-legend-overflow-mode.gif) + +For bar legend + +You can wrap or scroll the bar legend items using the [`TreemapLegend.overflowMode`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/overflowMode.html) property. The default value of the `overflowMode` property is [`TreemapLegendOverflowMode.scroll`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegendOverflowMode.html). The possible values are `scroll` and `wrap`. + +If the legend position is `left` or `right`, then the default scroll direction is `vertical`. + +If the legend position is `top` or `bottom`, then the default scroll direction is `horizontal`. + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +class BarOverflowModeExample extends StatefulWidget { + const BarOverflowModeExample({super.key}); + + @override + State createState() => _BarOverflowModeExampleState(); +} + +class _BarOverflowModeExampleState extends State { + late List _source; + + @override + void initState() { + _source = [ + SocialMediaUsers('India', 'Facebook', 25.4), + SocialMediaUsers('USA', 'Instagram', 19.11), + SocialMediaUsers('Japan', 'Facebook', 13.3), + SocialMediaUsers('Germany', 'Instagram', 10.65), + SocialMediaUsers('France', 'Twitter', 7.54), + SocialMediaUsers('UK', 'Instagram', 4.93), + ]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: SizedBox( + height: 400, + width: 400, + child: SfTreemap( + dataCount: _source.length, + weightValueMapper: (int index) { + return _source[index].usersInMillions; + }, + levels: [ + TreemapLevel( + groupMapper: (int index) { + return _source[index].country; + }, + ), + ], + legend: TreemapLegend.bar( + overflowMode: TreemapLegendOverflowMode.scroll, + ), + ), + ), + ), + ); + } +} + +class SocialMediaUsers { + const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); + + final String country; + final String socialMedia; + final double usersInMillions; +} + +{% endhighlight %} +{% endtabs %} + +![bar legend overflow mode](images/legend/bar-legend-overflow-mode.gif) + +N> +* Refer the [`iconSize`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/TreemapLegend.html), for changing the size of the icon. + +## Text style + +You can customize the legend item's text style using the [`TreemapLegend.textStyle`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/textStyle.html) property. + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +class TextStyleExample extends StatefulWidget { + const TextStyleExample({super.key}); + + @override + State createState() => _TextStyleExampleState(); +} + +class _TextStyleExampleState extends State { + late List _source; + + @override + void initState() { + _source = [ + SocialMediaUsers('India', 'Facebook', 25.4), + SocialMediaUsers('USA', 'Instagram', 19.11), + SocialMediaUsers('Japan', 'Facebook', 13.3), + SocialMediaUsers('Germany', 'Instagram', 10.65), + SocialMediaUsers('France', 'Twitter', 7.54), + SocialMediaUsers('UK', 'Instagram', 4.93), + ]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: SizedBox( + height: 400, + width: 400, + child: SfTreemap( + dataCount: _source.length, + weightValueMapper: (int index) { + return _source[index].usersInMillions; + }, + levels: [ + TreemapLevel( + groupMapper: (int index) { + return _source[index].country; + }, + ), + ], + legend: TreemapLegend( + textStyle: const TextStyle( + color: Colors.red, + fontSize: 14, + fontWeight: FontWeight.bold, + fontStyle: FontStyle.italic, + ), + ), + ), + ), + ), + ); + } +} + +class SocialMediaUsers { + const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); + + final String country; + final String socialMedia; + final double usersInMillions; +} + +{% endhighlight %} +{% endtabs %} + +![legend text style](images/legend/text-style.png) + +## Default legend appearance customization + +You can customize the legend items using the following properties. + +* **iconType** - Used to change the icon shape. The default value of the [`iconType`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/TreemapLegend.html) argument in the constructor is [`TreemapIconType.circle`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapIconType.html#circle). The possible values are [`circle`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapIconType.html#circle), [`rectangle`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapIconType.html#rectangle), [`triangle`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapIconType.html#triangle), and [`diamond`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapIconType.html#diamond). +* **iconSize** - Used to change the size of the icon. The default value of [`iconSize`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/TreemapLegend.html) argument in the constructor is `Size(8.0, 8.0)`. +* **spacing** - Used to provide space between the each legend items. The default value of the [`spacing`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/spacing.html) argument in the constructor is `10.0`. +* **direction** - Used to arrange the legend items in either horizontal or vertical direction. The default value of [`direction`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/direction.html) property is `horizontal`, if the value of the [`position`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/position.html) property is [`top`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegendPosition.html#top), [`bottom`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegendPosition.html#bottom) and defaults to `vertical`, if the value of the [`position`] property is [`left`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegendPosition.html#left) or [`right`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegendPosition.html#right). +* **padding** - Used to set padding around the legend. The default value of the [`padding`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/padding.html) property is `EdgeInsets.all(10.0)`. + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +class LegendAppearanceExample extends StatefulWidget { + const LegendAppearanceExample({super.key}); + + @override + State createState() => + _LegendAppearanceExampleState(); +} + +class _LegendAppearanceExampleState extends State { + late List _source; + + @override + void initState() { + _source = [ + SocialMediaUsers('India', 'Facebook', 25.4), + SocialMediaUsers('USA', 'Instagram', 19.11), + SocialMediaUsers('Japan', 'Facebook', 13.3), + SocialMediaUsers('Germany', 'Instagram', 10.65), + SocialMediaUsers('France', 'Twitter', 7.54), + SocialMediaUsers('UK', 'Instagram', 4.93), + ]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: SizedBox( + height: 400, + width: 400, + child: SfTreemap( + dataCount: _source.length, + weightValueMapper: (int index) { + return _source[index].usersInMillions; + }, + levels: [ + TreemapLevel( + groupMapper: (int index) { + return _source[index].country; + }, + ), + ], + legend: TreemapLegend( + iconType: TreemapIconType.triangle, + iconSize: const Size(12.0, 12.0), + spacing: 15, + padding: const EdgeInsets.all(12.0), + direction: Axis.vertical, + ), + ), + ), + ), + ); + } +} + +class SocialMediaUsers { + const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); + + final String country; + final String socialMedia; + final double usersInMillions; +} + +{% endhighlight %} +{% endtabs %} + +![Legend items customization](images/legend/legend-items-customization.png) + +N> +* Refer the `position`, for setting the position of the legend. + +## Bar legend segment painting style + +### Solid + +You can set solid color for the legend bar by using the [`TreemapLegendPaintingStyle.solid`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegendPaintingStyle.html#solid). By defaults [`TreemapLegendPaintingStyle`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegendPaintingStyle.html) will be [`solid`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegendPaintingStyle.html#solid). + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +class SolidBarLegendExample extends StatefulWidget { + const SolidBarLegendExample({super.key}); + + @override + State createState() => _SolidBarLegendExampleState(); +} + +class _SolidBarLegendExampleState extends State { + late List _source; + late List _colorMappers; + + @override + void initState() { + _source = [ + SocialMediaUsers('India', 'Facebook', 25.4), + SocialMediaUsers('USA', 'Instagram', 19.11), + SocialMediaUsers('Japan', 'Facebook', 13.3), + SocialMediaUsers('Germany', 'Instagram', 10.65), + SocialMediaUsers('France', 'Twitter', 7.54), + SocialMediaUsers('UK', 'Instagram', 4.93), + ]; + + _colorMappers = [ + TreemapColorMapper.range(from: 0, to: 10, color: Colors.blue[200]!), + TreemapColorMapper.range(from: 10, to: 20, color: Colors.deepOrange), + TreemapColorMapper.range(from: 20, to: 30, color: Colors.blue[800]!), + ]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SfTreemap( + dataCount: _source.length, + weightValueMapper: (int index) { + return _source[index].usersInMillions; + }, + levels: [ + TreemapLevel( + padding: const EdgeInsets.all(1.5), + groupMapper: (int index) { + return _source[index].country; + }, + colorValueMapper: (TreemapTile tile) { + return tile.weight; + }, + ), + ], + colorMappers: _colorMappers, + legend: TreemapLegend.bar( + segmentPaintingStyle: TreemapLegendPaintingStyle.solid, + ), + ), + ); + } +} + +class SocialMediaUsers { + const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); + + final String country; + final String socialMedia; + final double usersInMillions; +} + +{% endhighlight %} +{% endtabs %} + +![Bar legend solid type](images/legend/bar-legend-solid-type.png) + +### Gradient + +You can set gradient color for the legend bar by using the [`TreemapLegendPaintingStyle.gradient`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegendPaintingStyle.html#gradient). + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +class GradientBarLegendExample extends StatefulWidget { + const GradientBarLegendExample({super.key}); + + @override + State createState() => + _GradientBarLegendExampleState(); +} + +class _GradientBarLegendExampleState extends State { + late List _source; + late List _colorMappers; + + @override + void initState() { + _source = [ + SocialMediaUsers('India', 'Facebook', 25.4), + SocialMediaUsers('USA', 'Instagram', 19.11), + SocialMediaUsers('Japan', 'Facebook', 13.3), + SocialMediaUsers('Germany', 'Instagram', 10.65), + SocialMediaUsers('France', 'Twitter', 7.54), + SocialMediaUsers('UK', 'Instagram', 4.93), + ]; + + _colorMappers = [ + TreemapColorMapper.range(from: 0, to: 10, color: Colors.blue[200]!), + TreemapColorMapper.range(from: 10, to: 20, color: Colors.deepOrange), + TreemapColorMapper.range(from: 20, to: 30, color: Colors.blue[800]!), + ]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SfTreemap( + dataCount: _source.length, + weightValueMapper: (int index) { + return _source[index].usersInMillions; + }, + levels: [ + TreemapLevel( + padding: const EdgeInsets.all(1.5), + groupMapper: (int index) { + return _source[index].country; + }, + colorValueMapper: (TreemapTile tile) { + return tile.weight; + }, + ), + ], + colorMappers: _colorMappers, + legend: TreemapLegend.bar( + segmentPaintingStyle: TreemapLegendPaintingStyle.gradient, + ), + ), + ); + } +} + +class SocialMediaUsers { + const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); + + final String country; + final String socialMedia; + final double usersInMillions; +} + +{% endhighlight %} +{% endtabs %} + +![Bar legend gradient type](images/legend/bar-legend-gradient-type.png) + +## Bar legend appearance customization + +You can customize the legend items using the following properties. + +* **segmentSize** - Used to change the size of individual legend bar segments. When gradient paint style is applied, [`segmentSize`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/TreemapLegend.bar.html) argument in the constructor will update the whole legend bar. The default value of the [`segmentSize`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/TreemapLegend.bar.html) property is `Size(80.0, 12.0)`. +* **labelOverflow** - Used to remove or trim the legend labels based on the bar legend size.The default value of the [`labelOverflow`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/TreemapLegend.bar.html) argument in the constructor will be `TreemapLabelOverflow.visible`. +* **edgeLabelsPlacement** - Used to place the edge labels either inside or outside of the bar legend. The default value of the [`edgeLabelsPlacement`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/TreemapLegend.bar.html) argument in the constructor will be `TreemapLegendEdgeLabelsPlacement.inside`. +* **spacing** - Used to provide space between the each legend items. The default value of the [`spacing`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/TreemapLegend.bar.html) is `2.0`. This is not applicable for gradient legend. +* **direction** - Used to arrange the legend items in either horizontal or vertical direction. The default value of [`direction`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/TreemapLegend.bar.html) property is `horizontal`, if the value of the `position` property is `top`, `bottom` and defaults to `vertical`, if the value of the [`position`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/TreemapLegend.bar.html) property is `left` or `right`. +* **padding** - Used to set padding around the legend. The default value of the [`padding`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/TreemapLegend.bar.html) property is `EdgeInsets.all(10.0)`. + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +class BarLegendAppearanceExample extends StatefulWidget { + const BarLegendAppearanceExample({super.key}); + + @override + State createState() => + _BarLegendAppearanceExampleState(); +} + +class _BarLegendAppearanceExampleState extends State { + late List _source; + + @override + void initState() { + _source = [ + SocialMediaUsers('India', 'Facebook', 25.4), + SocialMediaUsers('USA', 'Instagram', 19.11), + SocialMediaUsers('Japan', 'Facebook', 13.3), + SocialMediaUsers('Germany', 'Instagram', 10.65), + SocialMediaUsers('United Kingdom', 'Instagram', 4.93), + SocialMediaUsers('France', 'Twitter', 7.54), + ]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: SizedBox( + height: 400, + width: 400, + child: SfTreemap( + dataCount: _source.length, + weightValueMapper: (int index) { + return _source[index].usersInMillions; + }, + levels: [ + TreemapLevel( + groupMapper: (int index) { + return _source[index].country; + }, + ), + ], + legend: TreemapLegend.bar( + segmentSize: const Size(60, 12), + labelOverflow: TreemapLabelOverflow.ellipsis, + edgeLabelsPlacement: TreemapLegendEdgeLabelsPlacement.center, + padding: const EdgeInsets.all(12), + direction: Axis.horizontal, + spacing: 5, + ), + ), + ), + ), + ); + } +} + +class SocialMediaUsers { + const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); + + final String country; + final String socialMedia; + final double usersInMillions; +} + +{% endhighlight %} +{% endtabs %} + +![Bar legend customization](images/legend/bar-legend-customization.png) + +## Bar legend labels placement + +You can place the labels either between the segments or on the segments using the [`labelsPlacement`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/TreemapLegend.bar.html) property. + +Labels placement for range color mapper + +The labels are positioned between the segments when setting range color mapper without setting color mapper [`TreemapColorMapper.name`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/name.html) property. The [`TreemapColorMapper.from`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/from.html) value of the first item is positioned at starting point of the first segment and the [`TreemapColorMapper.to`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/to.html) value of the first item is placed at the first segment end position. For other segments, the values of [`TreemapColorMapper.to`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/to.html) is positioned as label between the other segments. + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +class LabelPlacementRangeColorMapperExample extends StatefulWidget { + const LabelPlacementRangeColorMapperExample({super.key}); + + @override + State createState() => + _LabelPlacementRangeColorMapperExampleState(); +} + +class _LabelPlacementRangeColorMapperExampleState extends State { + late List _source; + late List _colorMappers; + + @override + void initState() { + _source = [ + SocialMediaUsers('India', 'Facebook', 25.4), + SocialMediaUsers('USA', 'Instagram', 19.11), + SocialMediaUsers('Japan', 'Facebook', 13.3), + SocialMediaUsers('Germany', 'Instagram', 10.65), + SocialMediaUsers('France', 'Twitter', 7.54), + SocialMediaUsers('UK', 'Instagram', 4.93), + ]; + + _colorMappers = [ + TreemapColorMapper.range(from: 0, to: 10, color: Colors.blue[200]!), + TreemapColorMapper.range(from: 10, to: 20, color: Colors.deepOrange), + TreemapColorMapper.range(from: 20, to: 30, color: Colors.blue[800]!), + ]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SfTreemap( + dataCount: _source.length, + weightValueMapper: (int index) { + return _source[index].usersInMillions; + }, + levels: [ + TreemapLevel( + padding: const EdgeInsets.all(1.5), + groupMapper: (int index) { + return _source[index].country; + }, + colorValueMapper: (TreemapTile tile) { + return tile.weight; + }, + ), + ], + colorMappers: _colorMappers, + legend: TreemapLegend.bar( + labelsPlacement: TreemapLegendLabelsPlacement.betweenItems, + segmentPaintingStyle: TreemapLegendPaintingStyle.gradient, + ), + ), + ); + } +} + +class SocialMediaUsers { + const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); + + final String country; + final String socialMedia; + final double usersInMillions; +} + +{% endhighlight %} +{% endtabs %} + +![Bar legend labels placement](images/legend/bar-legend-range-color-mapper-default.png) + +The labels are positioned between the segments when setting range color mapper along with setting color mapper [`TreemapColorMapper.name`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/name.html) property. The [`TreemapColorMapper.from`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/from.html) value of the first item is positioned at starting point of the first segment and the [`TreemapColorMapper.name`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/name.html) value of the first item is placed at the first segment end position. For Other segments, the value of [`TreemapColorMapper.name`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/name.html) is positioned as label between the segments. + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +class NamedRangeColorMapperExample extends StatefulWidget { + const NamedRangeColorMapperExample({super.key}); + + @override + State createState() => + _NamedRangeColorMapperExampleState(); +} + +class _NamedRangeColorMapperExampleState extends State { + late List _source; + late List _colorMappers; + + @override + void initState() { + _source = [ + SocialMediaUsers('India', 'Facebook', 25.4), + SocialMediaUsers('USA', 'Instagram', 19.11), + SocialMediaUsers('Japan', 'Facebook', 13.3), + SocialMediaUsers('Germany', 'Instagram', 10.65), + SocialMediaUsers('France', 'Twitter', 7.54), + SocialMediaUsers('UK', 'Instagram', 4.93), + ]; + + _colorMappers = [ + TreemapColorMapper.range( + from: 0, to: 10, color: Colors.blue[200]!, name: '<10'), + TreemapColorMapper.range( + from: 10, to: 20, color: Colors.deepOrange, name: '10 - 20'), + TreemapColorMapper.range( + from: 20, to: 30, color: Colors.blue[800]!, name: '20 - 30'), + ]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SfTreemap( + dataCount: _source.length, + weightValueMapper: (int index) { + return _source[index].usersInMillions; + }, + levels: [ + TreemapLevel( + padding: const EdgeInsets.all(1.5), + groupMapper: (int index) { + return _source[index].country; + }, + colorValueMapper: (TreemapTile tile) { + return tile.weight; + }, + ), + ], + colorMappers: _colorMappers, + legend: TreemapLegend.bar( + labelsPlacement: TreemapLegendLabelsPlacement.betweenItems, + segmentPaintingStyle: TreemapLegendPaintingStyle.gradient, + ), + ), + ); + } +} + +class SocialMediaUsers { + const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); + + final String country; + final String socialMedia; + final double usersInMillions; +} + +{% endhighlight %} +{% endtabs %} + +![Bar legend labels placement](images/legend/bar-legend-range-color-mapper-with-text.png) + +The labels are positioned at the center of the segments when setting the [`labelsPlacement`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/TreemapLegend.bar.html) property to [`TreemapLegendLabelsPlacement.onItem`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegendLabelsPlacement.html#onItem). The labels will based on the value of [`TreemapColorMapper.name`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/name.html) property. If the value of [`TreemapColorMapper.name`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/name.html) property is null, labels will be based on the values of [`TreemapColorMapper.from`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/from.html) and [`TreemapColorMapper.to`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapColorMapper/to.html) properties. + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +class BarLegendLabelPlacementExample extends StatefulWidget { + const BarLegendLabelPlacementExample({super.key}); + + @override + State createState() => + _BarLegendLabelPlacementExampleState(); +} + +class _BarLegendLabelPlacementExampleState extends State { + + late List _source; + late List _colorMappers; + + @override + void initState() { + _source = [ + SocialMediaUsers('India', 'Facebook', 25.4), + SocialMediaUsers('USA', 'Instagram', 19.11), + SocialMediaUsers('Japan', 'Facebook', 13.3), + SocialMediaUsers('Germany', 'Instagram', 10.65), + SocialMediaUsers('France', 'Twitter', 7.54), + SocialMediaUsers('UK', 'Instagram', 4.93), + ]; + + _colorMappers = [ + TreemapColorMapper.range( + from: 0, to: 10, color: Colors.blue[200]!, name: '<10'), + TreemapColorMapper.range( + from: 10, to: 20, color: Colors.deepOrange, name: '10 - 20'), + TreemapColorMapper.range( + from: 20, to: 30, color: Colors.blue[800]!, name: '20 - 30'), + ]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SfTreemap( + dataCount: _source.length, + weightValueMapper: (int index) { + return _source[index].usersInMillions; + }, + levels: [ + TreemapLevel( + padding: const EdgeInsets.all(1.5), + groupMapper: (int index) { + return _source[index].country; + }, + colorValueMapper: (TreemapTile tile) { + return tile.weight; + }, + ), + ], + colorMappers: _colorMappers, + legend: TreemapLegend.bar( + labelsPlacement: TreemapLegendLabelsPlacement.onItem, + edgeLabelsPlacement: TreemapLegendEdgeLabelsPlacement.center, + segmentPaintingStyle: TreemapLegendPaintingStyle.gradient, + ), + ), + ); + } +} + +class SocialMediaUsers { + const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); + + final String country; + final String socialMedia; + final double usersInMillions; +} + +{% endhighlight %} +{% endtabs %} + +![Bar legend labels placement](images/legend/bar-legend-range-color-mapper-onItem.png) + +Labels placement for equal color mapper + +The [`labelsPlacement`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/labelsPlacement.html) option is not applicable for the legend label applied with equal color mapper. By default, the labels are positioned at center of the segment. + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +class PointerCustomizationExample extends StatefulWidget { + const PointerCustomizationExample({super.key}); + + @override + State createState() => + _PointerCustomizationExampleState(); +} + +class _PointerCustomizationExampleState extends State { + + late List _source; + late List _colorMappers; + + @override + void initState() { + _source = [ + SocialMediaUsers('India', 'Facebook', 25.4), + SocialMediaUsers('USA', 'Instagram', 19.11), + SocialMediaUsers('Japan', 'Facebook', 13.3), + SocialMediaUsers('Germany', 'Instagram', 10.65), + SocialMediaUsers('France', 'Twitter', 7.54), + SocialMediaUsers('UK', 'Instagram', 4.93), + ]; + + _colorMappers = [ + TreemapColorMapper.value(value: 'Facebook', color: Colors.blue[200]!), + TreemapColorMapper.value(value: 'Instagram', color: Colors.deepOrange), + TreemapColorMapper.value(value: 'Twitter', color: Colors.blue[800]!), + ]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SfTreemap( + dataCount: _source.length, + weightValueMapper: (int index) { + return _source[index].usersInMillions; + }, + levels: [ + TreemapLevel( + padding: const EdgeInsets.all(2.5), + groupMapper: (int index) { + return _source[index].country; + }, + labelBuilder: (BuildContext context, TreemapTile tile) { + return Text(_source[tile.indices[0]].socialMedia); + }, + colorValueMapper: (TreemapTile tile) { + return _source[tile.indices[0]].socialMedia; + }, + ), + ], + colorMappers: _colorMappers, + legend: TreemapLegend.bar( + edgeLabelsPlacement: TreemapLegendEdgeLabelsPlacement.center, + segmentPaintingStyle: TreemapLegendPaintingStyle.gradient, + ), + ), + ); + } +} + +class SocialMediaUsers { + const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); + + final String country; + final String socialMedia; + final double usersInMillions; +} + +{% endhighlight %} +{% endtabs %} + +![Bar legend labels placement](images/legend/bar-legend-equal-color-mapper-default.png) + +## Show pointer + +You may show a pointer on the solid or gradient bar legend while hovering over a tile using the [`showPointerOnHover`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/showPointerOnHover.html) property. The default value of the [`showPointerOnHover`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/showPointerOnHover.html) property is `false`. + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +class ShowPointerExample extends StatefulWidget { + const ShowPointerExample({super.key}); + + @override + State createState() => _ShowPointerExampleState(); +} + +class _ShowPointerExampleState extends State { + late List _population; + late List _colorMappers; + + @override + void initState() { + _population = [ + IndianPopulation('Gujarat', 54612), + IndianPopulation('Bangalore', 473069), + IndianPopulation('Chennai', 210312), + IndianPopulation('Andra', 95419), + IndianPopulation('Kashmir', 80599), + IndianPopulation('Delhi', 39000), + IndianPopulation('Mumbai', 122897), + IndianPopulation('Kolkatta', 184135), + ]; + + _colorMappers = [ + TreemapColorMapper.range(from: 0, to: 10, color: Colors.blueGrey), + TreemapColorMapper.range(from: 10, to: 20, color: Colors.green), + TreemapColorMapper.range(from: 20, to: 30, color: Colors.lime), + TreemapColorMapper.range(from: 30, to: 50, color: Colors.teal), + ]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: SizedBox( + height: 400, + width: 400, + child: SfTreemap( + dataCount: _population.length, + weightValueMapper: (int index) => + _population[index].population.toDouble(), + colorMappers: _colorMappers, + legend: TreemapLegend.bar( + segmentPaintingStyle: TreemapLegendPaintingStyle.gradient, + showPointerOnHover: true, + ), + levels: [ + TreemapLevel( + groupMapper: (int index) { + return _population[index].state; + }, + colorValueMapper: (TreemapTile tile) { + return _population[tile.indices[0]].population / 10000; + }, + ) + ], + ), + ), + ), + ); + } +} + +class IndianPopulation { + const IndianPopulation(this.state, this.population); + + final String state; + final int population; +} + +{% endhighlight %} +{% endtabs %} + +![Bar legend pointer](images/legend/bar-legend-pointer.gif) + +## Pointer builder + +It returns a widget for the given value. + +The pointer is used to indicate the exact color of the hovering tile on the legend segment. + +The [`pointerBuilder`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/pointerBuilder.html) will be called when the user interacts with the tiles i.e., while tapping in touch devices and hovering in the mouse enabled devices. + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +class PointerBuilderExample extends StatefulWidget { + const PointerBuilderExample({super.key}); + + @override + State createState() => _PointerBuilderExampleState(); +} + +class _PointerBuilderExampleState extends State { + late List _population; + late List _colorMappers; + + @override + void initState() { + _population = [ + IndianPopulation('Gujarat', 54612), + IndianPopulation('Bangalore', 473069), + IndianPopulation('Chennai', 210312), + IndianPopulation('Andra', 95419), + IndianPopulation('Kashmir', 80599), + IndianPopulation('Delhi', 39000), + IndianPopulation('Mumbai', 122897), + IndianPopulation('Kolkatta', 184135), + ]; + + _colorMappers = [ + TreemapColorMapper.range(from: 0, to: 10, color: Colors.blueGrey), + TreemapColorMapper.range(from: 10, to: 20, color: Colors.green), + TreemapColorMapper.range(from: 20, to: 30, color: Colors.lime), + TreemapColorMapper.range(from: 30, to: 50, color: Colors.teal), + ]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: SizedBox( + height: 400, + width: 400, + child: SfTreemap( + dataCount: _population.length, + weightValueMapper: (int index) => + _population[index].population.toDouble(), + colorMappers: _colorMappers, + legend: TreemapLegend.bar( + segmentPaintingStyle: TreemapLegendPaintingStyle.gradient, + showPointerOnHover: true, + pointerBuilder: (BuildContext context, dynamic value) { + return const Icon(Icons.arrow_downward, size: 15); + }, + ), + levels: [ + TreemapLevel( + groupMapper: (int index) { + return _population[index].state; + }, + colorValueMapper: (TreemapTile tile) { + return _population[tile.indices[0]].population / 10000; + }, + ) + ], + ), + ), + ), + ); + } +} + +class IndianPopulation { + const IndianPopulation(this.state, this.population); + + final String state; + final int population; +} + +{% endhighlight %} +{% endtabs %} + +![Bar legend custom pointer](images/legend/bar-legend-custom-pointer.png) + +## Pointer customization + +You can customize the size and color of the pointer using the [`pointerSize`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/pointerSize.html) and [`pointerColor`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/pointerColor.html) properties. The default value of the [`pointerSize`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLegend/pointerSize.html) property is `Size(16, 12)`. + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +class PointerCustomizationExample extends StatefulWidget { + const PointerCustomizationExample({super.key}); + + @override + State createState() => + _PointerCustomizationExampleState(); +} + +class _PointerCustomizationExampleState extends State { + late List _population; + late List _colorMappers; + + @override + void initState() { + _population = [ + IndianPopulation('Gujarat', 54612), + IndianPopulation('Bangalore', 473069), + IndianPopulation('Chennai', 210312), + IndianPopulation('Andra', 95419), + IndianPopulation('Kashmir', 80599), + IndianPopulation('Delhi', 39000), + IndianPopulation('Mumbai', 122897), + IndianPopulation('Kolkatta', 184135), + ]; + + _colorMappers = [ + TreemapColorMapper.range(from: 0, to: 10, color: Colors.blueGrey), + TreemapColorMapper.range(from: 10, to: 20, color: Colors.green), + TreemapColorMapper.range(from: 20, to: 30, color: Colors.lime), + TreemapColorMapper.range(from: 30, to: 50, color: Colors.teal), + ]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: SizedBox( + height: 400, + width: 400, + child: SfTreemap( + dataCount: _population.length, + weightValueMapper: (int index) => + _population[index].population.toDouble(), + colorMappers: _colorMappers, + legend: TreemapLegend.bar( + segmentPaintingStyle: TreemapLegendPaintingStyle.gradient, + showPointerOnHover: true, + pointerSize: const Size(20, 20), + pointerColor: Colors.deepPurple, + ), + levels: [ + TreemapLevel( + groupMapper: (int index) { + return _population[index].state; + }, + colorValueMapper: (TreemapTile tile) { + return _population[tile.indices[0]].population / 10000; + }, + ) + ], + ), + ), + ), + ); + } +} + +class IndianPopulation { + const IndianPopulation(this.state, this.population); + + final String state; + final int population; +} + +{% endhighlight %} +{% endtabs %} + ![Bar legend pointer customization](images/legend/bar-legend-pointer-customization.png) \ No newline at end of file diff --git a/Flutter/treemap/levels.md b/Flutter/treemap/levels.md index bb8eafd52..4ce5bd495 100644 --- a/Flutter/treemap/levels.md +++ b/Flutter/treemap/levels.md @@ -1,406 +1,406 @@ ---- -layout: post -title: Flat and Hierarchical Levels in Flutter Treemap | Syncfusion® -description: Learn about flat and hierarchical levels in Syncfusion® Flutter Treemap (SfTreemap), including grouping, hierarchy visualization, and drilldown support. -platform: flutter -control: SfTreemap -documentation: ug ---- - -# Flat and Hierarchical Levels in Flutter Treemap (SfTreemap) - -The levels of the treemap can be categorized into the following two types: - -* Flat level. -* Hierarchical level. - -## Flat level - -There will be a tile for each unique value returned in the [`TreemapLevel.groupMapper`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/groupMapper.html) callback which is added to the [`levels`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/levels.html) collection property of [`SfTreemap`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap-class.html). - -### Squarified flat level example - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -class TreemapFlatLevelExample extends StatefulWidget { - const TreemapFlatLevelExample({super.key}); - - @override - State createState() => - _TreemapFlatLevelExampleState(); -} - -class _TreemapFlatLevelExampleState extends State { - late List _source; - - @override - void initState() { - _source = [ - const PopulationModel('Asia', 25.4), - const PopulationModel('South America', 19.11), - const PopulationModel('North America', 13.3), - const PopulationModel('Europe', 10.65), - const PopulationModel('Africa', 7.54), - const PopulationModel('Australia', 4.93), - ]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: Container( - height: 400, - width: 400, - child: SfTreemap( - dataCount: _source.length, - weightValueMapper: (int index) { - return _source[index].populationInMillions; - }, - levels: [ - TreemapLevel( - groupMapper: (int index) { - return _source[index].continent; - }, - ), - ], - ), - ), - ), - ); - } -} - -class PopulationModel { - const PopulationModel(this.continent, this.populationInMillions); - - final String continent; - final double populationInMillions; -} - -{% endhighlight %} -{% endtabs %} - -![Squarified flat level](images/levels/squarified-flat-level.png) - -N> -* Refer the [`TreemapLevel.colorValueMapper`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/colorValueMapper.html), for customizing the tile color. -* Refer the [`TreemapLevel.tooltipBuilder`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/tooltipBuilder.html), for adding and customizing the tooltip on the treemap. -* Refer the [`TreemapLevel.labelBuilder`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/labelBuilder.html), for adding and customizing the label on the tile. -* Refer the [`TreemapLevel.itemBuilder`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/itemBuilder.html), for adding and customizing the custom widget on the treemap. - -## Hierarchical level - -Hierarchical levels arrange the tiles in the form of nested rectangles. Each tile of the treemap is a rectangle which is filled with smaller rectangles representing sub-data. You can have more than one [`TreemapLevel`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel-class.html) in the [`levels`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/levels.html) collection to form a hierarchical treemap. - -The first level will work similarly to the flat level. From the next level in the [`levels`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/levels.html) collection, the items returned from the [`TreemapLevel.groupMapper`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/groupMapper.html) for the indices, will be placed inside the rectangle for the same indices returned from the [`TreemapLevel.groupMapper`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/groupMapper.html) in the previous level. This will go on until the last level in the [`levels`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/levels.html) collection. - -### Squarified hierarchical level example - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -class TreemapHierarchicalLevelExample extends StatefulWidget { - const TreemapHierarchicalLevelExample({super.key}); - - @override - State createState() => - _TreemapHierarchicalLevelExampleState(); -} - -class _TreemapHierarchicalLevelExampleState - extends State { - late List _source; - - @override - void initState() { - _source = [ - const JobVacancyModel(country: 'America', job: 'Sales', vacancy: 70), - const JobVacancyModel( - country: 'America', job: 'Technical', group: 'Testers', vacancy: 35), - const JobVacancyModel( - country: 'America', - job: 'Technical', - group: 'Developers', - role: 'Windows', - vacancy: 105), - const JobVacancyModel( - country: 'America', - job: 'Technical', - group: 'Developers', - role: 'Web', - vacancy: 40), - const JobVacancyModel(country: 'America', job: 'Management', vacancy: 40), - const JobVacancyModel(country: 'America', job: 'Accounts', vacancy: 60), - const JobVacancyModel( - country: 'India', job: 'Technical', group: 'Testers', vacancy: 25), - const JobVacancyModel( - country: 'India', - job: 'Technical', - group: 'Developers', - role: 'Windows', - vacancy: 155), - const JobVacancyModel( - country: 'India', - job: 'Technical', - group: 'Developers', - role: 'Web', - vacancy: 60), - const JobVacancyModel( - country: 'Germany', job: 'Sales', group: 'Executive', vacancy: 30), - const JobVacancyModel( - country: 'Germany', job: 'Sales', group: 'Analyst', vacancy: 40), - const JobVacancyModel( - country: 'UK', - job: 'Technical', - group: 'Developers', - role: 'Windows', - vacancy: 100), - const JobVacancyModel( - country: 'UK', - job: 'Technical', - group: 'Developers', - role: 'Web', - vacancy: 30), - const JobVacancyModel(country: 'UK', job: 'HR Executives', vacancy: 60), - const JobVacancyModel(country: 'UK', job: 'Marketing', vacancy: 40), - ]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: Container( - height: 400, - width: 400, - child: SfTreemap( - dataCount: _source.length, - weightValueMapper: (int index) { - return _source[index].vacancy; - }, - levels: [ - TreemapLevel(groupMapper: (int index) => _source[index].country), - TreemapLevel(groupMapper: (int index) => _source[index].job), - TreemapLevel(groupMapper: (int index) => _source[index].group), - TreemapLevel(groupMapper: (int index) => _source[index].role), - ], - ), - ), - ), - ); - } -} - -class JobVacancyModel { - const JobVacancyModel({ - required this.country, - required this.job, - this.group, - this.role, - required this.vacancy, - }); - - final String country; - final String job; - final String? group; - final String? role; - final double vacancy; -} - -{% endhighlight %} -{% endtabs %} - -![Squarified hierarchical level](images/levels/squarified-hierarchical-level.png) - -N> -* Refer the [`TreemapLevel.colorValueMapper`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/colorValueMapper.html), for customizing the tile color. -* Refer the [`TreemapLevel.tooltipBuilder`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/tooltipBuilder.html), for adding and customizing the tooltip on the treemap. -* Refer the [`TreemapLevel.labelBuilder`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/labelBuilder.html), for adding and customizing the label on the tile. -* Refer the [`TreemapLevel.itemBuilder`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/itemBuilder.html), for adding and customizing the custom widget on the treemap. - -## Appearance customization - -You can customize the levels using the following properties: - -* **Padding** - Specifies the gap between the groups. The default value of the [`TreemapLevel.padding`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/padding.html) property is `EdgeInsets.all(0.5)`. - -* **Color** - Specifies the background color for the group using the [`TreemapLevel.color`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/color.html) property. - -* **Border** - Specifies the border color, border width and border radius for the group using the [`TreemapLevel.border`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/border.html) property. - -### Squarified appearance example - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -class TreemapAppearanceExample extends StatefulWidget { - const TreemapAppearanceExample({super.key}); - - @override - State createState() => - _TreemapAppearanceExampleState(); -} - -class _TreemapAppearanceExampleState extends State { - late List _source; - - @override - void initState() { - _source = [ - const JobVacancyModel(country: 'America', job: 'Sales', vacancy: 70), - const JobVacancyModel( - country: 'America', job: 'Technical', group: 'Testers', vacancy: 35), - const JobVacancyModel( - country: 'America', - job: 'Technical', - group: 'Developers', - role: 'Windows', - vacancy: 105), - const JobVacancyModel( - country: 'America', - job: 'Technical', - group: 'Developers', - role: 'Web', - vacancy: 40), - const JobVacancyModel(country: 'America', job: 'Management', vacancy: 40), - const JobVacancyModel(country: 'America', job: 'Accounts', vacancy: 60), - const JobVacancyModel( - country: 'India', job: 'Technical', group: 'Testers', vacancy: 25), - const JobVacancyModel( - country: 'India', - job: 'Technical', - group: 'Developers', - role: 'Windows', - vacancy: 155), - const JobVacancyModel( - country: 'India', - job: 'Technical', - group: 'Developers', - role: 'Web', - vacancy: 60), - const JobVacancyModel( - country: 'Germany', job: 'Sales', group: 'Executive', vacancy: 30), - const JobVacancyModel( - country: 'Germany', job: 'Sales', group: 'Analyst', vacancy: 40), - const JobVacancyModel( - country: 'UK', - job: 'Technical', - group: 'Developers', - role: 'Windows', - vacancy: 100), - const JobVacancyModel( - country: 'UK', - job: 'Technical', - group: 'Developers', - role: 'Web', - vacancy: 30), - const JobVacancyModel(country: 'UK', job: 'HR Executives', vacancy: 60), - const JobVacancyModel(country: 'UK', job: 'Marketing', vacancy: 40), - ]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: Container( - height: 400, - width: 400, - child: SfTreemap( - dataCount: _source.length, - weightValueMapper: (int index) { - return _source[index].vacancy; - }, - levels: [ - TreemapLevel( - groupMapper: (int index) => _source[index].country, - color: Colors.blue, - border: RoundedRectangleBorder( - side: BorderSide( - color: Colors.blue, - width: 1, - ), - ), - padding: const EdgeInsets.all(2.5), - ), - TreemapLevel( - groupMapper: (int index) => _source[index].job, - color: Colors.orangeAccent, - border: RoundedRectangleBorder( - side: BorderSide( - color: Colors.orangeAccent, - width: 1, - ), - ), - padding: const EdgeInsets.all(2.5), - ), - TreemapLevel( - groupMapper: (int index) => _source[index].group, - color: Colors.green[300], - border: RoundedRectangleBorder( - side: BorderSide( - color: Colors.green, - width: 1, - ), - ), - padding: const EdgeInsets.all(5), - ), - TreemapLevel( - groupMapper: (int index) => _source[index].role, - color: Colors.pink[300], - border: RoundedRectangleBorder( - side: BorderSide( - color: Colors.pink, - width: 1, - ), - ), - padding: const EdgeInsets.all(5), - ), - ], - ), - ), - ), - ); - } -} - -class JobVacancyModel { - const JobVacancyModel({ - required this.country, - required this.job, - this.group, - this.role, - required this.vacancy, - }); - - final String country; - final String job; - final String? group; - final String? role; - final double vacancy; -} - -{% endhighlight %} -{% endtabs %} - -![Appearance customized levels](images/levels/levels-customization.png) - -N> -* Refer the [`TreemapLevel.colorValueMapper`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/colorValueMapper.html), for customizing the tile color. -* Refer the [`TreemapLevel.tooltipBuilder`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/tooltipBuilder.html), for adding and customizing the tooltip on the treemap. -* Refer the [`TreemapLevel.labelBuilder`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/labelBuilder.html), for adding and customizing the label on the tile. -* Refer the [`TreemapLevel.itemBuilder`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/itemBuilder.html), for adding and customizing the custom widget on the treemap. \ No newline at end of file +--- +layout: post +title: Flat and Hierarchical Levels in Flutter Treemap | Syncfusion® +description: Learn about flat and hierarchical levels in Syncfusion® Flutter Treemap (SfTreemap), including grouping, hierarchy visualization, and drilldown support. +platform: flutter +control: SfTreemap +documentation: ug +--- + +# Flat and Hierarchical Levels in Flutter Treemap (SfTreemap) + +The levels of the Flutter Treemap can be categorized into the following two types: + +* Flat level. +* Hierarchical level. + +## Flat level + +There will be a tile for each unique value returned in the [`TreemapLevel.groupMapper`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/groupMapper.html) callback which is added to the [`levels`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/levels.html) collection property of [`SfTreemap`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap-class.html). + +### Squarified flat level example + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +class TreemapFlatLevelExample extends StatefulWidget { + const TreemapFlatLevelExample({super.key}); + + @override + State createState() => + _TreemapFlatLevelExampleState(); +} + +class _TreemapFlatLevelExampleState extends State { + late List _source; + + @override + void initState() { + _source = [ + const PopulationModel('Asia', 25.4), + const PopulationModel('South America', 19.11), + const PopulationModel('North America', 13.3), + const PopulationModel('Europe', 10.65), + const PopulationModel('Africa', 7.54), + const PopulationModel('Australia', 4.93), + ]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Container( + height: 400, + width: 400, + child: SfTreemap( + dataCount: _source.length, + weightValueMapper: (int index) { + return _source[index].populationInMillions; + }, + levels: [ + TreemapLevel( + groupMapper: (int index) { + return _source[index].continent; + }, + ), + ], + ), + ), + ), + ); + } +} + +class PopulationModel { + const PopulationModel(this.continent, this.populationInMillions); + + final String continent; + final double populationInMillions; +} + +{% endhighlight %} +{% endtabs %} + +![Squarified flat level](images/levels/squarified-flat-level.png) + +N> +* Refer the [`TreemapLevel.colorValueMapper`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/colorValueMapper.html), for customizing the tile color. +* Refer the [`TreemapLevel.tooltipBuilder`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/tooltipBuilder.html), for adding and customizing the tooltip on the Flutter Treemap. +* Refer the [`TreemapLevel.labelBuilder`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/labelBuilder.html), for adding and customizing the label on the tile. +* Refer the [`TreemapLevel.itemBuilder`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/itemBuilder.html), for adding and customizing the custom widget on the treemap. + +## Hierarchical level + +Hierarchical levels arrange the tiles in the form of nested rectangles. Each tile of the Flutter Treemap is a rectangle which is filled with smaller rectangles representing sub-data. You can have more than one [`TreemapLevel`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel-class.html) in the [`levels`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/levels.html) collection to form a hierarchical treemap. + +The first level will work similarly to the flat level. From the next level in the [`levels`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/levels.html) collection, the items returned from the [`TreemapLevel.groupMapper`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/groupMapper.html) for the indices, will be placed inside the rectangle for the same indices returned from the [`TreemapLevel.groupMapper`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/groupMapper.html) in the previous level. This will go on until the last level in the [`levels`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/levels.html) collection. + +### Squarified hierarchical level example + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +class TreemapHierarchicalLevelExample extends StatefulWidget { + const TreemapHierarchicalLevelExample({super.key}); + + @override + State createState() => + _TreemapHierarchicalLevelExampleState(); +} + +class _TreemapHierarchicalLevelExampleState + extends State { + late List _source; + + @override + void initState() { + _source = [ + const JobVacancyModel(country: 'America', job: 'Sales', vacancy: 70), + const JobVacancyModel( + country: 'America', job: 'Technical', group: 'Testers', vacancy: 35), + const JobVacancyModel( + country: 'America', + job: 'Technical', + group: 'Developers', + role: 'Windows', + vacancy: 105), + const JobVacancyModel( + country: 'America', + job: 'Technical', + group: 'Developers', + role: 'Web', + vacancy: 40), + const JobVacancyModel(country: 'America', job: 'Management', vacancy: 40), + const JobVacancyModel(country: 'America', job: 'Accounts', vacancy: 60), + const JobVacancyModel( + country: 'India', job: 'Technical', group: 'Testers', vacancy: 25), + const JobVacancyModel( + country: 'India', + job: 'Technical', + group: 'Developers', + role: 'Windows', + vacancy: 155), + const JobVacancyModel( + country: 'India', + job: 'Technical', + group: 'Developers', + role: 'Web', + vacancy: 60), + const JobVacancyModel( + country: 'Germany', job: 'Sales', group: 'Executive', vacancy: 30), + const JobVacancyModel( + country: 'Germany', job: 'Sales', group: 'Analyst', vacancy: 40), + const JobVacancyModel( + country: 'UK', + job: 'Technical', + group: 'Developers', + role: 'Windows', + vacancy: 100), + const JobVacancyModel( + country: 'UK', + job: 'Technical', + group: 'Developers', + role: 'Web', + vacancy: 30), + const JobVacancyModel(country: 'UK', job: 'HR Executives', vacancy: 60), + const JobVacancyModel(country: 'UK', job: 'Marketing', vacancy: 40), + ]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Container( + height: 400, + width: 400, + child: SfTreemap( + dataCount: _source.length, + weightValueMapper: (int index) { + return _source[index].vacancy; + }, + levels: [ + TreemapLevel(groupMapper: (int index) => _source[index].country), + TreemapLevel(groupMapper: (int index) => _source[index].job), + TreemapLevel(groupMapper: (int index) => _source[index].group), + TreemapLevel(groupMapper: (int index) => _source[index].role), + ], + ), + ), + ), + ); + } +} + +class JobVacancyModel { + const JobVacancyModel({ + required this.country, + required this.job, + this.group, + this.role, + required this.vacancy, + }); + + final String country; + final String job; + final String? group; + final String? role; + final double vacancy; +} + +{% endhighlight %} +{% endtabs %} + +![Squarified hierarchical level](images/levels/squarified-hierarchical-level.png) + +N> +* Refer the [`TreemapLevel.colorValueMapper`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/colorValueMapper.html), for customizing the tile color. +* Refer the [`TreemapLevel.tooltipBuilder`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/tooltipBuilder.html), for adding and customizing the tooltip on the treemap. +* Refer the [`TreemapLevel.labelBuilder`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/labelBuilder.html), for adding and customizing the label on the tile. +* Refer the [`TreemapLevel.itemBuilder`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/itemBuilder.html), for adding and customizing the custom widget on the treemap. + +## Appearance customization + +You can customize the levels using the following properties: + +* **Padding** - Specifies the gap between the groups. The default value of the [`TreemapLevel.padding`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/padding.html) property is `EdgeInsets.all(0.5)`. + +* **Color** - Specifies the background color for the group using the [`TreemapLevel.color`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/color.html) property. + +* **Border** - Specifies the border color, border width and border radius for the group using the [`TreemapLevel.border`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/border.html) property. + +### Squarified appearance example + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +class TreemapAppearanceExample extends StatefulWidget { + const TreemapAppearanceExample({super.key}); + + @override + State createState() => + _TreemapAppearanceExampleState(); +} + +class _TreemapAppearanceExampleState extends State { + late List _source; + + @override + void initState() { + _source = [ + const JobVacancyModel(country: 'America', job: 'Sales', vacancy: 70), + const JobVacancyModel( + country: 'America', job: 'Technical', group: 'Testers', vacancy: 35), + const JobVacancyModel( + country: 'America', + job: 'Technical', + group: 'Developers', + role: 'Windows', + vacancy: 105), + const JobVacancyModel( + country: 'America', + job: 'Technical', + group: 'Developers', + role: 'Web', + vacancy: 40), + const JobVacancyModel(country: 'America', job: 'Management', vacancy: 40), + const JobVacancyModel(country: 'America', job: 'Accounts', vacancy: 60), + const JobVacancyModel( + country: 'India', job: 'Technical', group: 'Testers', vacancy: 25), + const JobVacancyModel( + country: 'India', + job: 'Technical', + group: 'Developers', + role: 'Windows', + vacancy: 155), + const JobVacancyModel( + country: 'India', + job: 'Technical', + group: 'Developers', + role: 'Web', + vacancy: 60), + const JobVacancyModel( + country: 'Germany', job: 'Sales', group: 'Executive', vacancy: 30), + const JobVacancyModel( + country: 'Germany', job: 'Sales', group: 'Analyst', vacancy: 40), + const JobVacancyModel( + country: 'UK', + job: 'Technical', + group: 'Developers', + role: 'Windows', + vacancy: 100), + const JobVacancyModel( + country: 'UK', + job: 'Technical', + group: 'Developers', + role: 'Web', + vacancy: 30), + const JobVacancyModel(country: 'UK', job: 'HR Executives', vacancy: 60), + const JobVacancyModel(country: 'UK', job: 'Marketing', vacancy: 40), + ]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Container( + height: 400, + width: 400, + child: SfTreemap( + dataCount: _source.length, + weightValueMapper: (int index) { + return _source[index].vacancy; + }, + levels: [ + TreemapLevel( + groupMapper: (int index) => _source[index].country, + color: Colors.blue, + border: RoundedRectangleBorder( + side: BorderSide( + color: Colors.blue, + width: 1, + ), + ), + padding: const EdgeInsets.all(2.5), + ), + TreemapLevel( + groupMapper: (int index) => _source[index].job, + color: Colors.orangeAccent, + border: RoundedRectangleBorder( + side: BorderSide( + color: Colors.orangeAccent, + width: 1, + ), + ), + padding: const EdgeInsets.all(2.5), + ), + TreemapLevel( + groupMapper: (int index) => _source[index].group, + color: Colors.green[300], + border: RoundedRectangleBorder( + side: BorderSide( + color: Colors.green, + width: 1, + ), + ), + padding: const EdgeInsets.all(5), + ), + TreemapLevel( + groupMapper: (int index) => _source[index].role, + color: Colors.pink[300], + border: RoundedRectangleBorder( + side: BorderSide( + color: Colors.pink, + width: 1, + ), + ), + padding: const EdgeInsets.all(5), + ), + ], + ), + ), + ), + ); + } +} + +class JobVacancyModel { + const JobVacancyModel({ + required this.country, + required this.job, + this.group, + this.role, + required this.vacancy, + }); + + final String country; + final String job; + final String? group; + final String? role; + final double vacancy; +} + +{% endhighlight %} +{% endtabs %} + +![Appearance customized levels](images/levels/levels-customization.png) + +N> +* Refer the [`TreemapLevel.colorValueMapper`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/colorValueMapper.html), for customizing the tile color. +* Refer the [`TreemapLevel.tooltipBuilder`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/tooltipBuilder.html), for adding and customizing the tooltip on the treemap. +* Refer the [`TreemapLevel.labelBuilder`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/labelBuilder.html), for adding and customizing the label on the tile. +* Refer the [`TreemapLevel.itemBuilder`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapLevel/itemBuilder.html), for adding and customizing the custom widget on the Flutter Treemap. \ No newline at end of file diff --git a/Flutter/treemap/overview.md b/Flutter/treemap/overview.md index 10c3a3c64..0e5a7f9db 100644 --- a/Flutter/treemap/overview.md +++ b/Flutter/treemap/overview.md @@ -1,34 +1,34 @@ ---- -layout: post -title: About Flutter Treemap Control | Syncfusion® -description: Learn about the Syncfusion® Flutter Treemap (SfTreemap), its features, hierarchical data visualization, and customization options. -platform: flutter -control: SfTreemap -documentation: ug ---- - -# About Flutter Treemap Control (SfTreemap) - -Syncfusion® Flutter Treemap is a powerful and customizable widget that allows you to create interactive treemaps in Flutter applications. It offers a rich feature set including selection, legends, labels, tooltips, color mapping, and more. - -![Flutter Treemap](images/overview/treemap_overview.png) - -## Features - -* **Layouts** - Utilize various layouts based on algorithms such as squarified, slice, and dice to represent both flat and hierarchically-structured data. - -* **Hierarchical support** - Besides flat structures, the treemap supports hierarchical data. Each tile is a rectangle filled with smaller rectangles representing sub-data. - -* **Labels** - Add widgets, like text widgets, to enhance the readability of individual tiles by providing brief descriptions on labels. - -* **Selection** - Select tiles to highlight them and perform specific functionalities like displaying a pop-up or navigating to a different page. - -* **Legend** - Use different legend styles to provide information on the treemap data clearly. - -* **Colors** - Customize tile colors on the treemap based on levels. Tile color can be set for specific values or ranges of values. - -* **Tooltip** - Use customizable tooltips to display additional information about the tiles on the treemap. - -* **Custom background widgets** - Add custom widgets, such as image widgets, as backgrounds of the tiles to enrich the UI and easily visualize the data type that a particular tile represents. - +--- +layout: post +title: About Flutter Treemap Control | Syncfusion® +description: Learn about the Syncfusion® Flutter Treemap (SfTreemap), its features, hierarchical data visualization, and customization options. +platform: flutter +control: SfTreemap +documentation: ug +--- + +# About Flutter Treemap Control (SfTreemap) + +Syncfusion® Flutter Treemap is a powerful and customizable widget that allows you to create interactive treemaps in Flutter applications. It offers a rich feature set including selection, legends, labels, tooltips, color mapping, and more. + +![Flutter Treemap](images/overview/treemap_overview.png) + +## Features + +* **Layouts** - Utilize various layouts based on algorithms such as squarified, slice, and dice to represent both flat and hierarchically-structured data. + +* **Hierarchical support** - Besides flat structures, the Flutter Treemap supports hierarchical data. Each tile is a rectangle filled with smaller rectangles representing sub-data. + +* **Labels** - Add widgets, like text widgets, to enhance the readability of individual tiles by providing brief descriptions on labels. + +* **Selection** - Select tiles to highlight them and perform specific functionalities like displaying a pop-up or navigating to a different page. + +* **Legend** - Use different legend styles to provide information on the Flutter Treemap data clearly. + +* **Colors** - Customize tile colors on the treemap based on levels. Tile color can be set for specific values or ranges of values. + +* **Tooltip** - Use customizable tooltips to display additional information about the tiles on the Flutter Treemap. + +* **Custom background widgets** - Add custom widgets, such as image widgets, as backgrounds of the tiles to enrich the UI and easily visualize the data type that a particular tile represents. + For step-by-step installation and setup instructions, see [Getting Started with Flutter Treemap](getting-started.md). \ No newline at end of file diff --git a/Flutter/treemap/right-to-left.md b/Flutter/treemap/right-to-left.md index 92268b59f..68d16e520 100644 --- a/Flutter/treemap/right-to-left.md +++ b/Flutter/treemap/right-to-left.md @@ -1,494 +1,494 @@ ---- -layout: post -title: Right-to-Left (RTL) in Flutter Treemap | Syncfusion® -description: Learn about right-to-left (RTL) support in Syncfusion® Flutter Treemap (SfTreemap), including layout customization, localization, and RTL rendering. -platform: flutter -control: SfTreemap -documentation: ug ---- - -# Right-to-Left (RTL) in Flutter Treemap (SfTreemap) - -## Enable RTL rendering - -Right-to-left rendering can be achieved in the following ways: - -### Wrapping the SfTreemap with the Directionality widget - -The treemap can be wrapped inside the [`Directionality`](https://api.flutter.dev/flutter/widgets/Directionality-class.html) widget, and you can set the [`textDirection`](https://api.flutter.dev/flutter/widgets/Directionality/textDirection.html) property to [`rtl`](https://api.flutter.dev/flutter/dart-ui/TextDirection.html#rtl). - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -void main() { - runApp(const RTLExample()); -} - -class RTLExample extends StatefulWidget { - const RTLExample({super.key}); - - @override - State createState() => _RTLExampleState(); -} - -class _RTLExampleState extends State { - late List _source; - - @override - void initState() { - _source = [ - PopulationModel('Asia', 25.4), - PopulationModel('Africa', 19.11), - PopulationModel('Europe', 13.3), - PopulationModel('North America', 10.65), - PopulationModel('South America', 7.54), - PopulationModel('Australia', 4.93), - ]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Column( - children: [ - Expanded( - child: Directionality( - textDirection: TextDirection.rtl, - child: SfTreemap( - dataCount: _source.length, - weightValueMapper: (int index) { - return _source[index].populationInMillions; - }, - levels: [ - TreemapLevel( - groupMapper: (int index) { - return _source[index].continent; - }, - labelBuilder: (BuildContext context, TreemapTile tile) { - return Padding( - padding: const EdgeInsets.all(5.0), - child: Text(tile.group), - ); - }, - ), - ], - ), - ), - ), - ], - ), - ), - ); - } -} - -class PopulationModel { - const PopulationModel(this.continent, this.populationInMillions); - - final String continent; - final double populationInMillions; -} - -{% endhighlight %} -{% endtabs %} - -### Changing the locale to RTL languages - -The treemap elements will render in the right-to-left direction if the locale belongs to RTL languages such as Arabic, Persian, Hebrew, Pashto, or Urdu. You can achieve this by specifying the MaterialApp properties such as [`localizationsDelegates`](https://api.flutter.dev/flutter/material/MaterialApp/localizationsDelegates.html), [`supportedLocales`](https://api.flutter.dev/flutter/material/MaterialApp/supportedLocales.html), [`locale`](https://api.flutter.dev/flutter/material/MaterialApp/locale.html), and adding the flutter_localizations package to your pubspec.yaml file. - -{% tabs %} -{% highlight yaml %} - -dependencies: - flutter_localizations: - sdk: flutter - -{% endhighlight %} -{% endtabs %} - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:flutter_localizations/flutter_localizations.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -void main() { - runApp(const RTLLocaleExample()); -} - -class RTLLocaleExample extends StatefulWidget { - const RTLLocaleExample({super.key}); - - @override - State createState() => _RTLLocaleExampleState(); -} - -class _RTLLocaleExampleState extends State { - late List _source; - - @override - void initState() { - _source = [ - PopulationModel('Asia', 25.4), - PopulationModel('Africa', 19.11), - PopulationModel('Europe', 13.3), - PopulationModel('North America', 10.65), - PopulationModel('South America', 7.54), - PopulationModel('Australia', 4.93), - ]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return MaterialApp( - localizationsDelegates: const [ - GlobalMaterialLocalizations.delegate, - GlobalWidgetsLocalizations.delegate, - ], - supportedLocales: const [Locale('fa', 'IR')], - locale: const Locale('fa', 'IR'), - home: Scaffold( - backgroundColor: Colors.white, - body: SfTreemap( - dataCount: _source.length, - weightValueMapper: (int index) { - return _source[index].populationInMillions; - }, - levels: [ - TreemapLevel( - groupMapper: (int index) { - return _source[index].continent; - }, - labelBuilder: (BuildContext context, TreemapTile tile) { - return Padding( - padding: const EdgeInsets.all(5.0), - child: Text(tile.group), - ); - }, - ), - ], - ), - ), - ); - } -} - -class PopulationModel { - const PopulationModel(this.continent, this.populationInMillions); - - final String continent; - final double populationInMillions; -} - -{% endhighlight %} -{% endtabs %} - -## RTL supported treemap elements - -### Labels - -Labels will be rendered from right to left direction. - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -void main() { - runApp(const RTLLabelsExample()); -} - -class RTLLabelsExample extends StatefulWidget { - const RTLLabelsExample({super.key}); - - @override - State createState() => _RTLLabelsExampleState(); -} - -class _RTLLabelsExampleState extends State { - late List _source; - - @override - void initState() { - _source = [ - PopulationModel('Asia', 25.4), - PopulationModel('Africa', 19.11), - PopulationModel('Europe', 13.3), - PopulationModel('North America', 10.65), - PopulationModel('South America', 7.54), - PopulationModel('Australia', 4.93), - ]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SizedBox( - height: 400, - width: 400, - child: Directionality( - textDirection: TextDirection.rtl, - child: SfTreemap( - dataCount: _source.length, - weightValueMapper: (int index) { - return _source[index].populationInMillions; - }, - levels: [ - TreemapLevel( - groupMapper: (int index) { - return _source[index].continent; - }, - labelBuilder: (BuildContext context, TreemapTile tile) { - return Padding( - padding: const EdgeInsets.all(5.0), - child: Text(tile.group), - ); - }, - ), - ], - ), - ), - ), - ), - ), - ); - } -} - -class PopulationModel { - const PopulationModel(this.continent, this.populationInMillions); - - final String continent; - final double populationInMillions; -} - -{% endhighlight %} -{% endtabs %} - -![RTL treemap labels support](images/right-to-left/treemap-label-rtl.png) - -### Legend - -Legend items will be rendered from right to left direction. It is applicable for both solid and bar type legend. - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -void main() { - runApp(const RTLLegendExample()); -} - -class RTLLegendExample extends StatefulWidget { - const RTLLegendExample({super.key}); - - @override - State createState() => _RTLLegendExampleState(); -} - -class _RTLLegendExampleState extends State { - late List _source; - - @override - void initState() { - _source = [ - PopulationModel('Asia', 25.4), - PopulationModel('Africa', 19.11), - PopulationModel('Europe', 13.3), - PopulationModel('North America', 10.65), - PopulationModel('South America', 7.54), - PopulationModel('Australia', 4.93), - ]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SizedBox( - height: 400, - width: 400, - child: Directionality( - textDirection: TextDirection.rtl, - child: SfTreemap( - dataCount: _source.length, - weightValueMapper: (int index) { - return _source[index].populationInMillions; - }, - levels: [ - TreemapLevel( - groupMapper: (int index) { - return _source[index].continent; - }, - labelBuilder: (BuildContext context, TreemapTile tile) { - return Padding( - padding: const EdgeInsets.all(5.0), - child: Text(tile.group), - ); - }, - ), - ], - legend: TreemapLegend(), - ), - ), - ), - ), - ), - ); - } -} - -class PopulationModel { - const PopulationModel(this.continent, this.populationInMillions); - - final String continent; - final double populationInMillions; -} - -{% endhighlight %} -{% endtabs %} - -![RTL treemap legend support](images/right-to-left/treemap-legend-rtl.png) - -### Tooltip - -Tooltip text will be rendered from right to left direction. - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -void main() { - runApp(const RTLTooltipExample()); -} - -class RTLTooltipExample extends StatefulWidget { - const RTLTooltipExample({super.key}); - - @override - State createState() => _RTLTooltipExampleState(); -} - -class _RTLTooltipExampleState extends State { - late List _source; - - @override - void initState() { - _source = [ - PopulationModel('Asia', 25.4), - PopulationModel('Africa', 19.11), - PopulationModel('Europe', 13.3), - PopulationModel('North America', 10.65), - PopulationModel('South America', 7.54), - PopulationModel('Australia', 4.93), - ]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return MaterialApp( - home: Scaffold( - body: Center( - child: SizedBox( - height: 400, - width: 400, - child: Directionality( - textDirection: TextDirection.rtl, - child: SfTreemap( - dataCount: _source.length, - weightValueMapper: (int index) { - return _source[index].populationInMillions; - }, - levels: [ - TreemapLevel( - groupMapper: (int index) { - return _source[index].continent; - }, - labelBuilder: (BuildContext context, TreemapTile tile) { - return Padding( - padding: const EdgeInsets.all(5.0), - child: Text(tile.group), - ); - }, - tooltipBuilder: (BuildContext context, TreemapTile tile) { - return Padding( - padding: const EdgeInsets.all(5), - child: Column( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Text( - 'Continent : ', - style: TextStyle(color: Colors.white), - ), - Text( - tile.group, - style: const TextStyle(color: Colors.white), - ), - ], - ), - Row( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Text( - 'Population : ', - style: TextStyle(color: Colors.white), - ), - Text( - tile.weight.toString(), - style: const TextStyle(color: Colors.white), - ), - ], - ), - ], - ), - ); - }, - ), - ], - ), - ), - ), - ), - ), - ); - } -} - -class PopulationModel { - const PopulationModel(this.continent, this.populationInMillions); - - final String continent; - final double populationInMillions; -} - -{% endhighlight %} -{% endtabs %} - +--- +layout: post +title: Right-to-Left (RTL) in Flutter Treemap | Syncfusion® +description: Learn about right-to-left (RTL) support in Syncfusion® Flutter Treemap (SfTreemap), including layout customization, localization, and RTL rendering. +platform: flutter +control: SfTreemap +documentation: ug +--- + +# Right-to-Left (RTL) in Flutter Treemap (SfTreemap) + +## Enable RTL rendering + +Right-to-left rendering can be achieved in the following ways: + +### Wrapping the SfTreemap with the Directionality widget + +The Flutter Treemap can be wrapped inside the [`Directionality`](https://api.flutter.dev/flutter/widgets/Directionality-class.html) widget, and you can set the [`textDirection`](https://api.flutter.dev/flutter/widgets/Directionality/textDirection.html) property to [`rtl`](https://api.flutter.dev/flutter/dart-ui/TextDirection.html#rtl). + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +void main() { + runApp(const RTLExample()); +} + +class RTLExample extends StatefulWidget { + const RTLExample({super.key}); + + @override + State createState() => _RTLExampleState(); +} + +class _RTLExampleState extends State { + late List _source; + + @override + void initState() { + _source = [ + PopulationModel('Asia', 25.4), + PopulationModel('Africa', 19.11), + PopulationModel('Europe', 13.3), + PopulationModel('North America', 10.65), + PopulationModel('South America', 7.54), + PopulationModel('Australia', 4.93), + ]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Column( + children: [ + Expanded( + child: Directionality( + textDirection: TextDirection.rtl, + child: SfTreemap( + dataCount: _source.length, + weightValueMapper: (int index) { + return _source[index].populationInMillions; + }, + levels: [ + TreemapLevel( + groupMapper: (int index) { + return _source[index].continent; + }, + labelBuilder: (BuildContext context, TreemapTile tile) { + return Padding( + padding: const EdgeInsets.all(5.0), + child: Text(tile.group), + ); + }, + ), + ], + ), + ), + ), + ], + ), + ), + ); + } +} + +class PopulationModel { + const PopulationModel(this.continent, this.populationInMillions); + + final String continent; + final double populationInMillions; +} + +{% endhighlight %} +{% endtabs %} + +### Changing the locale to RTL languages + +The elements of the Flutter Treemap will render in the right-to-left direction if the locale belongs to RTL languages such as Arabic, Persian, Hebrew, Pashto, or Urdu. You can achieve this by specifying the MaterialApp properties such as [`localizationsDelegates`](https://api.flutter.dev/flutter/material/MaterialApp/localizationsDelegates.html), [`supportedLocales`](https://api.flutter.dev/flutter/material/MaterialApp/supportedLocales.html), [`locale`](https://api.flutter.dev/flutter/material/MaterialApp/locale.html), and adding the flutter_localizations package to your pubspec.yaml file. + +{% tabs %} +{% highlight yaml %} + +dependencies: + flutter_localizations: + sdk: flutter + +{% endhighlight %} +{% endtabs %} + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:flutter_localizations/flutter_localizations.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +void main() { + runApp(const RTLLocaleExample()); +} + +class RTLLocaleExample extends StatefulWidget { + const RTLLocaleExample({super.key}); + + @override + State createState() => _RTLLocaleExampleState(); +} + +class _RTLLocaleExampleState extends State { + late List _source; + + @override + void initState() { + _source = [ + PopulationModel('Asia', 25.4), + PopulationModel('Africa', 19.11), + PopulationModel('Europe', 13.3), + PopulationModel('North America', 10.65), + PopulationModel('South America', 7.54), + PopulationModel('Australia', 4.93), + ]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + localizationsDelegates: const [ + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + ], + supportedLocales: const [Locale('fa', 'IR')], + locale: const Locale('fa', 'IR'), + home: Scaffold( + backgroundColor: Colors.white, + body: SfTreemap( + dataCount: _source.length, + weightValueMapper: (int index) { + return _source[index].populationInMillions; + }, + levels: [ + TreemapLevel( + groupMapper: (int index) { + return _source[index].continent; + }, + labelBuilder: (BuildContext context, TreemapTile tile) { + return Padding( + padding: const EdgeInsets.all(5.0), + child: Text(tile.group), + ); + }, + ), + ], + ), + ), + ); + } +} + +class PopulationModel { + const PopulationModel(this.continent, this.populationInMillions); + + final String continent; + final double populationInMillions; +} + +{% endhighlight %} +{% endtabs %} + +## RTL supported treemap elements + +### Labels + +Labels will be rendered from right to left direction. + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +void main() { + runApp(const RTLLabelsExample()); +} + +class RTLLabelsExample extends StatefulWidget { + const RTLLabelsExample({super.key}); + + @override + State createState() => _RTLLabelsExampleState(); +} + +class _RTLLabelsExampleState extends State { + late List _source; + + @override + void initState() { + _source = [ + PopulationModel('Asia', 25.4), + PopulationModel('Africa', 19.11), + PopulationModel('Europe', 13.3), + PopulationModel('North America', 10.65), + PopulationModel('South America', 7.54), + PopulationModel('Australia', 4.93), + ]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SizedBox( + height: 400, + width: 400, + child: Directionality( + textDirection: TextDirection.rtl, + child: SfTreemap( + dataCount: _source.length, + weightValueMapper: (int index) { + return _source[index].populationInMillions; + }, + levels: [ + TreemapLevel( + groupMapper: (int index) { + return _source[index].continent; + }, + labelBuilder: (BuildContext context, TreemapTile tile) { + return Padding( + padding: const EdgeInsets.all(5.0), + child: Text(tile.group), + ); + }, + ), + ], + ), + ), + ), + ), + ), + ); + } +} + +class PopulationModel { + const PopulationModel(this.continent, this.populationInMillions); + + final String continent; + final double populationInMillions; +} + +{% endhighlight %} +{% endtabs %} + +![RTL treemap labels support](images/right-to-left/treemap-label-rtl.png) + +### Legend + +Legend items will be rendered from right to left direction. It is applicable for both solid and bar type legend. + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +void main() { + runApp(const RTLLegendExample()); +} + +class RTLLegendExample extends StatefulWidget { + const RTLLegendExample({super.key}); + + @override + State createState() => _RTLLegendExampleState(); +} + +class _RTLLegendExampleState extends State { + late List _source; + + @override + void initState() { + _source = [ + PopulationModel('Asia', 25.4), + PopulationModel('Africa', 19.11), + PopulationModel('Europe', 13.3), + PopulationModel('North America', 10.65), + PopulationModel('South America', 7.54), + PopulationModel('Australia', 4.93), + ]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SizedBox( + height: 400, + width: 400, + child: Directionality( + textDirection: TextDirection.rtl, + child: SfTreemap( + dataCount: _source.length, + weightValueMapper: (int index) { + return _source[index].populationInMillions; + }, + levels: [ + TreemapLevel( + groupMapper: (int index) { + return _source[index].continent; + }, + labelBuilder: (BuildContext context, TreemapTile tile) { + return Padding( + padding: const EdgeInsets.all(5.0), + child: Text(tile.group), + ); + }, + ), + ], + legend: TreemapLegend(), + ), + ), + ), + ), + ), + ); + } +} + +class PopulationModel { + const PopulationModel(this.continent, this.populationInMillions); + + final String continent; + final double populationInMillions; +} + +{% endhighlight %} +{% endtabs %} + +![RTL treemap legend support](images/right-to-left/treemap-legend-rtl.png) + +### Tooltip + +Tooltip text will be rendered from right to left direction. + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +void main() { + runApp(const RTLTooltipExample()); +} + +class RTLTooltipExample extends StatefulWidget { + const RTLTooltipExample({super.key}); + + @override + State createState() => _RTLTooltipExampleState(); +} + +class _RTLTooltipExampleState extends State { + late List _source; + + @override + void initState() { + _source = [ + PopulationModel('Asia', 25.4), + PopulationModel('Africa', 19.11), + PopulationModel('Europe', 13.3), + PopulationModel('North America', 10.65), + PopulationModel('South America', 7.54), + PopulationModel('Australia', 4.93), + ]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + body: Center( + child: SizedBox( + height: 400, + width: 400, + child: Directionality( + textDirection: TextDirection.rtl, + child: SfTreemap( + dataCount: _source.length, + weightValueMapper: (int index) { + return _source[index].populationInMillions; + }, + levels: [ + TreemapLevel( + groupMapper: (int index) { + return _source[index].continent; + }, + labelBuilder: (BuildContext context, TreemapTile tile) { + return Padding( + padding: const EdgeInsets.all(5.0), + child: Text(tile.group), + ); + }, + tooltipBuilder: (BuildContext context, TreemapTile tile) { + return Padding( + padding: const EdgeInsets.all(5), + child: Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text( + 'Continent : ', + style: TextStyle(color: Colors.white), + ), + Text( + tile.group, + style: const TextStyle(color: Colors.white), + ), + ], + ), + Row( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text( + 'Population : ', + style: TextStyle(color: Colors.white), + ), + Text( + tile.weight.toString(), + style: const TextStyle(color: Colors.white), + ), + ], + ), + ], + ), + ); + }, + ), + ], + ), + ), + ), + ), + ), + ); + } +} + +class PopulationModel { + const PopulationModel(this.continent, this.populationInMillions); + + final String continent; + final double populationInMillions; +} + +{% endhighlight %} +{% endtabs %} + ![RTL treemap tooltip support](images/right-to-left/treemap-tooltip-rtl.png) \ No newline at end of file diff --git a/Flutter/treemap/selection.md b/Flutter/treemap/selection.md index 294de8634..24da67675 100644 --- a/Flutter/treemap/selection.md +++ b/Flutter/treemap/selection.md @@ -1,264 +1,264 @@ ---- -layout: post -title: Tile Selection in Flutter Treemap | Syncfusion® -description: Learn about tile selection in Syncfusion® Flutter Treemap (SfTreemap), including selection customization, interaction, highlighting, and styling options. -platform: flutter -control: SfTreemap -documentation: ug ---- - -# Tile Selection in Flutter Treemap (SfTreemap) - -You can select a tile to highlight that area on the treemap. You can use the callback to perform any action during tile selection. - -## Enable tile selection - -You can enable tile selection on a treemap using the [`SfTreemap.onSelectionChanged`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/onSelectionChanged.html) property. The descendant tiles of the selected tile are also selected along with the selected tile when doing selection for hierarchical level. - -The [`onSelectionChanged`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/onSelectionChanged.html) callback will be called with the details of the selected tile when the user is selecting a tile by tapping and you will be able to do any specific functionalities like showing pop-up or navigate to a different page. - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -class EnableSelectionExample extends StatefulWidget { - const EnableSelectionExample({super.key}); - - @override - State createState() => _EnableSelectionExampleState(); -} - -class _EnableSelectionExampleState extends State { - late List _source; - - @override - void initState() { - _source = [ - SocialMediaUsers('India', 'Facebook', 25.4), - SocialMediaUsers('USA', 'Instagram', 19.11), - SocialMediaUsers('Japan', 'Facebook', 13.3), - SocialMediaUsers('Germany', 'Instagram', 10.65), - SocialMediaUsers('France', 'Twitter', 7.54), - SocialMediaUsers('UK', 'Instagram', 4.93), - ]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: SizedBox( - height: 400, - width: 400, - child: SfTreemap( - dataCount: _source.length, - weightValueMapper: (int index) { - return _source[index].usersInMillions; - }, - onSelectionChanged: (TreemapTile tile) {}, - levels: [ - TreemapLevel( - groupMapper: (int index) { - return _source[index].country; - }, - ), - ], - ), - ), - ), - ); - } -} - -class SocialMediaUsers { - const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); - - final String country; - final String socialMedia; - final double usersInMillions; -} - -{% endhighlight %} -{% endtabs %} - -![Enable tile selection](images/selection/enable-tile-selection.gif) - -N> -* Refer the [`TreemapSelectionSettings`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapSelectionSettings-class.html), for customizing the selected tile's appearance. - -## Appearance customization - -You can customize the below appearance of the selected tile. - -* **Background color** - Change the background color of the selected tile using the [`TreemapSelectionSettings.color`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapSelectionSettings/color.html) property. -* **Border** - Change the border color, border stroke width using the [`BorderSide.color`](https://api.flutter.dev/flutter/painting/BorderSide/color.html) and [`BorderSide.width`](https://api.flutter.dev/flutter/painting/BorderSide/width.html) properties in the [`RoundedRectangleBorder`](https://api.flutter.dev/flutter/painting/RoundedRectangleBorder-class.html). Also apply rounded border using the [`RoundedRectangleBorder.borderRadius`](https://api.flutter.dev/flutter/painting/RoundedRectangleBorder/borderRadius.html) property. - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -class SelectionAppearanceExample extends StatefulWidget { - const SelectionAppearanceExample({super.key}); - - @override - State createState() => - _SelectionAppearanceExampleState(); -} - -class _SelectionAppearanceExampleState extends State { - late List _source; - - @override - void initState() { - _source = [ - SocialMediaUsers('India', 'Facebook', 25.4), - SocialMediaUsers('USA', 'Instagram', 19.11), - SocialMediaUsers('Japan', 'Facebook', 13.3), - SocialMediaUsers('Germany', 'Instagram', 10.65), - SocialMediaUsers('France', 'Twitter', 7.54), - SocialMediaUsers('UK', 'Instagram', 4.93), - ]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: SizedBox( - height: 400, - width: 400, - child: SfTreemap( - dataCount: _source.length, - weightValueMapper: (int index) { - return _source[index].usersInMillions; - }, - onSelectionChanged: (TreemapTile tile) {}, - selectionSettings: TreemapSelectionSettings( - color: Colors.orange, - border: RoundedRectangleBorder( - side: const BorderSide( - color: Colors.deepOrange, - width: 1, - ), - borderRadius: BorderRadius.circular(10), - ), - ), - levels: [ - TreemapLevel( - groupMapper: (int index) { - return _source[index].country; - }, - ), - ], - ), - ), - ), - ); - } -} - -class SocialMediaUsers { - const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); - - final String country; - final String socialMedia; - final double usersInMillions; -} - -{% endhighlight %} -{% endtabs %} - -![Selection customization](images/selection/selection-customization.gif) - -## Hovered tile customization - -You can customize the hovered tile color and border using the [`tileHoverColor`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/tileHoverColor.html) and [`tileHoverBorder`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/tileHoverBorder.html) properties. The default value of the [`tileHoverColor`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/tileHoverColor.html) is `Colors.transparent`. - -{% tabs %} -{% highlight dart %} - -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_treemap/treemap.dart'; - -class HoveredTileExample extends StatefulWidget { - const HoveredTileExample({super.key}); - - @override - State createState() => _HoveredTileExampleState(); -} - -class _HoveredTileExampleState extends State { - late List _source; - - @override - void initState() { - _source = [ - SocialMediaUsers('India', 'Facebook', 25.4), - SocialMediaUsers('USA', 'Instagram', 19.11), - SocialMediaUsers('Japan', 'Facebook', 13.3), - SocialMediaUsers('Germany', 'Instagram', 10.65), - SocialMediaUsers('France', 'Twitter', 7.54), - SocialMediaUsers('UK', 'Instagram', 4.93), - ]; - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: SizedBox( - height: 400, - width: 400, - child: SfTreemap( - dataCount: _source.length, - weightValueMapper: (int index) { - return _source[index].usersInMillions; - }, - levels: [ - TreemapLevel( - groupMapper: (int index) { - return _source[index].country; - }, - labelBuilder: (BuildContext context, TreemapTile tile) { - return Padding( - padding: const EdgeInsets.all(4), - child: Text(tile.group, style: const TextStyle(color: Colors.black)), - ); - }, - ), - ], - onSelectionChanged: (TreemapTile tile) {}, - tileHoverColor: Colors.tealAccent, - tileHoverBorder: RoundedRectangleBorder( - side: const BorderSide( - color: Colors.teal, - width: 1, - ), - borderRadius: BorderRadius.circular(10), - ), - ), - ), - ), - ); - } -} - -class SocialMediaUsers { - const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); - - final String country; - final String socialMedia; - final double usersInMillions; -} - -{% endhighlight %} -{% endtabs %} - +--- +layout: post +title: Tile Selection in Flutter Treemap | Syncfusion® +description: Learn about tile selection in Syncfusion® Flutter Treemap (SfTreemap), including selection customization, interaction, highlighting, and styling options. +platform: flutter +control: SfTreemap +documentation: ug +--- + +# Tile Selection in Flutter Treemap (SfTreemap) + +You can select a tile to highlight that area on the Flutter Treemap. You can use the callback to perform any action during tile selection. + +## Enable tile selection + +You can enable tile selection on a Flutter Treemap using the [`SfTreemap.onSelectionChanged`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/onSelectionChanged.html) property. The descendant tiles of the selected tile are also selected along with the selected tile when doing selection for hierarchical level. + +The [`onSelectionChanged`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/onSelectionChanged.html) callback will be called with the details of the selected tile when the user is selecting a tile by tapping and you will be able to do any specific functionalities like showing pop-up or navigate to a different page. + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +class EnableSelectionExample extends StatefulWidget { + const EnableSelectionExample({super.key}); + + @override + State createState() => _EnableSelectionExampleState(); +} + +class _EnableSelectionExampleState extends State { + late List _source; + + @override + void initState() { + _source = [ + SocialMediaUsers('India', 'Facebook', 25.4), + SocialMediaUsers('USA', 'Instagram', 19.11), + SocialMediaUsers('Japan', 'Facebook', 13.3), + SocialMediaUsers('Germany', 'Instagram', 10.65), + SocialMediaUsers('France', 'Twitter', 7.54), + SocialMediaUsers('UK', 'Instagram', 4.93), + ]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: SizedBox( + height: 400, + width: 400, + child: SfTreemap( + dataCount: _source.length, + weightValueMapper: (int index) { + return _source[index].usersInMillions; + }, + onSelectionChanged: (TreemapTile tile) {}, + levels: [ + TreemapLevel( + groupMapper: (int index) { + return _source[index].country; + }, + ), + ], + ), + ), + ), + ); + } +} + +class SocialMediaUsers { + const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); + + final String country; + final String socialMedia; + final double usersInMillions; +} + +{% endhighlight %} +{% endtabs %} + +![Enable tile selection](images/selection/enable-tile-selection.gif) + +N> +* Refer the [`TreemapSelectionSettings`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapSelectionSettings-class.html), for customizing the selected tile's appearance. + +## Appearance customization + +You can customize the below appearance of the selected tile. + +* **Background color** - Change the background color of the selected tile using the [`TreemapSelectionSettings.color`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/TreemapSelectionSettings/color.html) property. +* **Border** - Change the border color, border stroke width using the [`BorderSide.color`](https://api.flutter.dev/flutter/painting/BorderSide/color.html) and [`BorderSide.width`](https://api.flutter.dev/flutter/painting/BorderSide/width.html) properties in the [`RoundedRectangleBorder`](https://api.flutter.dev/flutter/painting/RoundedRectangleBorder-class.html). Also apply rounded border using the [`RoundedRectangleBorder.borderRadius`](https://api.flutter.dev/flutter/painting/RoundedRectangleBorder/borderRadius.html) property. + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +class SelectionAppearanceExample extends StatefulWidget { + const SelectionAppearanceExample({super.key}); + + @override + State createState() => + _SelectionAppearanceExampleState(); +} + +class _SelectionAppearanceExampleState extends State { + late List _source; + + @override + void initState() { + _source = [ + SocialMediaUsers('India', 'Facebook', 25.4), + SocialMediaUsers('USA', 'Instagram', 19.11), + SocialMediaUsers('Japan', 'Facebook', 13.3), + SocialMediaUsers('Germany', 'Instagram', 10.65), + SocialMediaUsers('France', 'Twitter', 7.54), + SocialMediaUsers('UK', 'Instagram', 4.93), + ]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: SizedBox( + height: 400, + width: 400, + child: SfTreemap( + dataCount: _source.length, + weightValueMapper: (int index) { + return _source[index].usersInMillions; + }, + onSelectionChanged: (TreemapTile tile) {}, + selectionSettings: TreemapSelectionSettings( + color: Colors.orange, + border: RoundedRectangleBorder( + side: const BorderSide( + color: Colors.deepOrange, + width: 1, + ), + borderRadius: BorderRadius.circular(10), + ), + ), + levels: [ + TreemapLevel( + groupMapper: (int index) { + return _source[index].country; + }, + ), + ], + ), + ), + ), + ); + } +} + +class SocialMediaUsers { + const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); + + final String country; + final String socialMedia; + final double usersInMillions; +} + +{% endhighlight %} +{% endtabs %} + +![Selection customization](images/selection/selection-customization.gif) + +## Hovered tile customization + +You can customize the hovered tile color and border using the [`tileHoverColor`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/tileHoverColor.html) and [`tileHoverBorder`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/tileHoverBorder.html) properties. The default value of the [`tileHoverColor`](https://pub.dev/documentation/syncfusion_flutter_treemap/latest/treemap/SfTreemap/tileHoverColor.html) is `Colors.transparent`. + +{% tabs %} +{% highlight dart %} + +import 'package:flutter/material.dart'; +import 'package:syncfusion_flutter_treemap/treemap.dart'; + +class HoveredTileExample extends StatefulWidget { + const HoveredTileExample({super.key}); + + @override + State createState() => _HoveredTileExampleState(); +} + +class _HoveredTileExampleState extends State { + late List _source; + + @override + void initState() { + _source = [ + SocialMediaUsers('India', 'Facebook', 25.4), + SocialMediaUsers('USA', 'Instagram', 19.11), + SocialMediaUsers('Japan', 'Facebook', 13.3), + SocialMediaUsers('Germany', 'Instagram', 10.65), + SocialMediaUsers('France', 'Twitter', 7.54), + SocialMediaUsers('UK', 'Instagram', 4.93), + ]; + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: SizedBox( + height: 400, + width: 400, + child: SfTreemap( + dataCount: _source.length, + weightValueMapper: (int index) { + return _source[index].usersInMillions; + }, + levels: [ + TreemapLevel( + groupMapper: (int index) { + return _source[index].country; + }, + labelBuilder: (BuildContext context, TreemapTile tile) { + return Padding( + padding: const EdgeInsets.all(4), + child: Text(tile.group, style: const TextStyle(color: Colors.black)), + ); + }, + ), + ], + onSelectionChanged: (TreemapTile tile) {}, + tileHoverColor: Colors.tealAccent, + tileHoverBorder: RoundedRectangleBorder( + side: const BorderSide( + color: Colors.teal, + width: 1, + ), + borderRadius: BorderRadius.circular(10), + ), + ), + ), + ), + ); + } +} + +class SocialMediaUsers { + const SocialMediaUsers(this.country, this.socialMedia, this.usersInMillions); + + final String country; + final String socialMedia; + final double usersInMillions; +} + +{% endhighlight %} +{% endtabs %} + ![Hover customization](images/selection/hover-customization.gif) \ No newline at end of file