Merge pull request #1 from adarsh-technocrat/null-safety-migration

Null safety migration
master
Adarsh kumar singh 4 years ago committed by GitHub
commit 0831af6f0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,33 +1,48 @@
## 1.1.1-nullsafety.0
- Migrated package and sample to Null Safety
- Bumped up package version
## 1.1.0 ## 1.1.0
* The FlutterIcons class is provided to access all Icons
- The FlutterIcons class is provided to access all Icons
## 1.0.0+1 ## 1.0.0+1
* Enforce code robustness
- Enforce code robustness
## 1.0.0 ## 1.0.0
* Refactored API
- Refactored API
## 0.3.1 ## 0.3.1
* File movement and adding assertions
- File movement and adding assertions
## 0.3.0 ## 0.3.0
* WeatherIcons added
- WeatherIcons added
## 0.2.5 ## 0.2.5
* IconToggle added
- IconToggle added
## 0.2.0 ## 0.2.0
* FontAwesome5_Free added
- FontAwesome5_Free added
## 0.1.5 ## 0.1.5
* Update MaterialCommunityIcons to version 4.0.96
- Update MaterialCommunityIcons to version 4.0.96
## 0.1.4 ## 0.1.4
* Add hasIconData method
- Add hasIconData method
## 0.1.3 ## 0.1.3
* Foundation added
- Foundation added
## 0.1.0 ## 0.1.0
* This library contains several icon libraries, including the well-known ant-design icon library, material icon library, and so on - This library contains several icon libraries, including the well-known ant-design icon library, material icon library, and so on

