Skip to content

Commit

Permalink
Merge pull request #30 from AndriiHarashchak/master
Browse files Browse the repository at this point in the history
Minor changes and improvements
  • Loading branch information
tashiwangdi committed Jun 1, 2022
2 parents 60c178c + a2d8c76 commit c908cbb
Show file tree
Hide file tree
Showing 34 changed files with 1,177 additions and 45 deletions.
24 changes: 22 additions & 2 deletions example/.metadata
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.
# This file should be version controlled.

version:
revision: 20e59316b8b8474554b38493b8ca888794b0234a
revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
channel: stable

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
- platform: windows
create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268
base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
29 changes: 29 additions & 0 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
17 changes: 9 additions & 8 deletions example/lib/fake_chart_series.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@ class FakeChartSeries {

Map<DateTime, double> createLine2() {
Map<DateTime, double> data = {};
data[DateTime.now().subtract(Duration(minutes: 40))] = 13.0;
data[DateTime.now().subtract(Duration(minutes: 30))] = 24.0;
data[DateTime.now().subtract(Duration(minutes: 22))] = 39.0;
data[DateTime.now().subtract(Duration(minutes: 20))] = 29.0;
data[DateTime.now().subtract(Duration(minutes: 15))] = 27.0;
data[DateTime.now().subtract(Duration(minutes: 12))] = 9.0;
data[DateTime.now().subtract(Duration(minutes: 5))] = 35.0;
var date = DateTime.now().subtract(Duration(minutes: 40));
data[date.subtract(Duration(minutes: 40))] = 13.0;
data[date.subtract(Duration(minutes: 30))] = 24.0;
data[date.subtract(Duration(minutes: 22))] = 39.0;
data[date.subtract(Duration(minutes: 20))] = 29.0;
data[date.subtract(Duration(minutes: 15))] = 27.0;
data[date.subtract(Duration(minutes: 12))] = 9.0;
data[date.subtract(Duration(minutes: 5))] = 35.0;
return data;
}

Expand All @@ -63,7 +64,7 @@ class FakeChartSeries {
Map<DateTime, double> createLine3() {
Map<DateTime, double> data = {};
data[DateTime.now().subtract(Duration(days: 6))] = 1100.0;
data[DateTime.now().subtract(Duration(days: 5))] = 2233.0;
data[DateTime.now().subtract(Duration(days: 4))] = 2233.0;
data[DateTime.now().subtract(Duration(days: 4))] = 3744.0;
data[DateTime.now().subtract(Duration(days: 3))] = 3100.0;
data[DateTime.now().subtract(Duration(days: 2))] = 2900.0;
Expand Down
49 changes: 34 additions & 15 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,24 @@ class _MyHomePageState extends State<MyHomePage> with FakeChartSeries {
LineChart chart;

if (chartIndex == 0) {
chart = LineChart.fromDateTimeMaps([line1, line2], [Colors.green, Colors.blue], ['C', 'C'], tapTextFontWeight: FontWeight.w400);
chart = LineChart.fromDateTimeMaps(
[line1, line2], [Colors.green, Colors.blue], ['C', 'C'],
tapTextFontWeight: FontWeight.w400);
} else if (chartIndex == 1) {
chart = LineChart.fromDateTimeMaps([createLineAlmostSaveValues()], [Colors.green], ['C'], tapTextFontWeight: FontWeight.w400);
chart = LineChart.fromDateTimeMaps(
[createLineAlmostSaveValues()], [Colors.green], ['C'],
tapTextFontWeight: FontWeight.w400);
} else {
chart = AreaLineChart.fromDateTimeMaps([line1], [Colors.red.shade900], ['C'],
chart = AreaLineChart.fromDateTimeMaps(
[line1], [Colors.red.shade900], ['C'],
yAxisName: "Temperature",
gradients: [Pair(Colors.yellow.shade400, Colors.red.shade700)]);
}
final ButtonStyle flatButtonStyle = TextButton.styleFrom(
shape: RoundedRectangleBorder(
side: BorderSide(color: Colors.black45),
borderRadius: BorderRadius.all(Radius.circular(3))),
);

return Scaffold(
appBar: AppBar(
Expand All @@ -64,33 +75,41 @@ class _MyHomePageState extends State<MyHomePage> with FakeChartSeries {
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
FlatButton(
shape: RoundedRectangleBorder(
side: BorderSide(color: Colors.black45), borderRadius: BorderRadius.all(Radius.circular(3))),
TextButton(
style: flatButtonStyle,
child: Text(
'LineChart',
style: TextStyle(color: chartIndex == 0 ? Colors.black : Colors.black12),
style: TextStyle(
color: chartIndex == 0
? Colors.black
: Colors.black12),
),
onPressed: () {
setState(() {
chartIndex = 0;
});
},
),
FlatButton(
shape: RoundedRectangleBorder(
side: BorderSide(color: Colors.black45), borderRadius: BorderRadius.all(Radius.circular(3))),
child: Text('LineChart2', style: TextStyle(color: chartIndex == 1 ? Colors.black : Colors.black12)),
TextButton(
style: flatButtonStyle,
child: Text('LineChart2',
style: TextStyle(
color: chartIndex == 1
? Colors.black
: Colors.black12)),
onPressed: () {
setState(() {
chartIndex = 1;
});
},
),
FlatButton(
shape: RoundedRectangleBorder(
side: BorderSide(color: Colors.black45), borderRadius: BorderRadius.all(Radius.circular(3))),
child: Text('AreaChart', style: TextStyle(color: chartIndex == 2 ? Colors.black : Colors.black12)),
TextButton(
style: flatButtonStyle,
child: Text('AreaChart',
style: TextStyle(
color: chartIndex == 2
? Colors.black
: Colors.black12)),
onPressed: () {
setState(() {
chartIndex = 2;
Expand Down
30 changes: 30 additions & 0 deletions example/test/widget_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility in the flutter_test package. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import 'package:example/main.dart';

void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());

// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);

// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();

// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}
17 changes: 17 additions & 0 deletions example/windows/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
flutter/ephemeral/

# Visual Studio user-specific files.
*.suo
*.user
*.userosscache
*.sln.docstates

# Visual Studio build-related files.
x64/
x86/

# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
101 changes: 101 additions & 0 deletions example/windows/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Project-level configuration.
cmake_minimum_required(VERSION 3.14)
project(example LANGUAGES CXX)

# The name of the executable created for the application. Change this to change
# the on-disk name of your application.
set(BINARY_NAME "example")

# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
# versions of CMake.
cmake_policy(SET CMP0063 NEW)

# Define build configuration option.
get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(IS_MULTICONFIG)
set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release"
CACHE STRING "" FORCE)
else()
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Debug" CACHE
STRING "Flutter build mode" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Profile" "Release")
endif()
endif()
# Define settings for the Profile build mode.
set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}")
set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}")

# Use Unicode for all projects.
add_definitions(-DUNICODE -D_UNICODE)

# Compilation settings that should be applied to most targets.
#
# Be cautious about adding new options here, as plugins use this function by
# default. In most cases, you should add new options to specific targets instead
# of modifying this function.
function(APPLY_STANDARD_SETTINGS TARGET)
target_compile_features(${TARGET} PUBLIC cxx_std_17)
target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100")
target_compile_options(${TARGET} PRIVATE /EHsc)
target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0")
target_compile_definitions(${TARGET} PRIVATE "$<$<CONFIG:Debug>:_DEBUG>")
endfunction()

# Flutter library and tool build rules.
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
add_subdirectory(${FLUTTER_MANAGED_DIR})

# Application build; see runner/CMakeLists.txt.
add_subdirectory("runner")

# Generated plugin build rules, which manage building the plugins and adding
# them to the application.
include(flutter/generated_plugins.cmake)


# === Installation ===
# Support files are copied into place next to the executable, so that it can
# run in place. This is done instead of making a separate bundle (as on Linux)
# so that building and running from within Visual Studio will work.
set(BUILD_BUNDLE_DIR "$<TARGET_FILE_DIR:${BINARY_NAME}>")
# Make the "install" step default, as it's required to run.
set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
endif()

set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}")

install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
COMPONENT Runtime)

install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
COMPONENT Runtime)

install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)

if(PLUGIN_BUNDLED_LIBRARIES)
install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
endif()

# Fully re-copy the assets directory on each build to avoid having stale files
# from a previous install.
set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
install(CODE "
file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
" COMPONENT Runtime)
install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)

# Install the AOT library on non-Debug builds only.
install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
CONFIGURATIONS Profile;Release
COMPONENT Runtime)

0 comments on commit c908cbb

Please sign in to comment.