-
-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
127 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
library aves_utils; | ||
|
||
export 'src/change_notifier.dart'; | ||
export 'src/colors.dart'; | ||
export 'src/listenable.dart'; | ||
export 'src/optional_event_channel.dart'; | ||
export 'src/vector_utils.dart'; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
|
||
// `ChangeNotifier` wrapper to call `notify` without constraint | ||
class AChangeNotifier extends ChangeNotifier { | ||
void notify() { | ||
// why is this protected? | ||
super.notifyListeners(); | ||
} | ||
} | ||
|
||
// contrary to standard `ValueListenableBuilder`, this widget allows providing a null listenable | ||
class NullableValueListenableBuilder<T> extends StatefulWidget { | ||
final ValueListenable<T?>? valueListenable; | ||
final ValueWidgetBuilder<T?> builder; | ||
final Widget? child; | ||
|
||
const NullableValueListenableBuilder({ | ||
super.key, | ||
required this.valueListenable, | ||
required this.builder, | ||
this.child, | ||
}); | ||
|
||
@override | ||
State<NullableValueListenableBuilder> createState() => _NullableValueListenableBuilderState<T>(); | ||
} | ||
|
||
class _NullableValueListenableBuilderState<T> extends State<NullableValueListenableBuilder<T>> { | ||
ValueNotifier<T?>? _internalValueListenable; | ||
|
||
ValueListenable<T?> get _valueListenable { | ||
var listenable = widget.valueListenable; | ||
if (listenable == null) { | ||
_internalValueListenable ??= ValueNotifier(null); | ||
listenable = _internalValueListenable; | ||
} | ||
return listenable!; | ||
} | ||
|
||
@override | ||
void dispose() { | ||
_internalValueListenable?.dispose(); | ||
super.dispose(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return ValueListenableBuilder<T?>( | ||
valueListenable: _valueListenable, | ||
builder: widget.builder, | ||
child: widget.child, | ||
); | ||
} | ||
} |