@ -27,7 +27,7 @@ class MyApp extends StatelessWidget {
} }
class MyHomePage extends StatefulWidget { class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key); MyHomePage({Key? key, required this.title}) : super(key: key);
final String title; final String title;
@ -36,7 +36,6 @@ class MyHomePage extends StatefulWidget {
} }
class _MyHomePageState extends State<MyHomePage> { class _MyHomePageState extends State<MyHomePage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done // This method is rerun every time setState is called, for instance as done

@ -8,9 +8,9 @@ description: A new Flutter application.
# build by specifying --build-name and --build-number, respectively. # build by specifying --build-name and --build-number, respectively.
# Read more about versioning at semver.org. # Read more about versioning at semver.org.
version: 1.0.0+1 version: 1.0.0+1
publish_to: none
environment: environment:
sdk: ">=2.1.0 <3.0.0" sdk: ">=2.12.0-0 <3.0.0"
dependencies: dependencies:
flutter: flutter:
@ -20,10 +20,10 @@ dependencies:
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2 cupertino_icons: ^0.1.2
flutter_icons: flutter_icons:
# path: ../ path: ..//
git: # git:
url: https://github.com/flutter-studio/flutter-icons.git # url: https://github.com/flutter-studio/flutter-icons.git
ref: 1.1.0 # ref: 1.1.0
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
@ -37,7 +37,6 @@ flutter_icons:
# The following section is specific to Flutter. # The following section is specific to Flutter.
flutter: flutter:
# The following line ensures that the Material Icons font is # The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in # included with your application, so that you can use the icons in
# the material Icons class. # the material Icons class.

@ -1,4 +1,3 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'dart:math' as math; import 'dart:math' as math;
@ -25,18 +24,18 @@ class IconToggle extends StatefulWidget {
final Color activeColor; final Color activeColor;
final Color inactiveColor; final Color inactiveColor;
final bool value; final bool value;
final ValueChanged<bool> onChanged; final ValueChanged<bool>? onChanged;
final AnimatedSwitcherTransitionBuilder transitionBuilder; final AnimatedSwitcherTransitionBuilder transitionBuilder;
final Duration duration; final Duration duration;
final Duration reverseDuration; final Duration? reverseDuration;
@override @override
_IconToggleState createState() => _IconToggleState(); _IconToggleState createState() => _IconToggleState();
} }
class _IconToggleState extends State<IconToggle> class _IconToggleState extends State<IconToggle>
with SingleTickerProviderStateMixin { with SingleTickerProviderStateMixin {
AnimationController _controller; AnimationController? _controller;
Animation<double> _position; late Animation<double> _position;
bool _cancel = false; bool _cancel = false;
@override @override
@ -46,12 +45,12 @@ class _IconToggleState extends State<IconToggle>
vsync: this, vsync: this,
duration: Duration(milliseconds: 100), duration: Duration(milliseconds: 100),
reverseDuration: Duration(milliseconds: 50)); reverseDuration: Duration(milliseconds: 50));
_position = CurvedAnimation(parent: _controller, curve: Curves.linear); _position = CurvedAnimation(parent: _controller!, curve: Curves.linear);
_position.addStatusListener((status) { _position.addStatusListener((status) {
if (status == AnimationStatus.dismissed && if (status == AnimationStatus.dismissed &&
widget.onChanged != null && widget.onChanged != null &&
_cancel == false) { _cancel == false) {
widget.onChanged(!widget.value); widget.onChanged!(!widget.value);
} }
}); });
} }
@ -88,7 +87,9 @@ class _IconToggleState extends State<IconToggle>
reverseDuration: widget.reverseDuration, reverseDuration: widget.reverseDuration,
transitionBuilder: widget.transitionBuilder, transitionBuilder: widget.transitionBuilder,
child: Icon( child: Icon(
widget.value ? widget.selectedIconData : widget.unselectedIconData, widget.value
? widget.selectedIconData
: widget.unselectedIconData,
color: widget.value ? widget.activeColor : widget.inactiveColor, color: widget.value ? widget.activeColor : widget.inactiveColor,
size: 22, size: 22,
key: ValueKey<bool>(widget.value), key: ValueKey<bool>(widget.value),
@ -102,19 +103,19 @@ class _IconToggleState extends State<IconToggle>
class _IconToggleable<T> extends AnimatedWidget { class _IconToggleable<T> extends AnimatedWidget {
_IconToggleable({ _IconToggleable({
Animation<T> listenable, required Animation<T> listenable,
this.activeColor, this.activeColor,
this.inactiveColor, this.inactiveColor,
this.child, this.child,
}) : super(listenable: listenable); }) : super(listenable: listenable);
final Color activeColor; final Color? activeColor;
final Color inactiveColor; final Color? inactiveColor;
final Widget child; final Widget? child;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return CustomPaint( return CustomPaint(
painter: _IconPainter( painter: _IconPainter(
position: listenable, position: listenable as Animation<double>,
activeColor: activeColor, activeColor: activeColor,
inactiveColor: inactiveColor, inactiveColor: inactiveColor,
), ),
@ -125,20 +126,20 @@ class _IconToggleable<T> extends AnimatedWidget {
class _IconPainter extends CustomPainter { class _IconPainter extends CustomPainter {
_IconPainter({ _IconPainter({
@required this.position, required this.position,
this.activeColor, this.activeColor,
this.inactiveColor, this.inactiveColor,
}); });
final Animation<double> position; final Animation<double> position;
final Color activeColor; final Color? activeColor;
final Color inactiveColor; final Color? inactiveColor;
double get _value => position != null ? position.value : 0; double get _value => position.value;
@override @override
void paint(Canvas canvas, Size size) { void paint(Canvas canvas, Size size) {
final Paint paint = Paint() final Paint paint = Paint()
..color = Color.lerp(inactiveColor, activeColor, _value) ..color = Color.lerp(inactiveColor, activeColor, _value)!
.withOpacity(math.min(_value, 0.15)) .withOpacity(math.min(_value, 0.15))
..style = PaintingStyle.fill ..style = PaintingStyle.fill
..strokeWidth = 2.0; ..strokeWidth = 2.0;

@ -1,11 +1,11 @@
name: flutter_icons name: flutter_icons
description: Customizable Icons for Flutteryou can use with over 3K+ icons in your flutter project description: Customizable Icons for Flutteryou can use with over 3K+ icons in your flutter project
version: 1.1.0 version: 1.1.1-nullsafety.0
author: flutter-studio<2534290808@qq.com> author: flutter-studio<2534290808@qq.com>
homepage: https://github.com/flutter-studio/flutter-icons.git homepage: https://github.com/flutter-studio/flutter-icons.git
environment: environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0" sdk: ">=2.12.0-0 <3.0.0"
dependencies: dependencies:
flutter: flutter:
@ -21,54 +21,54 @@ dev_dependencies:
# The following section is specific to Flutter. # The following section is specific to Flutter.
flutter: flutter:
fonts: fonts:
- family: Ionicons - family: Ionicons
fonts: fonts:
- asset: fonts/Ionicons.ttf - asset: fonts/Ionicons.ttf
- family: AntDesign - family: AntDesign
fonts: fonts:
- asset: fonts/AntDesign.ttf - asset: fonts/AntDesign.ttf
- family: FontAwesome - family: FontAwesome
fonts: fonts:
- asset: fonts/FontAwesome.ttf - asset: fonts/FontAwesome.ttf
- family: MaterialIcons - family: MaterialIcons
fonts: fonts:
- asset: fonts/MaterialIcons.ttf - asset: fonts/MaterialIcons.ttf
- family: Entypo - family: Entypo
fonts: fonts:
- asset: fonts/Entypo.ttf - asset: fonts/Entypo.ttf
- family: EvilIcons - family: EvilIcons
fonts: fonts:
- asset: fonts/EvilIcons.ttf - asset: fonts/EvilIcons.ttf
- family: Feather - family: Feather
fonts: fonts:
- asset: fonts/Feather.ttf - asset: fonts/Feather.ttf
- family: Foundation - family: Foundation
fonts: fonts:
- asset: fonts/Foundation.ttf - asset: fonts/Foundation.ttf
- family: MaterialCommunityIcons - family: MaterialCommunityIcons
fonts: fonts:
- asset: fonts/MaterialCommunityIcons.ttf - asset: fonts/MaterialCommunityIcons.ttf
- family: Octicons - family: Octicons
fonts: fonts:
- asset: fonts/Octicons.ttf - asset: fonts/Octicons.ttf
- family: SimpleLineIcons - family: SimpleLineIcons
fonts: fonts:
- asset: fonts/SimpleLineIcons.ttf - asset: fonts/SimpleLineIcons.ttf
- family: Zocial - family: Zocial
fonts: fonts:
- asset: fonts/Zocial.ttf - asset: fonts/Zocial.ttf
- family: FontAwesome5 - family: FontAwesome5
fonts: fonts:
- asset: fonts/FontAwesome5_Regular.ttf - asset: fonts/FontAwesome5_Regular.ttf
- family: FontAwesome5_Brands - family: FontAwesome5_Brands
fonts: fonts:
- asset: fonts/FontAwesome5_Brands.ttf - asset: fonts/FontAwesome5_Brands.ttf
- family: FontAwesome5_Solid - family: FontAwesome5_Solid
fonts: fonts:
- asset: fonts/FontAwesome5_Solid.ttf - asset: fonts/FontAwesome5_Solid.ttf
- family: WeatherIcons - family: WeatherIcons
fonts: fonts:
- asset: fonts/weathericons.ttf - asset: fonts/weathericons.ttf
# To add assets to your package, add an assets section, like this: # To add assets to your package, add an assets section, like this:
# assets: # assets:

@ -1,6 +1,4 @@
import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'file:///Users/makisu/flutter-icons/test/a.dart';
//void main() async { //void main() async {
// File file = File("././lib/src/a.dart"); // File file = File("././lib/src/a.dart");
// if (!file.existsSync()) // if (!file.existsSync())
@ -43,13 +41,15 @@ import 'file:///Users/makisu/flutter-icons/test/a.dart';
// file.writeAsStringSync(allStr); // file.writeAsStringSync(allStr);
//} //}
String toCamelName(String name)=>name.split("_").map((e)=>"${e.substring(0,1).toUpperCase()}${ String toCamelName(String name) => name
e.substring(1) .split("_")
}").toList().join(""); .map((e) => "${e.substring(0, 1).toUpperCase()}${e.substring(1)}")
.toList()
.join("");
String toName(String name){ String toName(String name) {
String _name = toCamelName(name); String _name = toCamelName(name);
return "${_name.substring(0,1).toLowerCase()}${_name.substring(1)}"; return "${_name.substring(0, 1).toLowerCase()}${_name.substring(1)}";
} }
//void main(){ //void main(){
@ -72,27 +72,26 @@ String toName(String name){
// } // }
//} //}
void main(){ void main() {
Map<String,dynamic> _gly = _fontAwesome5_meta; Map<String, dynamic> _gly = _fontAwesome5_meta;
List<String> keys = _gly.keys.toList(); List<String> keys = _gly.keys.toList();
for(int i=0;i<keys.length;i++){ for (int i = 0; i < keys.length; i++) {
File file = File("././lib/font_awesome_5_${keys[i]}.dart"); File file = File("././lib/font_awesome_5_${keys[i]}.dart");
if(!file.existsSync())file.createSync(); if (!file.existsSync()) file.createSync();
String allStr = """ String allStr = """
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'flutter_icon_data.dart';"""; import 'flutter_icon_data.dart';""";
allStr += "class ${toCamelName("font_awesome_5_${keys[i]}")} { \n"; allStr += "class ${toCamelName("font_awesome_5_${keys[i]}")} { \n";
List<String> obj = _gly[keys[i]]; List<String> obj = _gly[keys[i]];
for(int j=0;j<obj.length;j++){ for (int j = 0; j < obj.length; j++) {
allStr += "static const IconData ${obj[j].replaceAll("-", "_")} = const FlutterIconData.${toName("font_awesome_5_${keys[i]}")}(${_fontAwesome5[obj[j]]});\n"; allStr +=
"static const IconData ${obj[j].replaceAll("-", "_")} = const FlutterIconData.${toName("font_awesome_5_${keys[i]}")}(${_fontAwesome5[obj[j]]});\n";
} }
allStr += "}"; allStr += "}";
file.writeAsStringSync(allStr); file.writeAsStringSync(allStr);
} }
} }
const Map<String, List<String>> _fontAwesome5_meta = { const Map<String, List<String>> _fontAwesome5_meta = {
"brands": [ "brands": [
"500px", "500px",
@ -2957,5 +2956,3 @@ const Map<String, int> _fontAwesome5 = {
"youtube-square": 62513, "youtube-square": 62513,
"zhihu": 63039 "zhihu": 63039
}; };

Loading…
Cancel
Save