diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index 3fc77b56a..0ebbbba64 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -95,7 +95,9 @@ jobs: flutter analyze dart analyze flutter pub global activate dartdoc - flutter pub global run dartdoc . --output talawa-mobile-docs --format md + flutter pub global run dartdoc . --output talawa-mobile-docs --format md --exclude=test/widget_tests/widgets/pinned_carousel_widget_test.dart, lib/widgets/pinned_carousel_widget.dart, lib/widgets/post_widget.dart, test/widget_tests/widgets/post_widget_test.dart + rm -rf talawa-mobile-docs/widgets_pinned_carousel_widget/CustomCarouselScrollerState/build.md + rm -rf talawa-mobile-docs/widgets_post_widget/PostContainerState/build.md - uses: actions/upload-artifact@v1 with: name: talawa-mobile-docs diff --git a/README.md b/README.md index 0b82e2b41..65b2324c7 100644 --- a/README.md +++ b/README.md @@ -2,14 +2,6 @@ [💬 Join the community on Slack](https://join.slack.com/t/thepalisadoes-dyb6419/shared_invite/zt-201rfrnid-TTDT4fPjdVEhnHGeYJ6uSw) -![talawa-logo-lite-200x200](https://raw.githubusercontent.com/PalisadoesFoundation/talawa/develop/assets/images/talawa-logo-lite-200x200.png) - - -[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) -[![GitHub stars](https://img.shields.io/github/stars/PalisadoesFoundation/talawa.svg?style=social&label=Star&maxAge=2592000)](https://github.com/PalisadoesFoundation/talawa) -[![GitHub forks](https://img.shields.io/github/forks/PalisadoesFoundation/talawa.svg?style=social&label=Fork&maxAge=2592000)](https://github.com/PalisadoesFoundation/talawa) -[![codecov](https://codecov.io/gh/PalisadoesFoundation/talawa/branch/develop/graph/badge.svg?token=3PJXIKRS1S)](https://codecov.io/gh/PalisadoesFoundation/talawa) - **Talawa** is a comprehensive platform that aims to revolutionize the way organizations manage and interact with their data and content. Talawa empowers administrators to access and manage content with ease through the Talawa Admin interface, ensuring that information remains up-to-date and accessible to the platform's members. With the Talawa API facilitating smooth communication between all parts of the platform, Talawa offers a cohesive and exceptional user experience for both administrators and members, making it a powerful tool for data management and content delivery seamlessly. Talawa is a modular open source project to manage group activities of both non-profit organizations and businesses. diff --git a/talawa-mobile-docs/widgets_pinned_carousel_widget/CustomCarouselScrollerState/build.md b/talawa-mobile-docs/widgets_pinned_carousel_widget/CustomCarouselScrollerState/build.md deleted file mode 100644 index e57b057bd..000000000 --- a/talawa-mobile-docs/widgets_pinned_carousel_widget/CustomCarouselScrollerState/build.md +++ /dev/null @@ -1,208 +0,0 @@ - - - -# build method - - - - - - - -- @[override](https://api.flutter.dev/flutter/dart-core/override-constant.html) - -[Widget](https://api.flutter.dev/flutter/widgets/Widget-class.html) build -([BuildContext](https://api.flutter.dev/flutter/widgets/BuildContext-class.html) context) - -_override_ - - - -

Describes the part of the user interface represented by this widget.

-

The framework calls this method in a number of different situations. For -example:

- -

This method can potentially be called in every frame and should not have -any side effects beyond building a widget.

-

The framework replaces the subtree below this widget with the widget -returned by this method, either by updating the existing subtree or by -removing the subtree and inflating a new subtree, depending on whether the -widget returned by this method can update the root of the existing -subtree, as determined by calling Widget.canUpdate.

-

Typically implementations return a newly created constellation of widgets -that are configured with information from this widget's constructor, the -given BuildContext, and the internal state of this State object.

-

The given BuildContext contains information about the location in the -tree at which this widget is being built. For example, the context -provides the set of inherited widgets for this location in the tree. The -BuildContext argument is always the same as the context property of -this State object and will remain the same for the lifetime of this -object. The BuildContext argument is provided redundantly here so that -this method matches the signature for a WidgetBuilder.

-

Design discussion

-

Why is the build method on State, and not StatefulWidget?

-

Putting a Widget build(BuildContext context) method on State rather -than putting a Widget build(BuildContext context, State state) method -on StatefulWidget gives developers more flexibility when subclassing -StatefulWidget.

-

For example, AnimatedWidget is a subclass of StatefulWidget that -introduces an abstract Widget build(BuildContext context) method for its -subclasses to implement. If StatefulWidget already had a build method -that took a State argument, AnimatedWidget would be forced to provide -its State object to subclasses even though its State object is an -internal implementation detail of AnimatedWidget.

-

Conceptually, StatelessWidget could also be implemented as a subclass of -StatefulWidget in a similar manner. If the build method were on -StatefulWidget rather than State, that would not be possible anymore.

-

Putting the build function on State rather than StatefulWidget also -helps avoid a category of bugs related to closures implicitly capturing -this. If you defined a closure in a build function on a -StatefulWidget, that closure would implicitly capture this, which is -the current widget instance, and would have the (immutable) fields of that -instance in scope:

-
// (this is not valid Flutter code)
-class MyButton extends StatefulWidgetX {
-  MyButton({super.key, required this.color});
-
-  final Color color;
-
-  @override
-  Widget build(BuildContext context, State state) {
-    return SpecialWidget(
-      handler: () { print('color: $color'); },
-    );
-  }
-}
-
-

For example, suppose the parent builds MyButton with color being blue, -the $color in the print function refers to blue, as expected. Now, -suppose the parent rebuilds MyButton with green. The closure created by -the first build still implicitly refers to the original widget and the -$color still prints blue even through the widget has been updated to -green; should that closure outlive its widget, it would print outdated -information.

-

In contrast, with the build function on the State object, closures -created during build implicitly capture the State instance instead of -the widget instance:

-
class MyButton extends StatefulWidget {
-  const MyButton({super.key, this.color = Colors.teal});
-
-  final Color color;
-  // ...
-}
-
-class MyButtonState extends State<MyButton> {
-  // ...
-  @override
-  Widget build(BuildContext context) {
-    return SpecialWidget(
-      handler: () { print('color: ${widget.color}'); },
-    );
-  }
-}
-
-

Now when the parent rebuilds MyButton with green, the closure created by -the first build still refers to State object, which is preserved across -rebuilds, but the framework has updated that State object's widget -property to refer to the new MyButton instance and ${widget.color} -prints green, as expected.

-

See also:

- - - - -## Implementation - -```dart -@override -Widget build(BuildContext context) { - // Stack is a widget that positions its children relative to the edges of its box. - return Stack( - children: [ - Padding( - padding: const EdgeInsets.symmetric(horizontal: 8.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.end, - children: [ - ListTile( - leading: const CircleAvatar( - radius: 15.0, - backgroundColor: Color(0xff737373), - ), - title: Text( - "${widget.pinnedPosts[pindex].creator!.firstName} ${widget.pinnedPosts[pindex].creator!.lastName}", - ), - ), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16.0), - child: Text( - widget.pinnedPosts[pindex].description!.length > 90 - ? "${widget.pinnedPosts[pindex].description!.substring(0, 90)}..." - : widget.pinnedPosts[pindex].description!, - style: Theme.of(context) - .textTheme - .bodyLarge! - .copyWith(color: const Color(0xFF737373)), - ), - ), - Padding( - padding: const EdgeInsets.symmetric( - horizontal: 16.0, - vertical: 10.0, - ), - child: Row( - children: [ - for (int i = 0; i < 4; i++) - Expanded( - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 5.0), - child: Divider( - thickness: 3.0, - color: pindex == i - ? Theme.of(context).colorScheme.primary - : Colors.grey, - ), - ), - ) - ], - ), - ) - ], - ), - ), - PageView( - scrollDirection: Axis.horizontal, - controller: controller, - onPageChanged: (index) { - setState(() { - pindex = index; - }); - }, - children: List.generate( - widget.pinnedPosts.length, - (index) => Container(), - ), - ), - ], - ); -} -``` - - - - - - - diff --git a/talawa-mobile-docs/widgets_post_widget/PostContainerState/build.md b/talawa-mobile-docs/widgets_post_widget/PostContainerState/build.md deleted file mode 100644 index 41c5dc686..000000000 --- a/talawa-mobile-docs/widgets_post_widget/PostContainerState/build.md +++ /dev/null @@ -1,207 +0,0 @@ - - - -# build method - - - - - - - -- @[override](https://api.flutter.dev/flutter/dart-core/override-constant.html) - -[Widget](https://api.flutter.dev/flutter/widgets/Widget-class.html) build -([BuildContext](https://api.flutter.dev/flutter/widgets/BuildContext-class.html) context) - -_override_ - - - -

Describes the part of the user interface represented by this widget.

-

The framework calls this method in a number of different situations. For -example:

- -

This method can potentially be called in every frame and should not have -any side effects beyond building a widget.

-

The framework replaces the subtree below this widget with the widget -returned by this method, either by updating the existing subtree or by -removing the subtree and inflating a new subtree, depending on whether the -widget returned by this method can update the root of the existing -subtree, as determined by calling Widget.canUpdate.

-

Typically implementations return a newly created constellation of widgets -that are configured with information from this widget's constructor, the -given BuildContext, and the internal state of this State object.

-

The given BuildContext contains information about the location in the -tree at which this widget is being built. For example, the context -provides the set of inherited widgets for this location in the tree. The -BuildContext argument is always the same as the context property of -this State object and will remain the same for the lifetime of this -object. The BuildContext argument is provided redundantly here so that -this method matches the signature for a WidgetBuilder.

-

Design discussion

-

Why is the build method on State, and not StatefulWidget?

-

Putting a Widget build(BuildContext context) method on State rather -than putting a Widget build(BuildContext context, State state) method -on StatefulWidget gives developers more flexibility when subclassing -StatefulWidget.

-

For example, AnimatedWidget is a subclass of StatefulWidget that -introduces an abstract Widget build(BuildContext context) method for its -subclasses to implement. If StatefulWidget already had a build method -that took a State argument, AnimatedWidget would be forced to provide -its State object to subclasses even though its State object is an -internal implementation detail of AnimatedWidget.

-

Conceptually, StatelessWidget could also be implemented as a subclass of -StatefulWidget in a similar manner. If the build method were on -StatefulWidget rather than State, that would not be possible anymore.

-

Putting the build function on State rather than StatefulWidget also -helps avoid a category of bugs related to closures implicitly capturing -this. If you defined a closure in a build function on a -StatefulWidget, that closure would implicitly capture this, which is -the current widget instance, and would have the (immutable) fields of that -instance in scope:

-
// (this is not valid Flutter code)
-class MyButton extends StatefulWidgetX {
-  MyButton({super.key, required this.color});
-
-  final Color color;
-
-  @override
-  Widget build(BuildContext context, State state) {
-    return SpecialWidget(
-      handler: () { print('color: $color'); },
-    );
-  }
-}
-
-

For example, suppose the parent builds MyButton with color being blue, -the $color in the print function refers to blue, as expected. Now, -suppose the parent rebuilds MyButton with green. The closure created by -the first build still implicitly refers to the original widget and the -$color still prints blue even through the widget has been updated to -green; should that closure outlive its widget, it would print outdated -information.

-

In contrast, with the build function on the State object, closures -created during build implicitly capture the State instance instead of -the widget instance:

-
class MyButton extends StatefulWidget {
-  const MyButton({super.key, this.color = Colors.teal});
-
-  final Color color;
-  // ...
-}
-
-class MyButtonState extends State<MyButton> {
-  // ...
-  @override
-  Widget build(BuildContext context) {
-    return SpecialWidget(
-      handler: () { print('color: ${widget.color}'); },
-    );
-  }
-}
-
-

Now when the parent rebuilds MyButton with green, the closure created by -the first build still refers to State object, which is preserved across -rebuilds, but the framework has updated that State object's widget -property to refer to the new MyButton instance and ${widget.color} -prints green, as expected.

-

See also:

- - - - -## Implementation - -```dart -@override -Widget build(BuildContext context) { - return VisibilityDetector( - key: Key(widget.id), - onVisibilityChanged: (info) { - info.visibleFraction > 0.5 ? inView = true : inView = false; - if (mounted) setState(() {}); - }, - child: Stack( - children: [ - PageView( - scrollDirection: Axis.horizontal, - controller: controller, - onPageChanged: (index) { - setState(() { - pindex = index; - inView = pindex == 0; - }); - }, - children: List.generate( - 4, - (index) => index == 0 - ? Center( - child: VideoWidget( - url: - 'https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4', - play: inView, - ), - ) - : const Image( - image: NetworkImage( - 'https://flutter.github.io/assets-for-api-docs/assets/widgets/owl.jpg', - ), - ), - ), - ), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 8.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Padding( - padding: const EdgeInsets.symmetric( - horizontal: 100.0, - vertical: 10.0, - ), - child: Row( - children: [ - for (int i = 0; i < 4; i++) - Expanded( - child: Padding( - padding: - const EdgeInsets.symmetric(horizontal: 5.0), - child: Divider( - thickness: 3.0, - color: pindex == i - ? Theme.of(context).colorScheme.primary - : Colors.grey, - ), - ), - ) - ], - ), - ) - ], - ), - ), - ], - ), - ); -} -``` - - - - - - -