Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ValueListenableBuilder widget #324

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
79 changes: 79 additions & 0 deletions lib/routes/valueListenableBuilder.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import 'package:fludget/Models/codeString.dart';
import 'package:flutter/material.dart';

class ValueListenableBuilderImplementation extends StatelessWidget {
const ValueListenableBuilderImplementation({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
final ValueNotifier<int> _counter = ValueNotifier<int>(0);
return MaterialApp(
theme: Theme.of(context),
home: Scaffold(
appBar: AppBar(
title: const Text('ValueListenableBuilder'),
),
body: Center(
child: ValueListenableBuilder(
valueListenable: _counter,
builder: (context, value, child) {
return Text(
'Value: $value',
style: const TextStyle(fontSize: 20),
);
},
),
),
floatingActionButton: FloatingActionButton(
child: const Icon(Icons.plus_one),
onPressed: () => _counter.value += 1,
),
),
);
}
}

class ValueListenableBuilderDescription extends StatelessWidget {
const ValueListenableBuilderDescription({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(top: 22.0, left: 15, right: 15),
child: Text(
'A widget whose content stays synced with a ValueListenable.',
style: TextStyle(fontSize: 20),
),
);
}
}

class ValueListenableBuilderCode extends CodeString {
const ValueListenableBuilderCode();

@override
String buildCodeString() {
return """ValueListenableBuilderCode(
Scaffold(
appBar: AppBar(
title: const Text('ValueListenableBuilder'),
),
body: Center(
child: ValueListenableBuilder(
valueListenable: _counter,
builder: (context, value, child) {
return Text(
'Value: \$value',
style: const TextStyle(fontSize: 20),
);
},
),
),
floatingActionButton: FloatingActionButton(
child: const Icon(Icons.plus_one),
onPressed: () => _counter.value += 1,
),
),
""";
}
}
11 changes: 11 additions & 0 deletions lib/widgetList.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ import 'package:fludget/routes/timePickerDialog.dart';
import 'package:fludget/routes/cupertino_text_field.dart';
import 'package:fludget/routes/transform.dart';
import 'package:fludget/routes/togglebutton.dart';
import 'package:fludget/routes/valueListenableBuilder.dart';
import 'package:fludget/routes/visibilityWidget.dart';
import 'package:fludget/routes/wrap.dart';
import 'package:fludget/routes/tooltip.dart';
Expand Down Expand Up @@ -1116,4 +1117,14 @@ const List<WidgetModel> widgets = [
category: [WidgetCategory.Animation],
codeString: AnimatedSwitcherCode(),
),
WidgetModel(
name: "ValueListenableBuilder",
link:
"https://api.flutter.dev/flutter/widgets/ValueListenableBuilder-class.html",
subtitle: "A widget whose content stays synced with a ValueListenable.",
implementation: ValueListenableBuilderImplementation(),
description: ValueListenableBuilderDescription(),
category: [WidgetCategory.Interaction, WidgetCategory.Async],
codeString: ValueListenableBuilderCode(),
),
];
8 changes: 8 additions & 0 deletions windows/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ list(APPEND FLUTTER_PLUGIN_LIST
url_launcher_windows
)

list(APPEND FLUTTER_FFI_PLUGIN_LIST
)

set(PLUGIN_BUNDLED_LIBRARIES)

foreach(plugin ${FLUTTER_PLUGIN_LIST})
Expand All @@ -14,3 +17,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST})
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
endforeach(plugin)

foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
endforeach(ffi_plugin)