Migrated package and example to null safety

master^2
adarsh-technocrat 4 years ago
parent eb082bfbbc
commit 92f9fe4194

@ -27,7 +27,7 @@ class MyApp extends StatelessWidget {
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@ -36,7 +36,6 @@ class MyHomePage extends StatefulWidget {
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
// 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.
# Read more about versioning at semver.org.
version: 1.0.0+1
publish_to: none
environment:
sdk: ">=2.1.0 <3.0.0"
sdk: ">=2.12.0-0 <3.0.0"
dependencies:
flutter:
@ -20,10 +20,10 @@ dependencies:
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
flutter_icons:
# path: ../
git:
url: https://github.com/flutter-studio/flutter-icons.git
ref: 1.1.0
path: ..//
# git:
# url: https://github.com/flutter-studio/flutter-icons.git
# ref: 1.1.0
dev_dependencies:
flutter_test:
sdk: flutter
@ -37,7 +37,6 @@ flutter_icons:
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.

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

@ -1,11 +1,11 @@
name: flutter_icons
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>
homepage: https://github.com/flutter-studio/flutter-icons.git
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
sdk: ">=2.12.0-0 <3.0.0"
dependencies:
flutter:

@ -1,6 +1,4 @@
import 'dart:async';
import 'dart:io';
import 'file:///Users/makisu/flutter-icons/test/a.dart';
//void main() async {
// File file = File("././lib/src/a.dart");
// if (!file.existsSync())
@ -43,9 +41,11 @@ import 'file:///Users/makisu/flutter-icons/test/a.dart';
// file.writeAsStringSync(allStr);
//}
String toCamelName(String name)=>name.split("_").map((e)=>"${e.substring(0,1).toUpperCase()}${
e.substring(1)
}").toList().join("");
String toCamelName(String name) => name
.split("_")
.map((e) => "${e.substring(0, 1).toUpperCase()}${e.substring(1)}")
.toList()
.join("");
String toName(String name) {
String _name = toCamelName(name);
@ -84,15 +84,14 @@ void main(){
allStr += "class ${toCamelName("font_awesome_5_${keys[i]}")} { \n";
List<String> obj = _gly[keys[i]];
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 += "}";
file.writeAsStringSync(allStr);
}
}
const Map<String, List<String>> _fontAwesome5_meta = {
"brands": [
"500px",
@ -2957,5 +2956,3 @@ const Map<String, int> _fontAwesome5 = {
"youtube-square": 62513,
"zhihu": 63039
};

Loading…
Cancel
Save