Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ part 'mirai_default_tab_controller.g.dart';
@freezed
class MiraiDefaultTabController with _$MiraiDefaultTabController {
const factory MiraiDefaultTabController({
required Map<String, dynamic> child,
required int length,
@Default(0) int initialIndex,
required Map<String, dynamic> child,
}) = _MiraiDefaultTabController;

factory MiraiDefaultTabController.fromJson(Map<String, dynamic> json) =>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class MiraiDefaultTabControllerParser
Widget parse(BuildContext context, MiraiDefaultTabController model) {
return DefaultTabController(
length: model.length,
initialIndex: model.initialIndex,
child: Mirai.fromJson(model.child, context) ?? const SizedBox(),
);
}
Expand Down
42 changes: 42 additions & 0 deletions website/docs/widgets/default_tab_controller.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# DefaultTabController

The Mirai DefaultTabController allows you to build a Flutter DefaultTabController widget using JSON.
To know more about the DefaultTabController widget in Flutter, refer to the [official documentation](https://api.flutter.dev/flutter/material/DefaultTabController-class.html).

## Properties

| Property | Type | Description |
|--------------|-------------------------|-----------------------------------------------------------------------------|
| length | `int` | The number of tabs. |
| initialIndex | `int` | The initial index of the selected tab. Defaults to `0`. |
| child | `Map<String, dynamic>` | The widget below this widget in the tree. |

## Example JSON

```json
{
"type": "defaultTabController",
"length": 3,
"child": {
"type": "column",
"children": [
{
"type": "tabBar",
"tabs": [
{"type": "tab", "text": "Tab 1"},
{"type": "tab", "text": "Tab 2"},
{"type": "tab", "text": "Tab 3"}
]
},
{
"type": "tabBarView",
"children": [
{"type": "text", "data": "Content for Tab 1"},
{"type": "text", "data": "Content for Tab 2"},
{"type": "text", "data": "Content for Tab 3"}
]
}
]
}
}
```
Loading