Skip to content

Commit

Permalink
Merge branch 'master' into android-embedding-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
Norbert515 authored Apr 1, 2021
2 parents 2964e80 + cfe2235 commit 0698e5a
Show file tree
Hide file tree
Showing 9 changed files with 341 additions and 112 deletions.
3 changes: 3 additions & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ lib/generated_plugin_registrant.dart

# Symbolication related
app.*.symbols
.flutter-plugins
.flutter-plugins-dependencies
ios/Flutter/flutter_export_environment.sh

# Obfuscation related
app.*.map.json
10 changes: 5 additions & 5 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ class _MyHomePageState extends State<MyHomePage> {
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
RaisedButton(
ElevatedButton(
onPressed: DynamicTheme.of(context).toggleBrightness,
child: const Text('Toggle brightness'),
),
RaisedButton(
ElevatedButton(
onPressed: changeColor,
child: const Text('Change color'),
),
Expand All @@ -60,14 +60,14 @@ class _MyHomePageState extends State<MyHomePage> {
child: const Icon(Icons.add),
),
bottomNavigationBar: BottomNavigationBar(
items: <BottomNavigationBarItem>[
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.insert_drive_file),
title: const Text('Tab 1'),
label: 'Tab 1',
),
BottomNavigationBarItem(
icon: Icon(Icons.show_chart),
title: const Text('Tab 2'),
label: 'Tab 2',
),
],
),
Expand Down
175 changes: 153 additions & 22 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
@@ -1,34 +1,48 @@
# Generated by pub
# See https://www.dartlang.org/tools/pub/glossary#lockfile
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
version: "2.5.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
version: "2.1.0"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.2"
version: "1.2.0"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.11"
version: "1.15.0"
cupertino_icons:
dependency: "direct main"
description:
Expand All @@ -42,7 +56,28 @@ packages:
path: ".."
relative: true
source: path
version: "1.0.1"
version: "2.0.0-nullsafety"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
ffi:
dependency: transitive
description:
name: ffi
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
file:
dependency: transitive
description:
name: file
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.0"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -53,41 +88,123 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_web_plugins:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
js:
dependency: transitive
description:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.3"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.3+1"
version: "0.12.10"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6"
version: "1.3.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.2"
quiver:
version: "1.8.0"
path_provider_linux:
dependency: transitive
description:
name: quiver
name: path_provider_linux
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
path_provider_platform_interface:
dependency: transitive
description:
name: path_provider_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
path_provider_windows:
dependency: transitive
description:
name: path_provider_windows
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
platform:
dependency: transitive
description:
name: platform
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.0"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
process:
dependency: transitive
description:
name: process
url: "https://pub.dartlang.org"
source: hosted
version: "4.1.0"
shared_preferences:
dependency: transitive
description:
name: shared_preferences
url: "https://pub.dartlang.org"
source: hosted
version: "0.5.0"
version: "2.0.5"
shared_preferences_linux:
dependency: transitive
description:
name: shared_preferences_linux
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
shared_preferences_macos:
dependency: transitive
description:
name: shared_preferences_macos
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
shared_preferences_platform_interface:
dependency: transitive
description:
name: shared_preferences_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
shared_preferences_web:
dependency: transitive
description:
name: shared_preferences_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
shared_preferences_windows:
dependency: transitive
description:
name: shared_preferences_windows
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -99,56 +216,70 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.4.1"
version: "1.8.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.3"
version: "1.10.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.8"
version: "2.1.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
version: "1.1.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
version: "1.2.0"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.1"
version: "0.2.19"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6"
version: "1.3.0"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
version: "2.1.0"
win32:
dependency: transitive
description:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
xdg_directories:
dependency: transitive
description:
name: xdg_directories
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0"
sdks:
dart: ">=2.0.0 <3.0.0"
flutter: ">=0.1.4 <2.0.0"
dart: ">=2.12.0 <3.0.0"
flutter: ">=1.20.0"
22 changes: 10 additions & 12 deletions lib/dynamic_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@ import 'dart:async';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter/material.dart';

typedef ThemedWidgetBuilder = Widget Function(
BuildContext context, ThemeData data);
typedef ThemedWidgetBuilder = Widget Function(BuildContext context, ThemeData data);

typedef ThemeDataWithBrightnessBuilder = ThemeData Function(
Brightness brightness);
typedef ThemeDataWithBrightnessBuilder = ThemeData Function(Brightness brightness);

class DynamicTheme extends StatefulWidget {
const DynamicTheme({
Key key,
this.data,
this.themedWidgetBuilder,
Key? key,
required this.data,
required this.themedWidgetBuilder,
this.defaultBrightness = Brightness.light,
this.loadBrightnessOnStart = true,
}) : super(key: key);
Expand All @@ -37,17 +35,17 @@ class DynamicTheme extends StatefulWidget {
@override
DynamicThemeState createState() => DynamicThemeState();

static DynamicThemeState of(BuildContext context) {
return context.findAncestorStateOfType<State<DynamicTheme>>();
static DynamicThemeState? of(BuildContext context) {
return context.findAncestorStateOfType<DynamicThemeState>();
}
}

class DynamicThemeState extends State<DynamicTheme> {
ThemeData _themeData;
late ThemeData _themeData;

Brightness _brightness;
Brightness _brightness = Brightness.light;

bool _shouldLoadBrightness;
bool _shouldLoadBrightness = true;

static const String _sharedPreferencesKey = 'isDark';

Expand Down
Loading

0 comments on commit 0698e5a

Please sign in to comment.