-
Notifications
You must be signed in to change notification settings - Fork 455
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
5 changed files
with
272 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
# CHANGES | ||
|
||
## 2.0.8 | ||
|
||
- Adds back `DefaultSvgTheme`. | ||
|
||
## 2.0.7 | ||
|
||
- Fix broken `matchTextDirection`. | ||
|
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,42 @@ | ||
import 'package:flutter/widgets.dart'; | ||
|
||
import 'loaders.dart'; | ||
|
||
/// The SVG theme to apply to descendant [SvgPicture] widgets | ||
/// which don't have explicit theme values. | ||
class DefaultSvgTheme extends InheritedTheme { | ||
/// Creates a default SVG theme for the given subtree | ||
/// using the provided [theme]. | ||
const DefaultSvgTheme({ | ||
Key? key, | ||
required Widget child, | ||
required this.theme, | ||
}) : super(key: key, child: child); | ||
|
||
/// The SVG theme to apply. | ||
final SvgTheme theme; | ||
|
||
/// The closest instance of this class that encloses the given context. | ||
/// | ||
/// Typical usage is as follows: | ||
/// | ||
/// ```dart | ||
/// DefaultSvgTheme theme = DefaultSvgTheme.of(context); | ||
/// ``` | ||
static DefaultSvgTheme? of(BuildContext context) { | ||
return context.dependOnInheritedWidgetOfExactType<DefaultSvgTheme>(); | ||
} | ||
|
||
@override | ||
bool updateShouldNotify(DefaultSvgTheme oldWidget) { | ||
return theme != oldWidget.theme; | ||
} | ||
|
||
@override | ||
Widget wrap(BuildContext context, Widget child) { | ||
return DefaultSvgTheme( | ||
theme: theme, | ||
child: child, | ||
); | ||
} | ||
} |
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
Oops, something went wrong.