Dataset Viewer
Auto-converted to Parquet Duplicate
text
stringlengths
6
1.82M
id
stringlengths
12
200
metadata
dict
__index_level_0__
int64
0
784
cd example/ flutter build web firebase deploy
Flutter-Neumorphic/deployWeb.sh/0
{ "file_path": "Flutter-Neumorphic/deployWeb.sh", "repo_id": "Flutter-Neumorphic", "token_count": 12 }
0
import 'package:example/tips/tips_home.dart'; import 'package:example/widgets/widgets_home.dart'; import 'package:flutter/material.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; import 'accessibility/neumorphic_accessibility.dart'; import 'playground/neumorphic_playground.dart'; import 'playground/text_playground.dart'; import 'samples/sample_home.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return NeumorphicApp( debugShowCheckedModeBanner: false, themeMode: ThemeMode.light, title: 'Flutter Neumorphic', home: FullSampleHomePage(), ); } } class FullSampleHomePage extends StatelessWidget { Widget _buildButton({String text, VoidCallback onClick}) { return NeumorphicButton( margin: EdgeInsets.only(bottom: 12), padding: EdgeInsets.symmetric( vertical: 18, horizontal: 24, ), style: NeumorphicStyle( boxShape: NeumorphicBoxShape.roundRect( BorderRadius.circular(12), ), //border: NeumorphicBorder( // isEnabled: true, // width: 0.3, //), shape: NeumorphicShape.flat, ), child: Center(child: Text(text)), onPressed: onClick, ); } @override Widget build(BuildContext context) { return NeumorphicTheme( theme: NeumorphicThemeData(depth: 8), child: Scaffold( backgroundColor: NeumorphicColors.background, body: SafeArea( child: SingleChildScrollView( child: Padding( padding: const EdgeInsets.all(18.0), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.max, children: [ _buildButton( text: "Neumorphic Playground", onClick: () { Navigator.of(context) .push(MaterialPageRoute(builder: (context) { return NeumorphicPlayground(); })); }, ), SizedBox(height: 24), _buildButton( text: "Text Playground", onClick: () { Navigator.of(context) .push(MaterialPageRoute(builder: (context) { return NeumorphicTextPlayground(); })); }, ), SizedBox(height: 24), _buildButton( text: "Samples", onClick: () { Navigator.of(context) .push(MaterialPageRoute(builder: (context) { return SamplesHome(); })); }), SizedBox(height: 24), _buildButton( text: "Widgets", onClick: () { Navigator.of(context) .push(MaterialPageRoute(builder: (context) { return WidgetsHome(); })); }), SizedBox(height: 24), _buildButton( text: "Tips", onClick: () { Navigator.of(context) .push(MaterialPageRoute(builder: (context) { return TipsHome(); })); }), SizedBox(height: 24), _buildButton( text: "Accessibility", onClick: () { Navigator.of(context) .push(MaterialPageRoute(builder: (context) { return NeumorphicAccessibility(); })); }), SizedBox(height: 12), ], ), ), ), ), ), ); } }
Flutter-Neumorphic/example/lib/main_home.dart/0
{ "file_path": "Flutter-Neumorphic/example/lib/main_home.dart", "repo_id": "Flutter-Neumorphic", "token_count": 2464 }
1
import 'package:example/lib/top_bar.dart'; import 'package:flutter/material.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; import 'border/tips_border.dart'; import 'border/tips_emboss_inside_emboss.dart'; class TipsHome extends StatelessWidget { Widget _buildButton({String text, VoidCallback onClick}) { return NeumorphicButton( margin: EdgeInsets.only(bottom: 12), padding: EdgeInsets.symmetric( vertical: 18, horizontal: 24, ), style: NeumorphicStyle( shape: NeumorphicShape.flat, boxShape: NeumorphicBoxShape.roundRect( BorderRadius.circular(12), ), ), child: Center(child: Text(text)), onPressed: onClick, ); } @override Widget build(BuildContext context) { return NeumorphicTheme( theme: NeumorphicThemeData(depth: 8), child: Scaffold( backgroundColor: NeumorphicColors.background, body: SafeArea( child: SingleChildScrollView( child: Padding( padding: const EdgeInsets.all(18.0), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.max, children: [ TopBar(title: "Tips"), _buildButton( text: "Border", onClick: () { Navigator.of(context) .push(MaterialPageRoute(builder: (context) { return TipsBorderPage(); })); }), _buildButton( text: "Recursive Emboss", onClick: () { Navigator.of(context) .push(MaterialPageRoute(builder: (context) { return TipsRecursiveeEmbossPage(); })); }), ], ), ), ), ), ), ); } }
Flutter-Neumorphic/example/lib/tips/tips_home.dart/0
{ "file_path": "Flutter-Neumorphic/example/lib/tips/tips_home.dart", "repo_id": "Flutter-Neumorphic", "token_count": 1161 }
2
import 'package:example/lib/top_bar.dart'; import 'package:example/widgets/appbar/widget_app_bar.dart'; import 'package:example/widgets/toggle/widget_toggle.dart'; import 'package:flutter/material.dart'; import 'package:flutter_neumorphic/flutter_neumorphic.dart'; import 'background/widget_background.dart'; import 'button/widget_button.dart'; import 'checkbox/widget_checkbox.dart'; import 'container/widget_container.dart'; import 'icon/widget_icon.dart'; import 'indeterminate_progress/widget_indeterminate_progress.dart'; import 'indicator/widget_indicator.dart'; import 'progress/widget_progress.dart'; import 'radiobutton/widget_radio_button.dart'; import 'range_slider/widget_range_slider.dart'; import 'slider/widget_slider.dart'; import 'switch/widget_switch.dart'; class WidgetsHome extends StatelessWidget { Widget _buildButton({String text, VoidCallback onClick}) { return NeumorphicButton( margin: EdgeInsets.only(bottom: 12), padding: EdgeInsets.symmetric( vertical: 18, horizontal: 24, ), style: NeumorphicStyle( boxShape: NeumorphicBoxShape.roundRect( BorderRadius.circular(12), ), shape: NeumorphicShape.flat, ), child: Center(child: Text(text)), onPressed: onClick, ); } @override Widget build(BuildContext context) { return NeumorphicTheme( theme: NeumorphicThemeData(depth: 8), child: Scaffold( backgroundColor: NeumorphicColors.background, body: SafeArea( child: SingleChildScrollView( child: Padding( padding: const EdgeInsets.all(18.0), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.max, children: [ TopBar(title: "Widgets"), _buildButton( text: "Container", onClick: () { Navigator.of(context) .push(MaterialPageRoute(builder: (context) { return ContainerWidgetPage(); })); }), _buildButton( text: "App bar", onClick: () { Navigator.of(context) .push(MaterialPageRoute(builder: (context) { return AppBarWidgetPage(); })); }), _buildButton( text: "Button", onClick: () { Navigator.of(context) .push(MaterialPageRoute(builder: (context) { return ButtonWidgetPage(); })); }), _buildButton( text: "Icon", onClick: () { Navigator.of(context) .push(MaterialPageRoute(builder: (context) { return IconWidgetPage(); })); }), _buildButton( text: "RadioButton", onClick: () { Navigator.of(context) .push(MaterialPageRoute(builder: (context) { return RadioButtonWidgetPage(); })); }), _buildButton( text: "Checkbox", onClick: () { Navigator.of(context) .push(MaterialPageRoute(builder: (context) { return CheckboxWidgetPage(); })); }), _buildButton( text: "Switch", onClick: () { Navigator.of(context) .push(MaterialPageRoute(builder: (context) { return SwitchWidgetPage(); })); }), _buildButton( text: "Toggle", onClick: () { Navigator.of(context) .push(MaterialPageRoute(builder: (context) { return ToggleWidgetPage(); })); }), _buildButton( text: "Slider", onClick: () { Navigator.of(context) .push(MaterialPageRoute(builder: (context) { return SliderWidgetPage(); })); }), _buildButton( text: "Range slider", onClick: () { Navigator.of(context) .push(MaterialPageRoute(builder: (context) { return RangeSliderWidgetPage(); })); }), _buildButton( text: "Indicator", onClick: () { Navigator.of(context) .push(MaterialPageRoute(builder: (context) { return IndicatorWidgetPage(); })); }), _buildButton( text: "Progress", onClick: () { Navigator.of(context) .push(MaterialPageRoute(builder: (context) { return ProgressWidgetPage(); })); }), _buildButton( text: "IndeterminateProgress", onClick: () { Navigator.of(context) .push(MaterialPageRoute(builder: (context) { return IndeterminateProgressWidgetPage(); })); }), _buildButton( text: "Background", onClick: () { Navigator.of(context) .push(MaterialPageRoute(builder: (context) { return BackgroundWidgetPage(); })); }), ], ), ), ), ), ), ); } }
Flutter-Neumorphic/example/lib/widgets/widgets_home.dart/0
{ "file_path": "Flutter-Neumorphic/example/lib/widgets/widgets_home.dart", "repo_id": "Flutter-Neumorphic", "token_count": 4105 }
3
import 'dart:ui' as ui; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/painting.dart'; import '../theme/theme.dart'; import 'cache/neumorphic_painter_cache.dart'; import 'neumorphic_box_decoration_helper.dart'; import 'neumorphic_emboss_decoration_painter.dart'; class NeumorphicEmptyTextPainter extends BoxPainter { NeumorphicEmptyTextPainter({required VoidCallback onChanged}) : super(onChanged); @override void paint(Canvas canvas, Offset offset, ImageConfiguration configuration) { //does nothing } } class NeumorphicDecorationTextPainter extends BoxPainter { final NeumorphicStyle style; final String text; final TextStyle textStyle; final TextAlign textAlign; NeumorphicPainterCache _cache; late Paint _backgroundPaint; late Paint _whiteShadowPaint; late Paint _whiteShadowMaskPaint; late Paint _blackShadowPaint; late Paint _blackShadowMaskPaint; late Paint _gradientPaint; late Paint _borderPaint; late ui.Paragraph _textParagraph; late ui.Paragraph _innerTextParagraph; late ui.Paragraph _whiteShadowParagraph; late ui.Paragraph _whiteShadowMaskParagraph; late ui.Paragraph _blackShadowTextParagraph; late ui.Paragraph _blackShadowTextMaskParagraph; late ui.Paragraph _gradientParagraph; void generatePainters() { this._backgroundPaint = Paint(); this._whiteShadowPaint = Paint(); this._whiteShadowMaskPaint = Paint()..blendMode = BlendMode.dstOut; this._blackShadowPaint = Paint(); this._blackShadowMaskPaint = Paint()..blendMode = BlendMode.dstOut; this._gradientPaint = Paint(); this._borderPaint = Paint() ..strokeCap = StrokeCap.round ..strokeJoin = StrokeJoin.bevel ..style = PaintingStyle.stroke ..strokeWidth = style.border.width ?? 0.0 ..color = style.border.color ?? Color(0xFFFFFFFF); } final bool drawGradient; final bool drawShadow; final bool drawBackground; final bool renderingByPath; NeumorphicDecorationTextPainter({ required this.style, required this.textStyle, required this.text, required this.drawGradient, required this.drawShadow, required this.drawBackground, required VoidCallback onChanged, required this.textAlign, this.renderingByPath = true, }) : _cache = NeumorphicPainterCache(), super(onChanged) { generatePainters(); } void _updateCache(Offset offset, ImageConfiguration configuration) { bool invalidateSize = false; if (configuration.size != null) { invalidateSize = this ._cache .updateSize(newOffset: offset, newSize: configuration.size!); } final bool invalidateLightSource = this ._cache .updateLightSource(style.lightSource, style.oppositeShadowLightSource); bool invalidateColor = false; if (style.color != null) { invalidateColor = this._cache.updateStyleColor(style.color!); if (invalidateColor) { _backgroundPaint..color = _cache.backgroundColor; } } bool invalidateDepth = false; if (style.depth != null) { invalidateDepth = this._cache.updateStyleDepth(style.depth!, 3); if (invalidateDepth) { _blackShadowPaint..maskFilter = _cache.maskFilterBlur; _whiteShadowPaint..maskFilter = _cache.maskFilterBlur; } } bool invalidateShadowColors = false; if (style.shadowLightColor != null && style.shadowDarkColor != null && style.intensity != null) { invalidateShadowColors = this._cache.updateShadowColor( newShadowLightColorEmboss: style.shadowLightColor!, newShadowDarkColorEmboss: style.shadowDarkColor!, newIntensity: style.intensity ?? neumorphicDefaultTheme.intensity, ); if (invalidateShadowColors) { if (_cache.shadowLightColor != null) { _whiteShadowPaint..color = _cache.shadowLightColor!; } if (_cache.shadowDarkColor != null) { _blackShadowPaint..color = _cache.shadowDarkColor!; } } } final constraints = ui.ParagraphConstraints(width: _cache.width); final paragraphStyle = textStyle.getParagraphStyle( textDirection: TextDirection.ltr, textAlign: this.textAlign); final textParagraphBuilder = ui.ParagraphBuilder(paragraphStyle) ..pushStyle(ui.TextStyle( foreground: _borderPaint, )) ..addText(text); final innerTextParagraphBuilder = ui.ParagraphBuilder(paragraphStyle) ..pushStyle(ui.TextStyle( foreground: _backgroundPaint, )) ..addText(text); final whiteShadowParagraphBuilder = ui.ParagraphBuilder(paragraphStyle) ..pushStyle(ui.TextStyle( foreground: _whiteShadowPaint, )) ..addText(text); final whiteShadowMaskParagraphBuilder = ui.ParagraphBuilder(paragraphStyle) ..pushStyle(ui.TextStyle( foreground: _whiteShadowMaskPaint, )) ..addText(text); final blackShadowParagraphBuilder = ui.ParagraphBuilder(paragraphStyle) ..pushStyle(ui.TextStyle( foreground: _blackShadowPaint, )) ..addText(text); final blackShadowMaskParagraphBuilder = ui.ParagraphBuilder(paragraphStyle) ..pushStyle(ui.TextStyle( foreground: _blackShadowMaskPaint, )) ..addText(text); _textParagraph = textParagraphBuilder.build()..layout(constraints); _innerTextParagraph = innerTextParagraphBuilder.build() ..layout(constraints); _whiteShadowParagraph = whiteShadowParagraphBuilder.build() ..layout(constraints); _whiteShadowMaskParagraph = whiteShadowMaskParagraphBuilder.build() ..layout(constraints); _blackShadowTextParagraph = blackShadowParagraphBuilder.build() ..layout(constraints); _blackShadowTextMaskParagraph = blackShadowMaskParagraphBuilder.build() ..layout(constraints); //region gradient final gradientParagraphBuilder = ui.ParagraphBuilder(paragraphStyle) ..pushStyle(ui.TextStyle( foreground: _gradientPaint ..shader = getGradientShader( gradientRect: Rect.fromLTRB(0, 0, _cache.width, _cache.height), intensity: style.surfaceIntensity, source: style.shape == NeumorphicShape.concave ? this.style.lightSource : this.style.lightSource.invert(), ), )) ..addText(text); _gradientParagraph = gradientParagraphBuilder.build() ..layout(ui.ParagraphConstraints(width: _cache.width)); //endregion if (invalidateDepth || invalidateLightSource) { _cache.updateDepthOffset(); } if (invalidateLightSource || invalidateDepth || invalidateSize) { _cache.updateTranslations(); } } @override void paint(Canvas canvas, Offset offset, ImageConfiguration configuration) { _updateCache(offset, configuration); _drawShadow(offset: offset, canvas: canvas, path: _cache.path); _drawElement(offset: offset, canvas: canvas, path: _cache.path); } void _drawElement( {required Canvas canvas, required Offset offset, required Path path}) { if (true) { _drawBackground(offset: offset, canvas: canvas, path: path); } if (this.drawGradient) { _drawGradient(offset: offset, canvas: canvas, path: path); } if (style.border.isEnabled) { _drawBorder(canvas: canvas, offset: offset, path: path); } } void _drawBorder( {required Canvas canvas, required Offset offset, required Path path}) { if (style.border.width != null && style.border.width! > 0) { canvas ..save() ..translate(offset.dx, offset.dy) ..drawParagraph(_textParagraph, Offset.zero) ..restore(); } } void _drawBackground( {required Canvas canvas, required Offset offset, required Path path}) { canvas ..save() ..translate(offset.dx, offset.dy) ..drawParagraph(_innerTextParagraph, Offset.zero) ..restore(); } void _drawShadow( {required Canvas canvas, required Offset offset, required Path path}) { if (style.depth != null && style.depth!.abs() >= 0.1) { canvas ..saveLayer(_cache.layerRect, _whiteShadowPaint) ..translate(offset.dx + _cache.depthOffset.dx, offset.dy + _cache.depthOffset.dy) ..drawParagraph(_whiteShadowParagraph, Offset.zero) ..translate(-_cache.depthOffset.dx, -_cache.depthOffset.dy) ..drawParagraph(_whiteShadowMaskParagraph, Offset.zero) ..restore(); canvas ..saveLayer(_cache.layerRect, _blackShadowPaint) ..translate(offset.dx - _cache.depthOffset.dx, offset.dy - _cache.depthOffset.dy) ..drawParagraph(_blackShadowTextParagraph, Offset.zero) ..translate(_cache.depthOffset.dx, _cache.depthOffset.dy) ..drawParagraph(_blackShadowTextMaskParagraph, Offset.zero) ..restore(); } } void _drawGradient( {required Canvas canvas, required Offset offset, required Path path}) { if (style.shape == NeumorphicShape.concave || style.shape == NeumorphicShape.convex) { canvas ..saveLayer(_cache.layerRect, _gradientPaint) ..translate(offset.dx, offset.dy) ..drawParagraph(_gradientParagraph, Offset.zero) ..restore(); } } }
Flutter-Neumorphic/lib/src/decoration/neumorphic_text_decoration_painter.dart/0
{ "file_path": "Flutter-Neumorphic/lib/src/decoration/neumorphic_text_decoration_painter.dart", "repo_id": "Flutter-Neumorphic", "token_count": 3546 }
4
import 'dart:ui'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart' show IconThemeData, TextTheme; import 'package:flutter/painting.dart'; import 'package:flutter_neumorphic/src/theme/app_bar.dart'; import 'package:flutter_neumorphic/src/widget/container.dart'; import '../../flutter_neumorphic.dart'; import '../colors.dart'; import '../light_source.dart'; import '../shape.dart'; export '../colors.dart'; export '../light_source.dart'; export '../shape.dart'; //region theme const double _defaultDepth = 4; const double _defaultIntensity = 0.7; const Color _defaultAccent = NeumorphicColors.accent; const Color _defaultVariant = NeumorphicColors.variant; const Color _defaultDisabledColor = NeumorphicColors.disabled; const Color _defaultTextColor = NeumorphicColors.defaultTextColor; const LightSource _defaultLightSource = LightSource.topLeft; const Color _defaultBaseColor = NeumorphicColors.background; const double _defaultBorderSize = 0.3; /// Used with the NeumorphicTheme /// /// ``` /// NeumorphicTheme( /// theme: NeumorphicThemeData(...) /// darkTheme: : NeumorphicThemeData(...) /// child: ... /// )` /// `` /// /// Contains all default values used in child Neumorphic Elements as /// default colors : baseColor, accentColor, variantColor /// default depth & intensities, used to generate white / dark shadows /// default lightsource, used to calculate the angle of the shadow /// @see [LightSource] /// @immutable class NeumorphicThemeData { final Color baseColor; final Color accentColor; final Color variantColor; final Color disabledColor; final Color shadowLightColor; final Color shadowDarkColor; final Color shadowLightColorEmboss; final Color shadowDarkColorEmboss; final NeumorphicBoxShape? _boxShape; NeumorphicBoxShape get boxShape => _boxShape ?? NeumorphicBoxShape.roundRect(BorderRadius.circular(8)); final Color borderColor; final double borderWidth; final Color defaultTextColor; //TODO maybe use TextStyle here final double _depth; final double _intensity; final LightSource lightSource; final bool disableDepth; /// Default text theme to use and apply across the app final TextTheme textTheme; /// Default button style to use and apply across the app final NeumorphicStyle? buttonStyle; /// Default icon theme to use and apply across the app final IconThemeData iconTheme; final NeumorphicAppBarThemeData appBarTheme; /// Get this theme's depth, clamp to min/max neumorphic constants double get depth => _depth.clamp(Neumorphic.MIN_DEPTH, Neumorphic.MAX_DEPTH); /// Get this theme's intensity, clamp to min/max neumorphic constants double get intensity => _intensity.clamp(Neumorphic.MIN_INTENSITY, Neumorphic.MAX_INTENSITY); const NeumorphicThemeData({ this.baseColor = _defaultBaseColor, double depth = _defaultDepth, NeumorphicBoxShape? boxShape, double intensity = _defaultIntensity, this.accentColor = _defaultAccent, this.variantColor = _defaultVariant, this.disabledColor = _defaultDisabledColor, this.shadowLightColor = NeumorphicColors.decorationMaxWhiteColor, this.shadowDarkColor = NeumorphicColors.decorationMaxDarkColor, this.shadowLightColorEmboss = NeumorphicColors.embossMaxWhiteColor, this.shadowDarkColorEmboss = NeumorphicColors.embossMaxDarkColor, this.defaultTextColor = _defaultTextColor, this.lightSource = _defaultLightSource, this.textTheme = const TextTheme(), this.iconTheme = const IconThemeData(), this.buttonStyle, this.appBarTheme = const NeumorphicAppBarThemeData(), this.borderColor = NeumorphicColors.defaultBorder, this.borderWidth = _defaultBorderSize, this.disableDepth = false, }) : this._depth = depth, this._boxShape = boxShape, this._intensity = intensity; const NeumorphicThemeData.dark({ this.baseColor = NeumorphicColors.darkBackground, double depth = _defaultDepth, NeumorphicBoxShape? boxShape, double intensity = _defaultIntensity, this.accentColor = _defaultAccent, this.textTheme = const TextTheme(), this.buttonStyle, this.iconTheme = const IconThemeData(), this.appBarTheme = const NeumorphicAppBarThemeData(), this.variantColor = NeumorphicColors.darkVariant, this.disabledColor = NeumorphicColors.darkDisabled, this.shadowLightColor = NeumorphicColors.decorationMaxWhiteColor, this.shadowDarkColor = NeumorphicColors.decorationMaxDarkColor, this.shadowLightColorEmboss = NeumorphicColors.embossMaxWhiteColor, this.shadowDarkColorEmboss = NeumorphicColors.embossMaxDarkColor, this.defaultTextColor = NeumorphicColors.darkDefaultTextColor, this.lightSource = _defaultLightSource, this.borderColor = NeumorphicColors.darkDefaultBorder, this.borderWidth = _defaultBorderSize, this.disableDepth = false, }) : this._depth = depth, this._boxShape = boxShape, this._intensity = intensity; @override String toString() { return 'NeumorphicTheme{baseColor: $baseColor, boxShape: $boxShape, disableDepth: $disableDepth, accentColor: $accentColor, variantColor: $variantColor, disabledColor: $disabledColor, _depth: $_depth, intensity: $intensity, lightSource: $lightSource}'; } @override bool operator ==(Object other) => identical(this, other) || other is NeumorphicThemeData && runtimeType == other.runtimeType && baseColor == other.baseColor && boxShape == other.boxShape && textTheme == other.textTheme && iconTheme == other.iconTheme && buttonStyle == other.buttonStyle && appBarTheme == other.appBarTheme && accentColor == other.accentColor && shadowDarkColor == other.shadowDarkColor && shadowLightColor == other.shadowLightColor && shadowDarkColorEmboss == other.shadowDarkColorEmboss && shadowLightColorEmboss == other.shadowLightColorEmboss && disabledColor == other.disabledColor && variantColor == other.variantColor && disableDepth == other.disableDepth && defaultTextColor == other.defaultTextColor && borderWidth == other.borderWidth && borderColor == other.borderColor && _depth == other._depth && _intensity == other._intensity && lightSource == other.lightSource; @override int get hashCode => baseColor.hashCode ^ textTheme.hashCode ^ iconTheme.hashCode ^ buttonStyle.hashCode ^ appBarTheme.hashCode ^ accentColor.hashCode ^ variantColor.hashCode ^ disabledColor.hashCode ^ shadowDarkColor.hashCode ^ shadowLightColor.hashCode ^ shadowDarkColorEmboss.hashCode ^ shadowLightColorEmboss.hashCode ^ defaultTextColor.hashCode ^ disableDepth.hashCode ^ borderWidth.hashCode ^ borderColor.hashCode ^ _depth.hashCode ^ boxShape.hashCode ^ _intensity.hashCode ^ lightSource.hashCode; /// Create a copy of this theme /// With possibly new values given from this method's arguments NeumorphicThemeData copyWith({ Color? baseColor, Color? accentColor, Color? variantColor, Color? disabledColor, Color? shadowLightColor, Color? shadowDarkColor, Color? shadowLightColorEmboss, Color? shadowDarkColorEmboss, Color? defaultTextColor, NeumorphicBoxShape? boxShape, TextTheme? textTheme, NeumorphicStyle? buttonStyle, IconThemeData? iconTheme, NeumorphicAppBarThemeData? appBarTheme, NeumorphicStyle? defaultStyle, bool? disableDepth, double? depth, double? intensity, Color? borderColor, double? borderSize, LightSource? lightSource, }) { return new NeumorphicThemeData( baseColor: baseColor ?? this.baseColor, textTheme: textTheme ?? this.textTheme, iconTheme: iconTheme ?? this.iconTheme, buttonStyle: buttonStyle ?? this.buttonStyle, boxShape: boxShape ?? this.boxShape, appBarTheme: appBarTheme ?? this.appBarTheme, accentColor: accentColor ?? this.accentColor, variantColor: variantColor ?? this.variantColor, disabledColor: disabledColor ?? this.disabledColor, defaultTextColor: defaultTextColor ?? this.defaultTextColor, disableDepth: disableDepth ?? this.disableDepth, shadowDarkColor: shadowDarkColor ?? this.shadowDarkColor, shadowLightColor: shadowLightColor ?? this.shadowLightColor, shadowDarkColorEmboss: shadowDarkColorEmboss ?? this.shadowDarkColorEmboss, shadowLightColorEmboss: shadowLightColorEmboss ?? this.shadowLightColorEmboss, depth: depth ?? this._depth, borderWidth: borderSize ?? this.borderWidth, borderColor: borderColor ?? this.borderColor, intensity: intensity ?? this._intensity, lightSource: lightSource ?? this.lightSource, ); } /// Create a copy of this theme /// With possibly new values given from the given second theme NeumorphicThemeData copyFrom({ required NeumorphicThemeData other, }) { return new NeumorphicThemeData( baseColor: other.baseColor, accentColor: other.accentColor, variantColor: other.variantColor, disableDepth: other.disableDepth, disabledColor: other.disabledColor, defaultTextColor: other.defaultTextColor, shadowDarkColor: other.shadowDarkColor, shadowLightColor: other.shadowLightColor, shadowDarkColorEmboss: other.shadowDarkColorEmboss, shadowLightColorEmboss: other.shadowLightColorEmboss, textTheme: other.textTheme, iconTheme: other.iconTheme, buttonStyle: other.buttonStyle, appBarTheme: other.appBarTheme, depth: other.depth, boxShape: other.boxShape, borderColor: other.borderColor, borderWidth: other.borderWidth, intensity: other.intensity, lightSource: other.lightSource, ); } } //endregion //region style const NeumorphicShape _defaultShape = NeumorphicShape.flat; //const double _defaultBorderRadius = 5; const neumorphicDefaultTheme = NeumorphicThemeData(); const neumorphicDefaultDarkTheme = NeumorphicThemeData.dark(); class NeumorphicBorder { final bool isEnabled; final Color? color; final double? width; const NeumorphicBorder({ this.isEnabled = true, this.color, this.width, }); const NeumorphicBorder.none() : this.isEnabled = true, this.color = const Color(0x00000000), this.width = 0; @override bool operator ==(Object other) => identical(this, other) || other is NeumorphicBorder && runtimeType == other.runtimeType && isEnabled == other.isEnabled && color == other.color && width == other.width; @override int get hashCode => isEnabled.hashCode ^ color.hashCode ^ width.hashCode; @override String toString() { return 'NeumorphicBorder{isEnabled: $isEnabled, color: $color, width: $width}'; } static NeumorphicBorder? lerp( NeumorphicBorder? a, NeumorphicBorder? b, double t) { if (a == null && b == null) return null; if (t == 0.0) return a; if (t == 1.0) return b; return NeumorphicBorder( color: Color.lerp(a!.color, b!.color, t), isEnabled: a.isEnabled, width: lerpDouble(a.width, b.width, t), ); } NeumorphicBorder copyWithThemeIfNull({Color? color, double? width}) { return NeumorphicBorder( isEnabled: this.isEnabled, color: this.color ?? color, width: this.width ?? width, ); } } class NeumorphicStyle { final Color? color; final double? _depth; final double? _intensity; final double _surfaceIntensity; final LightSource lightSource; final bool? disableDepth; final NeumorphicBorder border; final bool oppositeShadowLightSource; final NeumorphicShape shape; final NeumorphicBoxShape? boxShape; final NeumorphicThemeData? theme; //override the "white" color final Color? shadowLightColor; //override the "dark" color final Color? shadowDarkColor; //override the "white" color final Color? shadowLightColorEmboss; //override the "dark" color final Color? shadowDarkColorEmboss; const NeumorphicStyle({ this.shape = _defaultShape, this.lightSource = LightSource.topLeft, this.border = const NeumorphicBorder.none(), this.color, this.boxShape, //nullable by default, will use the one defined in theme if not set this.shadowLightColor, this.shadowDarkColor, this.shadowLightColorEmboss, this.shadowDarkColorEmboss, double? depth, double? intensity, double surfaceIntensity = 0.25, this.disableDepth, this.oppositeShadowLightSource = false, }) : this._depth = depth, this.theme = null, this._intensity = intensity, this._surfaceIntensity = surfaceIntensity; // with theme constructor is only available privately, please use copyWithThemeIfNull const NeumorphicStyle._withTheme({ this.theme, this.shape = _defaultShape, this.lightSource = LightSource.topLeft, this.color, this.boxShape, this.border = const NeumorphicBorder.none(), this.shadowLightColor, this.shadowDarkColor, this.shadowLightColorEmboss, this.shadowDarkColorEmboss, this.oppositeShadowLightSource = false, this.disableDepth, double? depth, double? intensity, double surfaceIntensity = 0.25, }) : this._depth = depth, this._intensity = intensity, this._surfaceIntensity = surfaceIntensity; double? get depth => _depth?.clamp(Neumorphic.MIN_DEPTH, Neumorphic.MAX_DEPTH); double? get intensity => _intensity?.clamp(Neumorphic.MIN_INTENSITY, Neumorphic.MAX_INTENSITY); double get surfaceIntensity => _surfaceIntensity.clamp( Neumorphic.MIN_INTENSITY, Neumorphic.MAX_INTENSITY); NeumorphicStyle copyWithThemeIfNull(NeumorphicThemeData theme) { return NeumorphicStyle._withTheme( theme: theme, color: this.color ?? theme.baseColor, boxShape: this.boxShape ?? theme.boxShape, shape: this.shape, border: this.border.copyWithThemeIfNull( color: theme.borderColor, width: theme.borderWidth), shadowDarkColor: this.shadowDarkColor ?? theme.shadowDarkColor, shadowLightColor: this.shadowLightColor ?? theme.shadowLightColor, shadowDarkColorEmboss: this.shadowDarkColorEmboss ?? theme.shadowDarkColorEmboss, shadowLightColorEmboss: this.shadowLightColorEmboss ?? theme.shadowLightColorEmboss, depth: this.depth ?? theme.depth, intensity: this.intensity ?? theme.intensity, disableDepth: this.disableDepth ?? theme.disableDepth, surfaceIntensity: this.surfaceIntensity, oppositeShadowLightSource: this.oppositeShadowLightSource, lightSource: this.lightSource); } @override bool operator ==(Object other) => identical(this, other) || other is NeumorphicStyle && runtimeType == other.runtimeType && color == other.color && boxShape == other.boxShape && border == other.border && shadowDarkColor == other.shadowDarkColor && shadowLightColor == other.shadowLightColor && shadowDarkColorEmboss == other.shadowDarkColorEmboss && shadowLightColorEmboss == other.shadowLightColorEmboss && disableDepth == other.disableDepth && _depth == other._depth && _intensity == other._intensity && _surfaceIntensity == other._surfaceIntensity && lightSource == other.lightSource && oppositeShadowLightSource == other.oppositeShadowLightSource && shape == other.shape && theme == other.theme; @override int get hashCode => color.hashCode ^ shadowDarkColor.hashCode ^ boxShape.hashCode ^ shadowLightColor.hashCode ^ shadowDarkColorEmboss.hashCode ^ shadowLightColorEmboss.hashCode ^ _depth.hashCode ^ border.hashCode ^ _intensity.hashCode ^ disableDepth.hashCode ^ _surfaceIntensity.hashCode ^ lightSource.hashCode ^ oppositeShadowLightSource.hashCode ^ shape.hashCode ^ theme.hashCode; NeumorphicStyle copyWith({ Color? color, NeumorphicBorder? border, NeumorphicBoxShape? boxShape, Color? shadowLightColor, Color? shadowDarkColor, Color? shadowLightColorEmboss, Color? shadowDarkColorEmboss, double? depth, double? intensity, double? surfaceIntensity, LightSource? lightSource, bool? disableDepth, double? borderRadius, bool? oppositeShadowLightSource, NeumorphicShape? shape, }) { return NeumorphicStyle._withTheme( color: color ?? this.color, border: border ?? this.border, boxShape: boxShape ?? this.boxShape, shadowDarkColor: shadowDarkColor ?? this.shadowDarkColor, shadowLightColor: shadowLightColor ?? this.shadowLightColor, shadowDarkColorEmboss: shadowDarkColorEmboss ?? this.shadowDarkColorEmboss, shadowLightColorEmboss: shadowLightColorEmboss ?? this.shadowLightColorEmboss, depth: depth ?? this.depth, theme: this.theme, intensity: intensity ?? this.intensity, surfaceIntensity: surfaceIntensity ?? this.surfaceIntensity, disableDepth: disableDepth ?? this.disableDepth, lightSource: lightSource ?? this.lightSource, oppositeShadowLightSource: oppositeShadowLightSource ?? this.oppositeShadowLightSource, shape: shape ?? this.shape, ); } @override String toString() { return 'NeumorphicStyle{color: $color, boxShape: $boxShape, _depth: $_depth, intensity: $intensity, disableDepth: $disableDepth, lightSource: $lightSource, shape: $shape, theme: $theme, oppositeShadowLightSource: $oppositeShadowLightSource}'; } NeumorphicStyle applyDisableDepth() { if (disableDepth == true) { return this.copyWith(depth: 0); } else { return this; } } } //endregion
Flutter-Neumorphic/lib/src/theme/theme.dart/0
{ "file_path": "Flutter-Neumorphic/lib/src/theme/theme.dart", "repo_id": "Flutter-Neumorphic", "token_count": 6439 }
5
import 'package:flutter/widgets.dart'; import '../neumorphic_box_shape.dart'; import '../theme/neumorphic_theme.dart'; import 'button.dart'; import 'container.dart'; typedef void NeumorphicRadioListener<T>(T value); /// A Style used to customize a [NeumorphicRadio] /// /// [selectedDepth] : the depth when checked /// [unselectedDepth] : the depth when unchecked (default : theme.depth) /// /// [intensity] : a customizable neumorphic intensity for this widget /// /// [boxShape] : a customizable neumorphic boxShape for this widget /// @see [NeumorphicBoxShape] /// /// [shape] : a customizable neumorphic shape for this widget /// @see [NeumorphicShape] (concave, convex, flat) /// class NeumorphicRadioStyle { final double? selectedDepth; final double? unselectedDepth; final bool disableDepth; final Color? selectedColor; //null for default final Color? unselectedColor; //null for unchanged color final double? intensity; final NeumorphicShape? shape; final NeumorphicBorder border; final NeumorphicBoxShape? boxShape; final LightSource? lightSource; const NeumorphicRadioStyle({ this.selectedDepth, this.unselectedDepth, this.selectedColor, this.unselectedColor, this.lightSource, this.disableDepth = false, this.boxShape, this.border = const NeumorphicBorder.none(), this.intensity, this.shape, }); @override bool operator ==(Object other) => identical(this, other) || other is NeumorphicRadioStyle && runtimeType == other.runtimeType && disableDepth == other.disableDepth && lightSource == other.lightSource && border == other.border && selectedDepth == other.selectedDepth && unselectedDepth == other.unselectedDepth && selectedColor == other.selectedColor && unselectedColor == other.unselectedColor && boxShape == other.boxShape && intensity == other.intensity && shape == other.shape; @override int get hashCode => disableDepth.hashCode ^ selectedDepth.hashCode ^ lightSource.hashCode ^ selectedColor.hashCode ^ unselectedColor.hashCode ^ boxShape.hashCode ^ border.hashCode ^ unselectedDepth.hashCode ^ intensity.hashCode ^ shape.hashCode; } /// A Neumorphic Radio /// /// It takes a `value` and a `groupValue` /// if (value == groupValue) => checked /// /// takes a NeumorphicRadioStyle as `style` /// /// notifies the parent when user interact with this widget with `onChanged` /// /// ``` /// int _groupValue; /// /// Widget _buildRadios() { /// return Row( /// children: <Widget>[ /// /// NeumorphicRadio( /// child: SizedBox( /// height: 50, /// width: 50, /// child: Center( /// child: Text("1"), /// ), /// ), /// value: 1, /// groupValue: _groupValue, /// onChanged: (value) { /// setState(() { /// _groupValue = value; /// }); /// }, /// ), /// /// NeumorphicRadio( /// child: SizedBox( /// height: 50, /// width: 50, /// child: Center( /// child: Text("2"), /// ), /// ), /// value: 2, /// groupValue: _groupValue, /// onChanged: (value) { /// setState(() { /// _groupValue = value; /// }); /// }, /// ), /// /// NeumorphicRadio( /// child: SizedBox( /// height: 50, /// width: 50, /// child: Center( /// child: Text("3"), /// ), /// ), /// value: 3, /// groupValue: _groupValue, /// onChanged: (value) { /// setState(() { /// _groupValue = value; /// }); /// }, /// ), /// /// ], /// ); /// } /// ``` /// @immutable class NeumorphicRadio<T> extends StatelessWidget { final Widget? child; final T? value; final T? groupValue; final EdgeInsets padding; final NeumorphicRadioStyle style; final NeumorphicRadioListener<T?>? onChanged; final bool isEnabled; final Duration duration; final Curve curve; NeumorphicRadio({ this.child, this.style = const NeumorphicRadioStyle(), this.value, this.curve = Neumorphic.DEFAULT_CURVE, this.duration = Neumorphic.DEFAULT_DURATION, this.padding = EdgeInsets.zero, this.groupValue, this.onChanged, this.isEnabled = true, }); bool get isSelected => this.value != null && this.value == this.groupValue; void _onClick() { if (this.onChanged != null) { if (this.value == this.groupValue) { //unselect this.onChanged!(null); } else { this.onChanged!(this.value); } } } @override Widget build(BuildContext context) { final NeumorphicThemeData theme = NeumorphicTheme.currentTheme(context); final double selectedDepth = -1 * (this.style.selectedDepth ?? theme.depth).abs(); final double unselectedDepth = (this.style.unselectedDepth ?? theme.depth).abs(); double depth = isSelected ? selectedDepth : unselectedDepth; if (!this.isEnabled) { depth = 0; } final Color unselectedColor = this.style.unselectedColor ?? theme.baseColor; final Color selectedColor = this.style.selectedColor ?? unselectedColor; final Color color = isSelected ? selectedColor : unselectedColor; return NeumorphicButton( onPressed: () { _onClick(); }, duration: this.duration, curve: this.curve, padding: this.padding, pressed: isSelected, minDistance: selectedDepth, child: this.child, style: NeumorphicStyle( border: this.style.border, color: color, boxShape: this.style.boxShape, lightSource: this.style.lightSource ?? theme.lightSource, disableDepth: this.style.disableDepth, intensity: this.style.intensity, depth: depth, shape: this.style.shape ?? NeumorphicShape.flat, ), ); } }
Flutter-Neumorphic/lib/src/widget/radio.dart/0
{ "file_path": "Flutter-Neumorphic/lib/src/widget/radio.dart", "repo_id": "Flutter-Neumorphic", "token_count": 2586 }
6
<?xml version="1.0" encoding="UTF-8"?> <projectDescription> <name>app</name> <comment>Project app created by Buildship.</comment> <projects> </projects> <buildSpec> <buildCommand> <name>org.eclipse.jdt.core.javabuilder</name> <arguments> </arguments> </buildCommand> <buildCommand> <name>org.eclipse.buildship.core.gradleprojectbuilder</name> <arguments> </arguments> </buildCommand> </buildSpec> <natures> <nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.buildship.core.gradleprojectnature</nature> </natures> </projectDescription>
Flutter-UI-Kit/android/app/.project/0
{ "file_path": "Flutter-UI-Kit/android/app/.project", "repo_id": "Flutter-UI-Kit", "token_count": 237 }
7
org.gradle.jvmargs=-Xmx1536M
Flutter-UI-Kit/android/gradle.properties/0
{ "file_path": "Flutter-UI-Kit/android/gradle.properties", "repo_id": "Flutter-UI-Kit", "token_count": 15 }
8
import 'package:flutter_uikit/model/post.dart'; class PostViewModel { List<Post> postItems; PostViewModel({this.postItems}); getPosts() => <Post>[ Post( personName: "Pawan", address: "New Delhi, India", likesCount: 100, commentsCount: 10, message: "Google Developer Expert for Flutter. Passionate #Flutter, #Android Developer. #Entrepreneur #YouTuber", personImage: "https://avatars0.githubusercontent.com/u/12619420?s=460&v=4", messageImage: "https://cdn.pixabay.com/photo/2018/03/09/16/32/woman-3211957_1280.jpg", postTime: "Just Now"), Post( personName: "Amanda", address: "Canada", likesCount: 123, commentsCount: 78, messageImage: "https://cdn.pixabay.com/photo/2016/04/10/21/34/woman-1320810_960_720.jpg", message: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s", personImage: "https://cdn.pixabay.com/photo/2016/04/10/21/34/woman-1320810_960_720.jpg", postTime: "5h ago"), Post( personName: "Eric", address: "California", likesCount: 50, commentsCount: 5, message: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s", personImage: "https://cdn.pixabay.com/photo/2013/07/18/20/24/brad-pitt-164880_960_720.jpg", postTime: "2h ago"), Post( personName: "Jack", address: "California", likesCount: 23, commentsCount: 4, messageImage: "https://cdn.pixabay.com/photo/2014/09/07/16/53/hands-437968_960_720.jpg", message: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s", personImage: "https://cdn.pixabay.com/photo/2016/04/01/09/51/actor-1299629_960_720.png", postTime: "3h ago"), Post( personName: "Neha", address: "Punjab", likesCount: 35, commentsCount: 2, messageImage: "https://cdn.pixabay.com/photo/2015/11/26/00/14/fashion-1063100_960_720.jpg", message: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s", personImage: "https://cdn.pixabay.com/photo/2015/11/26/00/14/fashion-1063100_960_720.jpg", postTime: "1d ago"), Post( personName: "Pawan", address: "New Delhi, India", likesCount: 100, commentsCount: 10, message: "Google Developer Expert for Flutter. Passionate #Flutter, #Android Developer. #Entrepreneur #YouTuber", personImage: "https://avatars0.githubusercontent.com/u/12619420?s=460&v=4", messageImage: "https://cdn.pixabay.com/photo/2018/03/09/16/32/woman-3211957_1280.jpg", postTime: "Just Now"), Post( personName: "Eric", address: "California", likesCount: 50, commentsCount: 5, message: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s", personImage: "https://cdn.pixabay.com/photo/2013/07/18/20/24/brad-pitt-164880_960_720.jpg", postTime: "2h ago"), Post( personName: "Jack", address: "California", likesCount: 23, commentsCount: 4, messageImage: "https://cdn.pixabay.com/photo/2014/09/07/16/53/hands-437968_960_720.jpg", message: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s", personImage: "https://cdn.pixabay.com/photo/2016/04/01/09/51/actor-1299629_960_720.png", postTime: "3h ago"), Post( personName: "Amanda", address: "Canada", likesCount: 123, commentsCount: 78, messageImage: "https://cdn.pixabay.com/photo/2016/04/10/21/34/woman-1320810_960_720.jpg", message: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s", personImage: "https://cdn.pixabay.com/photo/2016/04/10/21/34/woman-1320810_960_720.jpg", postTime: "5h ago"), Post( personName: "Neha", address: "Punjab", likesCount: 35, commentsCount: 2, messageImage: "https://cdn.pixabay.com/photo/2015/11/26/00/14/fashion-1063100_960_720.jpg", message: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s", personImage: "https://cdn.pixabay.com/photo/2015/11/26/00/14/fashion-1063100_960_720.jpg", postTime: "1d ago"), ]; }
Flutter-UI-Kit/lib/logic/viewmodel/post_view_model.dart/0
{ "file_path": "Flutter-UI-Kit/lib/logic/viewmodel/post_view_model.dart", "repo_id": "Flutter-UI-Kit", "token_count": 2894 }
9
import 'dart:async'; import 'package:flutter_uikit/model/login.dart'; import 'package:flutter_uikit/model/otp.dart'; import 'package:flutter_uikit/services/abstract/i_otp_service.dart'; import 'package:flutter_uikit/services/network_service.dart'; import 'package:flutter_uikit/services/network_service_response.dart'; import 'package:flutter_uikit/services/restclient.dart'; class OTPService extends NetworkService implements IOTPService { static const _kCreateOtpUrl = "/createOtpForUser/{1}"; static const _kUserOtpLogin = "/userotplogin"; OTPService(RestClient rest) : super(rest); @override Future<NetworkServiceResponse<CreateOTPResponse>> createOTP( String phoneNumber) async { var result = await rest.getAsync<CreateOTPResponse>( Uri.parse(_kCreateOtpUrl.replaceFirst("{1}", phoneNumber)).toString()); if (result.mappedResult != null) { var res = CreateOTPResponse.fromJson(result.mappedResult); return new NetworkServiceResponse( content: res, success: result.networkServiceResponse.success, ); } return new NetworkServiceResponse( success: result.networkServiceResponse.success, message: result.networkServiceResponse.message); } @override Future<NetworkServiceResponse<OTPResponse>> fetchOTPLoginResponse( Login userLogin) async { var result = await rest.postAsync<OTPResponse>(_kUserOtpLogin, userLogin); if (result.mappedResult != null) { var res = OTPResponse.fromJson(result.mappedResult); return new NetworkServiceResponse( content: res, success: result.networkServiceResponse.success, ); } return new NetworkServiceResponse( success: result.networkServiceResponse.success, message: result.networkServiceResponse.message); } }
Flutter-UI-Kit/lib/services/real/real_otp_service.dart/0
{ "file_path": "Flutter-UI-Kit/lib/services/real/real_otp_service.dart", "repo_id": "Flutter-UI-Kit", "token_count": 650 }
10
import 'package:flutter/material.dart'; import 'package:flutter_uikit/ui/widgets/common_scaffold.dart'; import 'package:flutter_uikit/ui/widgets/common_switch.dart'; import 'package:flutter_uikit/utils/uidata.dart'; class SettingsOnePage extends StatelessWidget { Widget bodyData() => SingleChildScrollView( child: Theme( data: ThemeData(fontFamily: UIData.ralewayFont), child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.stretch, children: <Widget>[ //1 Padding( padding: const EdgeInsets.all(16.0), child: Text( "General Setting", style: TextStyle(color: Colors.grey.shade700), ), ), Card( color: Colors.white, elevation: 2.0, child: Column( children: <Widget>[ ListTile( leading: Icon( Icons.person, color: Colors.grey, ), title: Text("Account"), trailing: Icon(Icons.arrow_right), ), ListTile( leading: Icon( Icons.mail, color: Colors.red, ), title: Text("Gmail"), trailing: Icon(Icons.arrow_right), ), ListTile( leading: Icon( Icons.sync, color: Colors.blue, ), title: Text("Sync Data"), trailing: Icon(Icons.arrow_right), ) ], ), ), //2 Padding( padding: const EdgeInsets.all(16.0), child: Text( "Network", style: TextStyle(color: Colors.grey.shade700), ), ), Card( color: Colors.white, elevation: 2.0, child: Column( children: <Widget>[ ListTile( leading: Icon( Icons.sim_card, color: Colors.grey, ), title: Text("Simcard & Network"), trailing: Icon(Icons.arrow_right), ), ListTile( leading: Icon( Icons.wifi, color: Colors.amber, ), title: Text("Wifi"), trailing: CommonSwitch( defValue: true, )), ListTile( leading: Icon( Icons.bluetooth, color: Colors.blue, ), title: Text("Bluetooth"), trailing: CommonSwitch( defValue: false, ), ), ListTile( leading: Icon( Icons.more_horiz, color: Colors.grey, ), title: Text("More"), trailing: Icon(Icons.arrow_right), ), ], ), ), //3 Padding( padding: const EdgeInsets.all(16.0), child: Text( "Sound", style: TextStyle(color: Colors.grey.shade700), ), ), Card( color: Colors.white, elevation: 2.0, child: Column( children: <Widget>[ ListTile( leading: Icon( Icons.do_not_disturb_off, color: Colors.orange, ), title: Text("Silent Mode"), trailing: CommonSwitch( defValue: false, ), ), ListTile( leading: Icon( Icons.vibration, color: Colors.purple, ), title: Text("Vibrate Mode"), trailing: CommonSwitch( defValue: true, ), ), ListTile( leading: Icon( Icons.volume_up, color: Colors.green, ), title: Text("Sound Volume"), trailing: Icon(Icons.arrow_right), ), ListTile( leading: Icon( Icons.phonelink_ring, color: Colors.grey, ), title: Text("Ringtone"), trailing: Icon(Icons.arrow_right), ) ], ), ), ], ), ), ); @override Widget build(BuildContext context) { return CommonScaffold( appTitle: "Device Settings", showDrawer: false, showFAB: false, backGroundColor: Colors.grey.shade300, bodyData: bodyData(), ); } }
Flutter-UI-Kit/lib/ui/page/settings/settings_one_page.dart/0
{ "file_path": "Flutter-UI-Kit/lib/ui/page/settings/settings_one_page.dart", "repo_id": "Flutter-UI-Kit", "token_count": 3899 }
11
import 'package:flutter/material.dart'; import 'package:flutter_uikit/ui/widgets/about_tile.dart'; import 'package:flutter_uikit/utils/uidata.dart'; class CommonDrawer extends StatelessWidget { @override Widget build(BuildContext context) { return Drawer( child: ListView( padding: EdgeInsets.zero, children: <Widget>[ UserAccountsDrawerHeader( accountName: Text( "Pawan Kumar", ), accountEmail: Text( "mtechviral@gmail.com", ), currentAccountPicture: new CircleAvatar( backgroundImage: new AssetImage(UIData.pkImage), ), ), new ListTile( title: Text( "Profile", style: TextStyle(fontWeight: FontWeight.w700, fontSize: 18.0), ), leading: Icon( Icons.person, color: Colors.blue, ), ), new ListTile( title: Text( "Shopping", style: TextStyle(fontWeight: FontWeight.w700, fontSize: 18.0), ), leading: Icon( Icons.shopping_cart, color: Colors.green, ), ), new ListTile( title: Text( "Dashboard", style: TextStyle(fontWeight: FontWeight.w700, fontSize: 18.0), ), leading: Icon( Icons.dashboard, color: Colors.red, ), ), new ListTile( title: Text( "Timeline", style: TextStyle(fontWeight: FontWeight.w700, fontSize: 18.0), ), leading: Icon( Icons.timeline, color: Colors.cyan, ), ), Divider(), new ListTile( title: Text( "Settings", style: TextStyle(fontWeight: FontWeight.w700, fontSize: 18.0), ), leading: Icon( Icons.settings, color: Colors.brown, ), ), Divider(), MyAboutTile() ], ), ); } }
Flutter-UI-Kit/lib/ui/widgets/common_drawer.dart/0
{ "file_path": "Flutter-UI-Kit/lib/ui/widgets/common_drawer.dart", "repo_id": "Flutter-UI-Kit", "token_count": 1270 }
12
import 'package:flutter/material.dart'; import 'package:flutter_mates/ui/friends/friends_list_page.dart'; void main() { runApp(new MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return new MaterialApp( theme: new ThemeData( primarySwatch: Colors.blue, accentColor: const Color(0xFFF850DD), ), home: new FriendsListPage(), ); } }
FlutterMates/lib/main.dart/0
{ "file_path": "FlutterMates/lib/main.dart", "repo_id": "FlutterMates", "token_count": 166 }
13
library beautiful_popup; import 'dart:typed_data'; import 'package:flutter/material.dart'; import 'dart:ui' as ui; import 'package:image/image.dart' as img; import 'package:flutter/services.dart'; import 'templates/Common.dart'; import 'templates/OrangeRocket.dart'; import 'templates/GreenRocket.dart'; import 'templates/OrangeRocket2.dart'; import 'templates/Coin.dart'; import 'templates/BlueRocket.dart'; import 'templates/Thumb.dart'; import 'templates/Gift.dart'; import 'templates/Camera.dart'; import 'templates/Notification.dart'; import 'templates/Geolocation.dart'; import 'templates/Success.dart'; import 'templates/Fail.dart'; import 'templates/Authentication.dart'; import 'templates/Term.dart'; import 'templates/RedPacket.dart'; export 'templates/Common.dart'; export 'templates/OrangeRocket.dart'; export 'templates/GreenRocket.dart'; export 'templates/OrangeRocket2.dart'; export 'templates/Coin.dart'; export 'templates/BlueRocket.dart'; export 'templates/Thumb.dart'; export 'templates/Gift.dart'; export 'templates/Camera.dart'; export 'templates/Notification.dart'; export 'templates/Geolocation.dart'; export 'templates/Success.dart'; export 'templates/Fail.dart'; export 'templates/Authentication.dart'; export 'templates/Term.dart'; export 'templates/RedPacket.dart'; class BeautifulPopup { BuildContext _context; BuildContext get context => _context; Type? _template; Type? get template => _template; BeautifulPopupTemplate Function(BeautifulPopup options)? _build; BeautifulPopupTemplate get instance { final build = _build; if (build != null) return build(this); switch (template) { case TemplateOrangeRocket: return TemplateOrangeRocket(this); case TemplateGreenRocket: return TemplateGreenRocket(this); case TemplateOrangeRocket2: return TemplateOrangeRocket2(this); case TemplateCoin: return TemplateCoin(this); case TemplateBlueRocket: return TemplateBlueRocket(this); case TemplateThumb: return TemplateThumb(this); case TemplateGift: return TemplateGift(this); case TemplateCamera: return TemplateCamera(this); case TemplateNotification: return TemplateNotification(this); case TemplateGeolocation: return TemplateGeolocation(this); case TemplateSuccess: return TemplateSuccess(this); case TemplateFail: return TemplateFail(this); case TemplateAuthentication: return TemplateAuthentication(this); case TemplateTerm: return TemplateTerm(this); case TemplateRedPacket: default: return TemplateRedPacket(this); } } ui.Image? _illustration; ui.Image? get illustration => _illustration; dynamic title = ''; dynamic content = ''; List<Widget>? actions; Widget? close; bool? barrierDismissible; Color? primaryColor; BeautifulPopup({ required BuildContext context, required Type? template, }) : _context = context, _template = template { primaryColor = instance.primaryColor; // Get the default primary color. } static BeautifulPopup customize({ required BuildContext context, required BeautifulPopupTemplate Function(BeautifulPopup options) build, }) { final popup = BeautifulPopup( context: context, template: null, ); popup._build = build; return popup; } /// Recolor the BeautifulPopup. /// This method is kind of slow.R Future<BeautifulPopup> recolor(Color color) async { this.primaryColor = color; final illustrationData = await rootBundle.load(instance.illustrationKey); final buffer = illustrationData.buffer.asUint8List(); img.Image? asset; asset = img.readPng(buffer); if (asset != null) { img.adjustColor( asset, saturation: 0, // hue: 0, ); img.colorOffset( asset, red: color.red, // I don't know why the effect is nicer with the number ╮(╯▽╰)╭ green: color.green ~/ 3, blue: color.blue ~/ 2, alpha: 0, ); } final paint = await PaintingBinding.instance?.instantiateImageCodec( asset != null ? Uint8List.fromList(img.encodePng(asset)) : buffer); final nextFrame = await paint?.getNextFrame(); _illustration = nextFrame?.image; return this; } /// `title`: Must be a `String` or `Widget`. Defaults to `''`. /// /// `content`: Must be a `String` or `Widget`. Defaults to `''`. /// /// `actions`: The set of actions that are displaed at bottom of the dialog, /// /// Typically this is a list of [BeautifulPopup.button]. Defaults to `[]`. /// /// `barrierDismissible`: Determine whether this dialog can be dismissed. Default to `False`. /// /// `close`: Close widget. Future<T?> show<T>({ dynamic title, dynamic content, List<Widget>? actions, bool barrierDismissible = false, Widget? close, }) { this.title = title; this.content = content; this.actions = actions; this.barrierDismissible = barrierDismissible; this.close = close ?? instance.close; final child = WillPopScope( onWillPop: () { return Future.value(barrierDismissible); }, child: instance, ); return showGeneralDialog<T>( barrierColor: Colors.black38, barrierDismissible: barrierDismissible, barrierLabel: barrierDismissible ? 'beautiful_popup' : null, context: context, pageBuilder: (context, animation1, animation2) { return child; }, transitionDuration: Duration(milliseconds: 150), transitionBuilder: (ctx, a1, a2, child) { return Transform.scale( scale: a1.value, child: Opacity( opacity: a1.value, child: child, ), ); }, ); } BeautifulPopupButton get button => instance.button; }
Flutter_beautiful_popup/lib/main.dart/0
{ "file_path": "Flutter_beautiful_popup/lib/main.dart", "repo_id": "Flutter_beautiful_popup", "token_count": 2207 }
14
import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'Common.dart'; import '../main.dart'; import 'package:auto_size_text/auto_size_text.dart'; /// ![](https://raw.githubusercontent.com/jaweii/Flutter_beautiful_popup/master/img/bg/thumb.png) class TemplateThumb extends BeautifulPopupTemplate { final BeautifulPopup options; TemplateThumb(this.options) : super(options); @override final illustrationPath = 'img/bg/thumb.png'; @override Color get primaryColor => options.primaryColor ?? Color(0xfffb675d); @override final maxWidth = 400; @override final maxHeight = 570; @override final bodyMargin = 0; @override Widget get title { if (options.title is Widget) { return SizedBox( width: percentW(54), height: percentH(10), child: options.title, ); } return SizedBox( width: percentW(54), child: Opacity( opacity: 0.9, child: AutoSizeText( options.title, maxLines: 1, style: TextStyle( fontSize: Theme.of(options.context).textTheme.headline6?.fontSize, color: Colors.white, fontWeight: FontWeight.bold, ), ), ), ); } @override BeautifulPopupButton get button { return ({ required String label, required void Function() onPressed, bool outline = false, bool flat = false, TextStyle labelStyle = const TextStyle(), }) { final gradient = LinearGradient(colors: [ primaryColor.withOpacity(0.5), primaryColor, ]); final double elevation = (outline || flat) ? 0 : 2; final labelColor = (outline || flat) ? primaryColor : Colors.white.withOpacity(0.95); final decoration = BoxDecoration( gradient: (outline || flat) ? null : gradient, borderRadius: BorderRadius.all(Radius.circular(80.0)), border: Border.all( color: outline ? primaryColor : Colors.transparent, width: (outline && !flat) ? 1 : 0, ), ); final minHeight = 40.0 - (outline ? 2 : 0); return RaisedButton( color: Colors.transparent, elevation: elevation, highlightElevation: 0, splashColor: Colors.transparent, child: Ink( decoration: decoration, child: Container( constraints: BoxConstraints( minWidth: 100, minHeight: minHeight, ), alignment: Alignment.center, child: Text( label, style: TextStyle( color: Colors.white.withOpacity(0.95), ).merge(labelStyle), ), ), ), padding: EdgeInsets.all(0), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(50), ), onPressed: onPressed, ); }; } @override get layout { return [ Positioned( child: background, ), Positioned( top: percentH(10), left: percentW(10), child: title, ), Positioned( top: percentH(28), left: percentW(10), right: percentW(10), height: percentH(actions == null ? 62 : 50), child: content, ), Positioned( bottom: percentW(14), left: percentW(10), right: percentW(10), child: actions ?? Container(), ), ]; } }
Flutter_beautiful_popup/lib/templates/Thumb.dart/0
{ "file_path": "Flutter_beautiful_popup/lib/templates/Thumb.dart", "repo_id": "Flutter_beautiful_popup", "token_count": 1609 }
15
manifest.json,1641774262310,f81e4554dc7f05633a2c5597416813859de5ace688342db41b201d42790fb8a7 flutter_service_worker.js,1641774661603,4ba5e20515b0200b83b1139b8fa2a5bfd7449edcd218a558fdf13850e835d26e index.html,1641774661196,5780182119495d698400b870b9ade8a4b236147acadd7ae1217483b19ce7dd1d assets/AssetManifest.json,1641774661189,e1765baf5f9582d7f51cb137538999d143b3054c36c13a0eecaa940b3079e566 version.json,1641774661094,2f06c1ff01b63ded25d9e999e5651966d897994731d5fc924f36d69cf29d9a41 assets/FontManifest.json,1641774661189,9ea504185602e57d97b7c3517d382b8627a13c0181c490c96a9b55a5d5c8810c favicon.png,1631367171538,fcc7c4545d5b62ad01682589e6fdc7ea03d0a3b42069963c815c344b632eb5cf icons/Icon-192.png,1631367171538,d2e0131bb7851eb9d98f7885edb5ae4b4d6b7a6c7addf8a25b9b712b39274c0f icons/Icon-512.png,1631367171538,7a31ce91e554f1941158ca46f31c7f3f2b7c8c129229ea74a8fae1affe335033 icons/Icon-maskable-192.png,1631367222753,dd96c123fdf6817cdf7e63d9693bcc246bac2e3782a41a6952fa41c0617c5573 icons/Icon-maskable-512.png,1631367222738,e7983524dc70254adc61764657d7e03d19284de8da586b5818d737bc08c6d14e canvaskit/canvaskit.js,315426600000,332d67a51b86f5129fc7d929d6bb6bd0416b17fd853899efc1f5044770954ed6 canvaskit/profiling/canvaskit.js,315426600000,41ae97b4ac8a386f55b22f1962c7b564da96df256fd938d684e73a8061e70b61 assets/packages/cupertino_icons/assets/CupertinoIcons.ttf,1636501093570,3064af137aeffc9011ba060601a01177b279963822310a778aeafa74c209732c assets/NOTICES,1641774661190,795a16e06e6dfd87b3ea62658b7b447bc99bb82b8a6f16f39c4dad17c6a9a488 assets/fonts/MaterialIcons-Regular.otf,1615596762000,5f71a8843e4edc9656c39061c2232458a6fc77e1603305960e4efa9c77f8b7a2 main.dart.js,1641774660616,0db953825ec2f14f8cc2a386d8daed616effc5dda307b286f12931fd88be27b2 canvaskit/canvaskit.wasm,315426600000,8dae2a06cf716711e3578aa55ee7b03ccdc54b4bdc9be9ee50c33515d2b3a7fe canvaskit/profiling/canvaskit.wasm,315426600000,cb4c2221f1c20811ac3a33666833b4458656193de55b276b3c8fc31856b2f3a0
Liquid-Pull-To-Refresh/example/.firebase/hosting.YnVpbGQvd2Vi.cache/0
{ "file_path": "Liquid-Pull-To-Refresh/example/.firebase/hosting.YnVpbGQvd2Vi.cache", "repo_id": "Liquid-Pull-To-Refresh", "token_count": 1065 }
16
name: liquid_pull_to_refresh description: A beautiful and custom refresh indicator with some cool animations and transitions for flutter. version: 3.0.1 homepage: https://github.com/aagarwal1012/Liquid-Pull-To-Refresh/ environment: sdk: '>=2.12.0 <3.0.0' dependencies: flutter: sdk: flutter dev_dependencies: flutter_test: sdk: flutter flutter:
Liquid-Pull-To-Refresh/pubspec.yaml/0
{ "file_path": "Liquid-Pull-To-Refresh/pubspec.yaml", "repo_id": "Liquid-Pull-To-Refresh", "token_count": 133 }
17
class CardMessage { String id; String avatar; String name; String message; String time; CardMessage({this.id, this.avatar, this.name, this.message, this.time}); factory CardMessage.fromJson(Map<String, dynamic> json) { return CardMessage( id: json["id"], avatar: json['avatar'], name: json['name'], message: json['message'], time: json['time'], ); } }
animated_selection_slide/lib/model.dart/0
{ "file_path": "animated_selection_slide/lib/model.dart", "repo_id": "animated_selection_slide", "token_count": 158 }
18
## 3.0.0 - Upgraded to null safety ## 2.1.0 - Added `textKey` parameter ## 2.0.2+1 - Fixed screenshots ## 2.0.2 - Fixed bug where `textScaleFactor` was not taken into account (thanks @Kavantix) ## 2.0.1 - Allow fractional font sizes again - Fixed bug with `wrapWords` not working ## 2.0.0+2 - Added logo ## 2.0.0 - Significant performance improvements - Prevent word wrapping using `wordWrap: false` - Replacement widget in case of text overflow: `overflowReplacement` - Added `strutStyle` parameter from `Text` - Fixed problem in case the `AutoSizeTextGroup` changes - Improved documentation - Added many more tests ## 1.1.2 - Fixed bug where system font scale was applied twice (thanks @jeffersonatsafe) ## 1.1.1 - Fixed bug where setting the style of a `TextSpan` to null in `AutoSizeText.rich` didn't work (thanks @Koridev) - Allow `minFontSize = 0` ## 1.1.0 - Added `group` parameter and `AutoSizeGroup` to synchronize multiple `AutoSizeText`s - Fixed bug where `minFontSize` was not used correctly - Improved documentation ## 1.0.0 - Library is used in multiple projects in production and is considered stable now. - Added more tests ## 0.3.0 - Added textScaleFactor property with fallback to `MediaQuery.textScaleFactorOf()` (thanks @jeroentrappers) ## 0.2.2 - Fixed tests - Improved documentation ## 0.2.1 - Fixed problem with `minFontSize` and `maxFontSize` (thanks @apaatsio) ## 0.2.0 - Added support for Rich Text using `AutoSizeText.rich()` with one or multiple `TextSpan`s. - Improved text size calculation (using `textScaleFactor`) ## 0.1.0 - Fixed documentation (thanks @g-balas) - Added tests ## 0.0.2 - Fixed documentation - Added example ## 0.0.1 - First Release
auto_size_text/CHANGELOG.md/0
{ "file_path": "auto_size_text/CHANGELOG.md", "repo_id": "auto_size_text", "token_count": 537 }
19
name: example description: AutoSizeText example version: 1.0.0 environment: sdk: '>=2.12.0-0 <3.0.0' dependencies: flutter: sdk: flutter auto_size_text: path: ../ dev_dependencies: flutter_test: sdk: flutter flutter: uses-material-design: true publish_to: none
auto_size_text/example/pubspec.yaml/0
{ "file_path": "auto_size_text/example/pubspec.yaml", "repo_id": "auto_size_text", "token_count": 126 }
20
import 'package:auto_size_text/auto_size_text.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'utils.dart'; void main() { testWidgets('Do not wrap words', (tester) async { await pumpAndExpectFontSize( tester: tester, expectedFontSize: 20, widget: SizedBox( width: 100, child: AutoSizeText( 'XXXXX XXXXX', style: TextStyle(fontSize: 25), wrapWords: false, ), ), ); var height = tester.getSize(find.byType(RichText)).height; expect(height, 40); await pumpAndExpectFontSize( tester: tester, expectedFontSize: 10, widget: SizedBox( width: 40, child: AutoSizeText( 'XXXXX', style: TextStyle(fontSize: 25), minFontSize: 10, maxLines: 10, wrapWords: false, ), ), ); height = tester.getSize(find.byType(RichText)).height; expect(height, 20); }); testWidgets('Wrap words', (tester) async { await pumpAndExpectFontSize( tester: tester, expectedFontSize: 30, widget: SizedBox( width: 90, child: AutoSizeText( 'XXXXXX', style: TextStyle(fontSize: 40), maxLines: 2, ), ), ); final height = tester.getSize(find.byType(RichText)).height; expect(height, 60); }); }
auto_size_text/test/wrap_words_test.dart/0
{ "file_path": "auto_size_text/test/wrap_words_test.dart", "repo_id": "auto_size_text", "token_count": 667 }
21
import 'package:backdrop/backdrop.dart'; import 'package:flutter/material.dart'; /// Contextual info preview app. class ContextualInfo extends StatelessWidget { /// Default constructor for [ContextualInfo]. const ContextualInfo({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Theme( data: ThemeData.light(), child: BackdropScaffold( appBar: BackdropAppBar( title: const Text("Contextual Info Example"), automaticallyImplyLeading: false, ), backLayer: _createBackLayer(context), frontLayer: _createFrontLayer(context), stickyFrontLayer: true, ), ); } Widget _createBackLayer(BuildContext context) => ListView( shrinkWrap: true, children: const [ ListTile( leading: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( "Name", ), ], ), title: Text( "Laptop Model X", style: TextStyle(fontWeight: FontWeight.bold), ), ), ListTile( leading: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text("Year of production"), ], ), title: Text( "2019", style: TextStyle(fontWeight: FontWeight.bold), ), ), ListTile( leading: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text("Place of Manufacture"), ], ), title: Text( "USA", style: TextStyle(fontWeight: FontWeight.bold), ), ), ListTile( leading: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text("Price"), ], ), title: Text( "\$999", style: TextStyle(fontWeight: FontWeight.bold), ), ), ], ); Widget _createFrontLayer(BuildContext context) => Container( margin: const EdgeInsets.all(16.0), child: Column( children: [ Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ const Icon( Icons.computer, size: 64.0, ), Text( "Laptop", style: Theme.of(context) .textTheme .displaySmall! .apply(color: Colors.black), ), ], ), Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.center, children: [ const Text( "Price", style: TextStyle(color: Colors.grey), ), Container( margin: const EdgeInsets.all(8.0), child: const Text( "\$999", style: TextStyle(fontSize: 18), ), ), ], ), Container( margin: const EdgeInsets.all(8.0), child: const Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Row( children: [ Icon(Icons.star, color: Colors.grey), Icon(Icons.star, color: Colors.grey), Icon(Icons.star, color: Colors.grey), Icon(Icons.star, color: Colors.grey), Icon(Icons.star_half, color: Colors.grey), ], ), Text( "73 Reviews", style: TextStyle(color: Colors.grey), ) ], ), ), Container( margin: const EdgeInsets.all(16.0), child: Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ Builder( builder: (context) => ElevatedButton( child: const Text("More about this product"), onPressed: () => Backdrop.of(context).fling(), ), ) ], ), ), ListTile( title: Text("Reviews", style: Theme.of(context) .textTheme .titleLarge! .apply(color: Colors.black)), ), const ListTile( leading: Icon(Icons.account_box), title: Text("Really satisfied!"), subtitle: Text("John Doe"), trailing: Text("5/5"), ), const ListTile( leading: Icon(Icons.account_box), title: Text("Good price!"), subtitle: Text("Jane Doe"), trailing: Text("4.5/5"), ) ], ), ); }
backdrop/demo/lib/use_cases/contextual_info/contextual_info.dart/0
{ "file_path": "backdrop/demo/lib/use_cases/contextual_info/contextual_info.dart", "repo_id": "backdrop", "token_count": 3272 }
22
# example A new Flutter project. ## Getting Started For help getting started with Flutter, view our online [documentation](https://flutter.io/).
backdrop/example/README.md/0
{ "file_path": "backdrop/example/README.md", "repo_id": "backdrop", "token_count": 42 }
23
#!/usr/bin/env bash ############################################################################## ## ## Gradle start up script for UN*X ## ############################################################################## # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS="" APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" warn ( ) { echo "$*" } die ( ) { echo echo "$*" echo exit 1 } # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false case "`uname`" in CYGWIN* ) cygwin=true ;; Darwin* ) darwin=true ;; MINGW* ) msys=true ;; esac # Attempt to set APP_HOME # Resolve links: $0 may be a link PRG="$0" # Need this for relative symlinks. while [ -h "$PRG" ] ; do ls=`ls -ld "$PRG"` link=`expr "$ls" : '.*-> \(.*\)$'` if expr "$link" : '/.*' > /dev/null; then PRG="$link" else PRG=`dirname "$PRG"`"/$link" fi done SAVED="`pwd`" cd "`dirname \"$PRG\"`/" >/dev/null APP_HOME="`pwd -P`" cd "$SAVED" >/dev/null CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables JAVACMD="$JAVA_HOME/jre/sh/java" else JAVACMD="$JAVA_HOME/bin/java" fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else JAVACMD="java" which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi # Increase the maximum file descriptors if we can. if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then MAX_FD_LIMIT=`ulimit -H -n` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then MAX_FD="$MAX_FD_LIMIT" fi ulimit -n $MAX_FD if [ $? -ne 0 ] ; then warn "Could not set maximum file descriptor limit: $MAX_FD" fi else warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" fi fi # For Darwin, add options to specify how the application appears in the dock if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi # For Cygwin, switch paths to Windows format before running java if $cygwin ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` SEP="" for dir in $ROOTDIRSRAW ; do ROOTDIRS="$ROOTDIRS$SEP$dir" SEP="|" done OURCYGPATTERN="(^($ROOTDIRS))" # Add a user-defined pattern to the cygpath arguments if [ "$GRADLE_CYGPATTERN" != "" ] ; then OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" fi # Now convert the arguments - kludge to limit ourselves to /bin/sh i=0 for arg in "$@" ; do CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` else eval `echo args$i`="\"$arg\"" fi i=$((i+1)) done case $i in (0) set -- ;; (1) set -- "$args0" ;; (2) set -- "$args0" "$args1" ;; (3) set -- "$args0" "$args1" "$args2" ;; (4) set -- "$args0" "$args1" "$args2" "$args3" ;; (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules function splitJvmOpts() { JVM_OPTS=("$@") } eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
backdrop/example/android/gradlew/0
{ "file_path": "backdrop/example/android/gradlew", "repo_id": "backdrop", "token_count": 2233 }
24
import 'package:backdrop/backdrop.dart'; import 'package:flutter/material.dart'; /// A wrapper for adding a sub-header to the used backdrop front layer(s). /// /// This class can be passed to [BackdropScaffold] to specify the sub-header /// that should be shown while the front layer is "inactive" (the back layer is /// "showing"). /// /// Usage example: /// ```dart /// BackdropScaffold( /// appBar: ..., /// backLayer: ..., /// subHeader: BackdropSubHeader( /// title: Text("Sub Header"), /// ), /// frontLayer: ..., /// ) /// ``` class BackdropSubHeader extends StatelessWidget { /// The primary content of the sub-header. final Widget title; /// The divider that should be shown at the bottom of the sub-header. /// /// Defaults to `Divider(height: 4.0, indent: 16.0, endIndent: 16.0)`. final Widget? divider; /// Padding that will be applied to the sub-header. /// /// Defaults to `EdgeInsets.symmetric(vertical: 12.0, horizontal: 16.0)`. final EdgeInsets padding; /// Flag indicating whether to add default leading widget. /// /// If set to `true`, a leading `Icon(Icons.keyboard_arrow_up)` is added to /// the sub-header. /// /// Defaults to `false`. final bool automaticallyImplyLeading; /// Flag indicating whether to add default trailing widget. /// /// If set to `true`, a trailing `Icon(Icons.keyboard_arrow_up)` is added to /// the sub-header. /// /// Defaults to `true`. final bool automaticallyImplyTrailing; /// Widget to be shown as leading element to the sub-header. /// /// If set, the value of [automaticallyImplyLeading] is ignored. final Widget? leading; /// Widget to be shown as trailing element to the sub-header. /// /// If set, the value of [automaticallyImplyTrailing] is ignored. final Widget? trailing; /// Creates a [BackdropSubHeader] instance. /// /// The [title] argument must not be `null`. const BackdropSubHeader({ Key? key, required this.title, this.divider, this.padding = const EdgeInsets.symmetric(vertical: 12.0, horizontal: 16.0), this.automaticallyImplyLeading = false, this.automaticallyImplyTrailing = true, this.leading, this.trailing, }) : super(key: key); @override Widget build(BuildContext context) { Widget buildAutomaticLeadingOrTrailing(BuildContext context) => FadeTransition( opacity: Tween(begin: 1.0, end: 0.0) .animate(Backdrop.of(context).animationController), child: const Icon(Icons.keyboard_arrow_up), ); return Column( mainAxisSize: MainAxisSize.min, children: <Widget>[ Padding( padding: padding, child: Row( children: <Widget>[ leading ?? (automaticallyImplyLeading ? buildAutomaticLeadingOrTrailing(context) : Container()), Expanded( child: title, ), trailing ?? (automaticallyImplyTrailing ? buildAutomaticLeadingOrTrailing(context) : Container()), ], ), ), divider ?? const Divider(height: 4.0, indent: 16.0, endIndent: 16.0), ], ); } }
backdrop/lib/src/sub_header.dart/0
{ "file_path": "backdrop/lib/src/sub_header.dart", "repo_id": "backdrop", "token_count": 1297 }
25
<?xml version="1.0" encoding="utf-8"?> <!-- Modify this file to customize your launch splash screen --> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="?android:colorBackground" /> <!-- You can insert your own image assets here --> <!-- <item> <bitmap android:gravity="center" android:src="@mipmap/launch_image" /> </item> --> </layer-list>
before_after/example/android/app/src/main/res/drawable-v21/launch_background.xml/0
{ "file_path": "before_after/example/android/app/src/main/res/drawable-v21/launch_background.xml", "repo_id": "before_after", "token_count": 166 }
26
import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import '../before_after.dart'; /// A custom painter for rendering a slider. /// /// The `SliderPainter` class is a custom painter that renders a slider with a track and a thumb. /// It extends the [ChangeNotifier] class and implements the [CustomPainter] class. /// /// The slider can be configured with various properties such as the axis (horizontal or vertical), /// the current value, track width and color, thumb size and decoration, and more. /// /// Example usage: /// /// ```dart /// SliderPainter painter = SliderPainter( /// overlayAnimation: AnimationController( /// vsync: this, /// duration: Duration(milliseconds: 100), /// ), /// ); /// painter.axis = SliderAxis.horizontal; /// painter.value = 0.5; /// painter.trackWidth = 4.0; /// painter.trackColor = Colors.grey; /// painter.thumbValue = 0.5; /// painter.thumbWidth = 20.0; /// painter.thumbHeight = 40.0; /// painter.thumbDecoration = BoxDecoration( /// color: Colors.blue, /// shape: BoxShape.circle, /// ); /// /// CustomPaint( /// painter: painter, /// child: Container( /// // Child widget /// ), /// ) /// ``` class SliderPainter extends ChangeNotifier implements CustomPainter { /// Creates a slider painter. SliderPainter({ required Animation<double> overlayAnimation, ValueSetter<Rect>? onThumbRectChanged, }) : _overlayAnimation = overlayAnimation, _onThumbRectChanged = onThumbRectChanged { _overlayAnimation.addListener(notifyListeners); } /// The animation of the thumb overlay. final Animation<double> _overlayAnimation; /// Callback to notify when the thumb rect changes. final ValueSetter<Rect>? _onThumbRectChanged; /// The axis of the slider. SliderDirection get axis => _axis!; SliderDirection? _axis; set axis(SliderDirection value) { if (_axis != value) { _axis = value; notifyListeners(); } } /// The current value of the slider. double get value => _value!; double? _value; set value(double value) { if (_value != value) { _value = value; notifyListeners(); } } /// The width of the track. double get trackWidth => _trackWidth!; double? _trackWidth; set trackWidth(double value) { if (_trackWidth != value) { _trackWidth = value; notifyListeners(); } } /// The color of the track. Color get trackColor => _trackColor!; Color? _trackColor; set trackColor(Color value) { if (_trackColor != value) { _trackColor = value; notifyListeners(); } } /// The value of the thumb. double get thumbValue => _thumbValue!; double? _thumbValue; set thumbValue(double value) { if (_thumbValue != value) { _thumbValue = value; notifyListeners(); } } /// The width of the thumb. double get thumbWidth => _thumbWidth!; double? _thumbWidth; set thumbWidth(double value) { if (_thumbWidth != value) { _thumbWidth = value; notifyListeners(); } } /// The height of the thumb. double get thumbHeight => _thumbHeight!; double? _thumbHeight; set thumbHeight(double value) { if (_thumbHeight != value) { _thumbHeight = value; notifyListeners(); } } /// The color of the thumb overlay. Color get overlayColor => _overlayColor!; Color? _overlayColor; set overlayColor(Color value) { if (_overlayColor != value) { _overlayColor = value; notifyListeners(); } } /// The decoration of the thumb. BoxDecoration get thumbDecoration => _thumbDecoration!; BoxDecoration? _thumbDecoration; set thumbDecoration(BoxDecoration? value) { if (_thumbDecoration != value) { _thumbDecoration = value; // Dispose and reset the thumb painter if it exists. _thumbPainter?.dispose(); _thumbPainter = null; notifyListeners(); } } /// The image configuration for the thumb. ImageConfiguration get configuration => _configuration!; ImageConfiguration? _configuration; set configuration(ImageConfiguration value) { if (_configuration != value) { _configuration = value; notifyListeners(); } } /// Whether to hide the thumb. bool get hideThumb => _hideThumb!; bool? _hideThumb; set hideThumb(bool value) { if (_hideThumb != value) { _hideThumb = value; notifyListeners(); } } @override void paint(Canvas canvas, Size size) { // Clip the canvas to the size of the slider so that we don't draw outside. canvas.clipRect(Rect.fromLTWH(0, 0, size.width, size.height)); final isHorizontal = axis == SliderDirection.horizontal; final trackPaint = Paint() ..color = trackColor ..strokeWidth = trackWidth; // If the thumb is hidden, draw a straight line. if (hideThumb) { return canvas.drawLine( Offset( isHorizontal ? size.width * value : 0.0, isHorizontal ? 0.0 : size.height * value, ), Offset( isHorizontal ? size.width * value : size.width, isHorizontal ? size.height : size.height * value, ), trackPaint, ); } // Draw track (first and second half). canvas ..drawLine( Offset( isHorizontal ? size.width * value : 0.0, isHorizontal ? 0.0 : size.height * value, ), Offset( isHorizontal ? size.width * value : size.width * thumbValue - (thumbHeight / 2), isHorizontal ? size.height * thumbValue - (thumbHeight / 2) : size.height * value, ), trackPaint, ) ..drawLine( Offset( isHorizontal ? size.width * value : size.width * thumbValue + thumbHeight / 2, isHorizontal ? size.height * thumbValue + thumbHeight / 2 : size.height * value, ), Offset( isHorizontal ? size.width * value : size.width, isHorizontal ? size.height : size.height * value, ), trackPaint, ); // Calculate the thumb rect. final thumbRect = Rect.fromCenter( center: Offset( isHorizontal ? size.width * value : size.width * thumbValue, isHorizontal ? size.height * thumbValue : size.height * value, ), width: isHorizontal ? thumbWidth : thumbHeight, height: isHorizontal ? thumbHeight : thumbWidth, ); // Notify the listener of the thumb rect. _onThumbRectChanged?.call(thumbRect); // Draw the thumb overlay. if (!_overlayAnimation.isDismissed) { const lengthMultiplier = 2; final overlayRect = Rect.fromCenter( center: thumbRect.center, width: thumbRect.width * lengthMultiplier * _overlayAnimation.value, height: thumbRect.height * lengthMultiplier * _overlayAnimation.value, ); // Draw the overlay. _drawOverlay(canvas, overlayRect); } // Draw the thumb. _drawThumb(canvas, thumbRect); } void _drawOverlay(Canvas canvas, Rect overlayRect) { Path? overlayPath; switch (thumbDecoration.shape) { case BoxShape.circle: assert(thumbDecoration.borderRadius == null); final Offset center = overlayRect.center; final double radius = overlayRect.shortestSide / 2.0; final Rect square = Rect.fromCircle(center: center, radius: radius); overlayPath = Path()..addOval(square); break; case BoxShape.rectangle: if (thumbDecoration.borderRadius == null || thumbDecoration.borderRadius == BorderRadius.zero) { overlayPath = Path()..addRect(overlayRect); } else { overlayPath = Path() ..addRRect(thumbDecoration.borderRadius! .resolve(configuration.textDirection) .toRRect(overlayRect)); } break; } canvas.drawPath(overlayPath, Paint()..color = overlayColor); } bool _isPainting = false; void _handleThumbChange() { // If the thumb decoration is available synchronously, we'll get called here // during paint. There's no reason to mark ourselves as needing paint if we // are already in the middle of painting. (In fact, doing so would trigger // an assert). if (!_isPainting) { notifyListeners(); } } BoxPainter? _thumbPainter; void _drawThumb(Canvas canvas, Rect thumbRect) { try { _isPainting = true; if (_thumbPainter == null) { _thumbPainter?.dispose(); _thumbPainter = thumbDecoration.createBoxPainter(_handleThumbChange); } final config = configuration.copyWith(size: thumbRect.size); _thumbPainter!.paint(canvas, thumbRect.topLeft, config); } finally { _isPainting = false; } } @override void dispose() { _thumbPainter?.dispose(); _thumbPainter = null; _overlayAnimation.removeListener(notifyListeners); super.dispose(); } @override bool shouldRepaint(covariant SliderPainter oldDelegate) => false; @override bool? hitTest(Offset position) => null; @override SemanticsBuilderCallback? get semanticsBuilder => null; @override bool shouldRebuildSemantics(covariant CustomPainter oldDelegate) => false; @override String toString() => describeIdentity(this); }
before_after/lib/src/slider_painter.dart/0
{ "file_path": "before_after/lib/src/slider_painter.dart", "repo_id": "before_after", "token_count": 3588 }
27
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility that Flutter provides. 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:bitmap_example/main.dart'; void main() { testWidgets('Verify Platform version', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(MyApp()); // Verify that platform version is retrieved. expect( find.byWidgetPredicate( (Widget widget) => widget is Text && widget.data!.startsWith('Running on:'), ), findsOneWidget, ); }); }
bitmap/example/test/widget_test.dart/0
{ "file_path": "bitmap/example/test/widget_test.dart", "repo_id": "bitmap", "token_count": 288 }
28
import '../bitmap.dart'; export 'adjust_color.dart'; export 'brightness.dart'; export 'contrast.dart'; export 'crop.dart'; export 'flip.dart'; export 'resize.dart'; export 'rgb_overlay.dart'; export 'rotation.dart'; abstract class BitmapOperation { Bitmap applyTo(Bitmap bitmap); }
bitmap/lib/src/operation/operation.dart/0
{ "file_path": "bitmap/lib/src/operation/operation.dart", "repo_id": "bitmap", "token_count": 109 }
29
org.gradle.jvmargs=-Xmx1536M android.useAndroidX=true android.enableJetifier=true
bottom_navy_bar/example/android/gradle.properties/0
{ "file_path": "bottom_navy_bar/example/android/gradle.properties", "repo_id": "bottom_navy_bar", "token_count": 31 }
30
name: bottom_navy_bar description: A beautiful and animated bottom navigation. The navigation bar uses your current theme, but you are free to customize it. version: 6.0.0 homepage: https://github.com/pedromassango/bottom_navy_bar environment: sdk: ">=2.17.0-0 <3.0.0" dependencies: flutter: sdk: flutter dev_dependencies: flutter_test: sdk: flutter
bottom_navy_bar/pubspec.yaml/0
{ "file_path": "bottom_navy_bar/pubspec.yaml", "repo_id": "bottom_navy_bar", "token_count": 132 }
31
.vscode/* example images
card_settings/.pubignore/0
{ "file_path": "card_settings/.pubignore", "repo_id": "card_settings", "token_count": 9 }
32
org.gradle.jvmargs=-Xmx1536M android.useAndroidX=true android.enableJetifier=true
card_settings/example/android/gradle.properties/0
{ "file_path": "card_settings/example/android/gradle.properties", "repo_id": "card_settings", "token_count": 31 }
33
name: card_settings_example description: A Flutter project that demonstrated the use of the card_settings package. version: 1.0.0 publish_to: none dependencies: flutter: sdk: flutter flutter_localizations: sdk: flutter card_settings: path: ../ font_awesome_flutter: adaptive_theme: ^2.0.0 google_fonts: ^4.0.0 dev_dependencies: flutter_lints: ^1.0.4 flutter_test: sdk: flutter environment: sdk: ">=2.12.0 <4.0.0" flutter: uses-material-design: true assets: - assets/twilight_sparkle.png
card_settings/example/pubspec.yaml/0
{ "file_path": "card_settings/example/pubspec.yaml", "repo_id": "card_settings", "token_count": 222 }
34
import 'dart:math' as math; import 'package:flutter/services.dart'; /// Limits text entry to decimal characters only class DecimalTextInputFormatter extends TextInputFormatter { DecimalTextInputFormatter({this.decimalDigits}) : assert(decimalDigits == null || decimalDigits > 0); final int? decimalDigits; @override TextEditingValue formatEditUpdate( TextEditingValue oldValue, // unused. TextEditingValue newValue, ) { TextSelection newSelection = newValue.selection; String truncated = newValue.text; if (decimalDigits != null) { String value = newValue.text; if (value.contains(".") && value.substring(value.indexOf(".") + 1).length > decimalDigits!) { truncated = oldValue.text; newSelection = oldValue.selection; } else if (value == ".") { truncated = "0."; newSelection = newValue.selection.copyWith( baseOffset: math.min(truncated.length, truncated.length + 1), extentOffset: math.min(truncated.length, truncated.length + 1), ); } return TextEditingValue( text: truncated, selection: newSelection, composing: TextRange.empty, ); } return newValue; } }
card_settings/lib/helpers/decimal_text_input_formatter.dart/0
{ "file_path": "card_settings/lib/helpers/decimal_text_input_formatter.dart", "repo_id": "card_settings", "token_count": 480 }
35
// Copyright (c) 2018, codegrue. All rights reserved. Use of this source code // is governed by the MIT license that can be found in the LICENSE file. import 'package:card_settings/helpers/platform_functions.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_cupertino_settings/flutter_cupertino_settings.dart'; import '../../card_settings.dart'; import '../../interfaces/common_field_properties.dart'; /// This is a field that allows a boolean to be set via a switch widget. class CardSettingsSlider extends FormField<double> implements ICommonFieldProperties { CardSettingsSlider({ Key? key, bool autovalidate = false, AutovalidateMode autovalidateMode = AutovalidateMode.onUserInteraction, FormFieldSetter<double>? onSaved, FormFieldValidator<double>? validator, double initialValue = 0.0, this.enabled = true, this.visible = true, this.label = 'Label', this.requiredIndicator, this.labelAlign, this.labelWidth, this.icon, this.contentAlign, this.onChanged, this.onChangedStart, this.onChangedEnd, this.min, this.max, this.divisions, this.showMaterialonIOS, this.fieldPadding, }) : super( key: key, initialValue: initialValue, onSaved: onSaved, validator: validator, // autovalidate: autovalidate, autovalidateMode: autovalidateMode, builder: (FormFieldState<double> field) => (field as _CardSettingsSliderState)._build(field.context)); /// The text to identify the field to the user @override final String label; /// The alignment of the label paret of the field. Default is left. @override final TextAlign? labelAlign; /// The width of the field label. If provided overrides the global setting. @override final double? labelWidth; /// controls how the widget in the content area of the field is aligned @override final TextAlign? contentAlign; /// The icon to display to the left of the field content @override final Icon? icon; /// If false the field is grayed out and unresponsive @override final bool enabled; /// A widget to show next to the label if the field is required @override final Widget? requiredIndicator; @override final ValueChanged<double>? onChanged; final ValueChanged<double>? onChangedEnd; final ValueChanged<double>? onChangedStart; /// If false hides the widget on the card setting panel @override final bool visible; /// Force the widget to use Material style on an iOS device @override final bool? showMaterialonIOS; /// provides padding to wrap the entire field @override final EdgeInsetsGeometry? fieldPadding; /// how many divisions to have between min and max final int? divisions; /// The value at the minimum position final double? min; /// The value at the maximum position final double? max; @override _CardSettingsSliderState createState() => _CardSettingsSliderState(); } class _CardSettingsSliderState extends FormFieldState<double> { @override CardSettingsSlider get widget => super.widget as CardSettingsSlider; Widget _build(BuildContext context) { if (showCupertino(context, widget.showMaterialonIOS)) return _cupertinoSettingsSlider(); else return _materialSettingsSlider(); } Widget _cupertinoSettingsSlider() { final ls = labelStyle(context, widget.enabled); return Container( child: widget.visible == false ? null : CSControl( nameWidget: Container( width: widget.labelWidth ?? CardSettings.of(context)?.labelWidth ?? 120.0, child: widget.requiredIndicator != null ? Text( (widget.label) + ' *', style: ls, ) : Text( widget.label, style: ls, ), ), contentWidget: CupertinoSlider( value: value!, divisions: widget.divisions, min: widget.min ?? 0, max: widget.max ?? 1, onChangeEnd: widget.onChangedEnd, onChangeStart: widget.onChangedStart, onChanged: (widget.enabled) ? (value) { didChange(value); if (widget.onChanged != null) widget.onChanged!(value); } : null, // to disable, we need to not provide an onChanged function ), style: CSWidgetStyle(icon: widget.icon), ), ); } Widget _materialSettingsSlider() { return CardSettingsField( label: widget.label, labelAlign: widget.labelAlign, labelWidth: widget.labelWidth, visible: widget.visible, enabled: widget.enabled, icon: widget.icon, requiredIndicator: widget.requiredIndicator, errorText: errorText, fieldPadding: widget.fieldPadding, content: Row(children: <Widget>[ Expanded( child: Container( padding: EdgeInsets.all(0.0), child: Container( height: 20.0, child: SliderTheme( data: SliderThemeData( trackShape: _CustomTrackShape(), ), child: Slider( activeColor: Theme.of(context).primaryColor, value: value!, divisions: widget.divisions, min: widget.min ?? 0, max: widget.max ?? 1, onChangeEnd: widget.onChangedEnd, onChangeStart: widget.onChangedStart, onChanged: (widget.enabled) ? (value) { didChange(value); if (widget.onChanged != null) widget.onChanged!(value); } : null, // to disable, we need to not provide an onChanged function ), ), ), ), ), ]), ); } } // https://github.com/flutter/flutter/issues/37057 class _CustomTrackShape extends RoundedRectSliderTrackShape { @override Rect getPreferredRect({ required RenderBox parentBox, Offset offset = Offset.zero, required SliderThemeData sliderTheme, bool isEnabled = false, bool isDiscrete = false, }) { final double trackHeight = sliderTheme.trackHeight ?? 10; final double trackLeft = offset.dx; final double trackTop = offset.dy + (parentBox.size.height - trackHeight) / 2; final double trackWidth = parentBox.size.width; return Rect.fromLTWH(trackLeft, trackTop, trackWidth, trackHeight); } }
card_settings/lib/widgets/numeric_fields/card_settings_slider.dart/0
{ "file_path": "card_settings/lib/widgets/numeric_fields/card_settings_slider.dart", "repo_id": "card_settings", "token_count": 3000 }
36
// Copyright (c) 2018, codegrue. All rights reserved. Use of this source code // is governed by the MIT license that can be found in the LICENSE file. import 'package:card_settings/helpers/platform_functions.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:extended_masked_text/extended_masked_text.dart'; import 'package:flutter_cupertino_settings/flutter_cupertino_settings.dart'; import 'package:flutter/cupertino.dart'; import '../../card_settings.dart'; import '../../interfaces/common_field_properties.dart'; import '../../interfaces/text_field_properties.dart'; /// This is a standard one line text entry It's based on the [TextFormField] widget. class CardSettingsText extends FormField<String> implements ICommonFieldProperties, ITextFieldProperties { CardSettingsText({ Key? key, String? initialValue, bool autovalidate = false, AutovalidateMode autovalidateMode = AutovalidateMode.onUserInteraction, this.enabled = true, this.onSaved, this.validator, this.onChanged, this.controller, this.textCapitalization = TextCapitalization.none, this.keyboardType = TextInputType.text, this.maxLengthEnforcement = MaxLengthEnforcement.enforced, this.inputMask, this.inputFormatters, this.onFieldSubmitted, this.style, this.focusNode, this.inputAction, this.inputActionNode, this.label = 'Label', this.contentOnNewLine = false, this.maxLength = 20, this.numberOfLines = 1, this.showCounter = false, this.visible = true, this.autocorrect = true, this.obscureText = false, this.autofocus = false, this.contentAlign, this.hintText, this.icon, this.labelAlign, this.labelWidth, this.prefixText, this.requiredIndicator, this.unitLabel, this.showMaterialonIOS, this.showClearButtonIOS = OverlayVisibilityMode.never, this.fieldPadding, this.contentPadding = const EdgeInsets.all(0.0), }) : assert(maxLength > 0), assert(controller == null || inputMask == null), super( key: key, initialValue: initialValue, onSaved: onSaved, validator: validator, autovalidateMode: autovalidateMode, builder: (FormFieldState<String> field) => (field as _CardSettingsTextState)._build(field.context), ); @override final ValueChanged<String>? onChanged; final TextEditingController? controller; final String? inputMask; final FocusNode? focusNode; final TextInputAction? inputAction; final FocusNode? inputActionNode; final TextInputType keyboardType; final TextCapitalization textCapitalization; final TextStyle? style; // If false the field is grayed out and unresponsive @override // If false, grays out the field and makes it unresponsive final bool enabled; final MaxLengthEnforcement? maxLengthEnforcement; final ValueChanged<String>? onFieldSubmitted; final List<TextInputFormatter>? inputFormatters; // The text to identify the field to the user @override final String label; // The alignment of the label paret of the field. Default is left. @override final TextAlign? labelAlign; // The width of the field label. If provided overrides the global setting. @override final double? labelWidth; // controls how the widget in the content area of the field is aligned @override final TextAlign? contentAlign; final String? unitLabel; final String? prefixText; @override // text to display to guide the user on what to enter final String? hintText; // The icon to display to the left of the field content @override final Icon? icon; // A widget to show next to the label if the field is required @override final Widget? requiredIndicator; final bool contentOnNewLine; final int maxLength; final int numberOfLines; final bool showCounter; // If false hides the widget on the card setting panel @override final bool visible; final bool autofocus; final bool obscureText; final bool autocorrect; // Force the widget to use Material style on an iOS device @override final bool? showMaterialonIOS; // provides padding to wrap the entire field @override final EdgeInsetsGeometry? fieldPadding; final EdgeInsetsGeometry contentPadding; ///Since the CupertinoTextField does not support onSaved, please use [onChanged] or [onFieldSubmitted] instead @override final FormFieldSetter<String>? onSaved; ///In material mode this shows the validation text under the field ///In cupertino mode, it shows a [red] [Border] around the [CupertinoTextField] @override final FormFieldValidator<String>? validator; final OverlayVisibilityMode showClearButtonIOS; @override _CardSettingsTextState createState() => _CardSettingsTextState(); } class _CardSettingsTextState extends FormFieldState<String> { TextEditingController? _controller; @override CardSettingsText get widget => super.widget as CardSettingsText; @override void initState() { super.initState(); _initController(widget.initialValue); } @override void didUpdateWidget(CardSettingsText oldWidget) { super.didUpdateWidget(oldWidget); if (widget.controller != oldWidget.controller) { oldWidget.controller?.removeListener(_handleControllerChanged); _initController(oldWidget.controller?.value.toString()); } } void _initController(String? initialValue) { if (widget.controller == null) { if (widget.inputMask == null) { _controller = TextEditingController(text: initialValue); } else { _controller = MaskedTextController(mask: widget.inputMask!, text: initialValue); } } else { _controller = widget.controller; } _controller!.addListener(_handleControllerChanged); } @override void dispose() { widget.controller?.removeListener(_handleControllerChanged); super.dispose(); } @override void reset() { super.reset(); setState(() { _controller!.text = widget.initialValue ?? ''; }); } void _handleControllerChanged() { if (_controller!.text != value) { didChange(_controller!.text); } } void _handleOnChanged(String value) { if (widget.onChanged != null) { // `value` doesn't apple any masks when this is called, so the controller has the actual formatted value widget.onChanged!(_controller!.value.text); } } void _onFieldSubmitted(String value) { if (this.widget.focusNode != null) this.widget.focusNode!.unfocus(); if (this.widget.inputActionNode != null) { this.widget.inputActionNode!.requestFocus(); return; } if (this.widget.onFieldSubmitted != null) this.widget.onFieldSubmitted!(value); } Widget _build(BuildContext context) { if (showCupertino(context, widget.showMaterialonIOS)) return _buildCupertinoTextbox(context); else return _buildMaterialTextbox(context); } Container _buildCupertinoTextbox(BuildContext context) { bool hasError = false; if (widget.validator != null) { String? errorMessage = widget.validator!(value); hasError = (errorMessage != null); } final ls = labelStyle(context, widget.enabled); final _child = Container( child: CupertinoTextField( prefix: widget.prefixText == null ? null : Text( widget.prefixText ?? '', style: ls, ), suffix: widget.unitLabel == null ? null : Text( widget.unitLabel ?? '', style: ls, ), controller: _controller, focusNode: widget.focusNode, textInputAction: widget.inputAction, keyboardType: widget.keyboardType, textCapitalization: widget.textCapitalization, style: contentStyle(context, value, widget.enabled), decoration: hasError ? BoxDecoration( border: Border.all(color: Colors.red), borderRadius: BorderRadius.all( Radius.circular(4.0), ), ) : BoxDecoration( border: Border( top: BorderSide( color: CupertinoColors.lightBackgroundGray, style: BorderStyle.solid, width: 0.0, ), bottom: BorderSide( color: CupertinoColors.lightBackgroundGray, style: BorderStyle.solid, width: 0.0, ), left: BorderSide( color: CupertinoColors.lightBackgroundGray, style: BorderStyle.solid, width: 0.0, ), right: BorderSide( color: CupertinoColors.lightBackgroundGray, style: BorderStyle.solid, width: 0.0, ), ), borderRadius: BorderRadius.all( Radius.circular(4.0), ), ), clearButtonMode: widget.showClearButtonIOS, placeholder: widget.hintText, textAlign: widget.contentAlign ?? TextAlign.end, autofocus: widget.autofocus, obscureText: widget.obscureText, autocorrect: widget.autocorrect, maxLengthEnforcement: widget.maxLengthEnforcement, maxLines: widget.numberOfLines, maxLength: (widget.showCounter) ? widget.maxLength : null, // if we want counter use default behavior onChanged: _handleOnChanged, onSubmitted: _onFieldSubmitted, inputFormatters: widget.inputFormatters ?? [ // if we don't want the counter, use this maxLength instead LengthLimitingTextInputFormatter(widget.maxLength) ], enabled: widget.enabled, ), ); return Container( child: widget.visible == false ? null : widget.contentOnNewLine == true ? Column( mainAxisSize: MainAxisSize.min, children: <Widget>[ CSControl( nameWidget: widget.requiredIndicator != null ? Text( (widget.label) + ' *', style: ls, ) : Text(widget.label, style: ls), contentWidget: Container(), style: CSWidgetStyle(icon: widget.icon), ), Container( padding: EdgeInsets.all(5.0), child: _child, color: Theme.of(context).brightness == Brightness.dark ? null : CupertinoColors.white, ), Container( padding: widget.showCounter ? EdgeInsets.all(5.0) : null, color: Theme.of(context).brightness == Brightness.dark ? null : CupertinoColors.white, child: widget.showCounter ? Row( mainAxisAlignment: MainAxisAlignment.end, children: <Widget>[ Text( "${_controller?.text.length ?? 0}/${widget.maxLength}", style: TextStyle( color: CupertinoColors.inactiveGray, ), ), ], ) : null, ), ], ) : Column( mainAxisSize: MainAxisSize.min, children: <Widget>[ CSControl( nameWidget: Container( width: widget.labelWidth ?? CardSettings.of(context)?.labelWidth ?? 120.0, child: widget.requiredIndicator != null ? Text((widget.label) + ' *', style: ls) : Text(widget.label, style: ls), ), contentWidget: Expanded( child: Container( padding: EdgeInsets.only(left: 10.0), child: _child, ), ), style: CSWidgetStyle(icon: widget.icon), ), Container( padding: widget.showCounter ? EdgeInsets.all(5.0) : null, color: Theme.of(context).brightness == Brightness.dark ? null : CupertinoColors.white, child: widget.showCounter ? Row( mainAxisAlignment: MainAxisAlignment.end, children: <Widget>[ Text( "${_controller?.text.length ?? 0}/${widget.maxLength}", style: TextStyle( color: CupertinoColors.inactiveGray, ), ), ], ) : null, ), ], ), ); } CardSettingsField _buildMaterialTextbox(BuildContext context) { return CardSettingsField( label: widget.label, labelAlign: widget.labelAlign, labelWidth: widget.labelWidth, visible: widget.visible, unitLabel: widget.unitLabel, icon: widget.icon, requiredIndicator: widget.requiredIndicator, contentOnNewLine: widget.contentOnNewLine, enabled: widget.enabled, fieldPadding: widget.fieldPadding, content: TextField( controller: _controller, focusNode: widget.focusNode, keyboardType: widget.keyboardType, textInputAction: widget.inputAction, textCapitalization: widget.textCapitalization, enabled: widget.enabled, readOnly: !widget.enabled, style: contentStyle(context, value, widget.enabled), decoration: InputDecoration( contentPadding: widget.contentPadding, border: InputBorder.none, errorText: errorText, prefixText: widget.prefixText, hintText: widget.hintText, isDense: true, ), textAlign: widget.contentAlign ?? CardSettings.of(context)!.contentAlign, autofocus: widget.autofocus, obscureText: widget.obscureText, autocorrect: widget.autocorrect, maxLengthEnforcement: widget.maxLengthEnforcement, maxLines: widget.numberOfLines, maxLength: (widget.showCounter) ? widget.maxLength : null, // if we want counter use default behavior onChanged: _handleOnChanged, onSubmitted: _onFieldSubmitted, inputFormatters: widget.inputFormatters ?? [ // if we don't want the counter, use this maxLength instead LengthLimitingTextInputFormatter(widget.maxLength) ], ), ); } }
card_settings/lib/widgets/text_fields/card_settings_text.dart/0
{ "file_path": "card_settings/lib/widgets/text_fields/card_settings_text.dart", "repo_id": "card_settings", "token_count": 7317 }
37
export './constants.dart'; export './theme/clay_text_theme.dart'; export './theme/clay_theme.dart'; export './theme/clay_theme_data.dart'; export './widgets/clay_animated_container.dart'; export './widgets/clay_container.dart'; export './widgets/clay_text.dart';
clay_containers/lib/clay_containers.dart/0
{ "file_path": "clay_containers/lib/clay_containers.dart", "repo_id": "clay_containers", "token_count": 104 }
38
#include "Generated.xcconfig"
direct-select-flutter/example/ios/Flutter/Debug.xcconfig/0
{ "file_path": "direct-select-flutter/example/ios/Flutter/Debug.xcconfig", "repo_id": "direct-select-flutter", "token_count": 12 }
39
org.gradle.jvmargs=-Xmx1536M android.enableR8=true android.enableJetifier=true android.useAndroidX=true #systemProp.http.nonProxyHosts=*.vclound.com #systemProp.http.proxyHost=127.0.0.1 #systemProp.http.proxyPort=8888 #systemProp.https.nonProxyHosts=*.vclound.com #systemProp.https.proxyHost=127.0.0.1 #systemProp.https.proxyPort=8888
dynamic_widget/example/android/gradle.properties/0
{ "file_path": "dynamic_widget/example/android/gradle.properties", "repo_id": "dynamic_widget", "token_count": 135 }
40
import 'package:dynamic_widget/dynamic_widget.dart'; import 'package:flutter/widgets.dart'; class ExpandedWidgetParser extends WidgetParser { @override Widget parse(Map<String, dynamic> map, BuildContext buildContext, ClickListener? listener) { return Expanded( child: DynamicWidgetBuilder.buildFromMap( map["child"], buildContext, listener)!, flex: map.containsKey("flex") ? map["flex"] : 1, ); } @override String get widgetName => "Expanded"; @override Map<String, dynamic> export(Widget? widget, BuildContext? buildContext) { var realWidget = widget as Expanded; return <String, dynamic>{ "type": widgetName, "flex": realWidget.flex, "child": DynamicWidgetBuilder.export(realWidget.child, buildContext) }; } @override Type get widgetType => Expanded; }
dynamic_widget/lib/dynamic_widget/basic/expanded_widget_parser.dart/0
{ "file_path": "dynamic_widget/lib/dynamic_widget/basic/expanded_widget_parser.dart", "repo_id": "dynamic_widget", "token_count": 296 }
41
import 'package:dynamic_widget/dynamic_widget.dart'; import 'package:dynamic_widget/dynamic_widget/utils.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; class SelectableTextWidgetParser implements WidgetParser { @override Widget parse(Map<String, dynamic> map, BuildContext buildContext, ClickListener? listener) { String? data = map['data']; String? textAlignString = map['textAlign']; int? maxLines = map['maxLines']; String? textDirectionString = map['textDirection']; // double textScaleFactor = map['textScaleFactor']; var textSpan; var textSpanParser = SelectableTextSpanParser(); if (map.containsKey("textSpan")) { textSpan = textSpanParser.parse(map['textSpan'], listener); } if (textSpan == null) { return SelectableText( data!, textAlign: parseTextAlign(textAlignString), maxLines: maxLines, textDirection: parseTextDirection(textDirectionString), style: map.containsKey('style') ? parseTextStyle(map['style']) : null, // textScaleFactor: textScaleFactor, ); } else { return SelectableText.rich( textSpan, textAlign: parseTextAlign(textAlignString), maxLines: maxLines, textDirection: parseTextDirection(textDirectionString), style: map.containsKey('style') ? parseTextStyle(map['style']) : null, // textScaleFactor: textScaleFactor, ); } } @override String get widgetName => "SelectableText"; @override Map<String, dynamic> export(Widget? widget, BuildContext? buildContext) { var realWidget = widget as SelectableText; if (realWidget.textSpan == null) { return <String, dynamic>{ "type": "SelectableText", "data": realWidget.data, "textAlign": realWidget.textAlign != null ? exportTextAlign(realWidget.textAlign) : "start", "maxLines": realWidget.maxLines, "textDirection": exportTextDirection(realWidget.textDirection), "style": exportTextStyle(realWidget.style), }; } else { var parser = SelectableTextSpanParser(); return <String, dynamic>{ "type": "SelectableText", "textSpan": parser.export(realWidget.textSpan!), "textAlign": realWidget.textAlign != null ? exportTextAlign(realWidget.textAlign) : "start", "maxLines": realWidget.maxLines, "textDirection": exportTextDirection(realWidget.textDirection), "style": exportTextStyle(realWidget.style), }; } } @override bool matchWidgetForExport(Widget? widget) => widget is SelectableText; @override Type get widgetType => SelectableText; } class SelectableTextSpanParser { TextSpan parse(Map<String, dynamic> map, ClickListener? listener) { String? clickEvent = map.containsKey("recognizer") ? map['recognizer'] : ""; var textSpan = TextSpan( text: map['text'], style: parseTextStyle(map['style']), recognizer: TapGestureRecognizer() ..onTap = () { listener!.onClicked(clickEvent); }, children: []); if (map.containsKey('children')) { parseChildren(textSpan, map['children'], listener); } return textSpan; } void parseChildren( TextSpan textSpan, List<dynamic> childrenSpan, ClickListener? listener) { for (var childmap in childrenSpan) { textSpan.children!.add(parse(childmap, listener)); } } Map<String, dynamic> export(TextSpan textSpan) { return <String, dynamic>{ "text": textSpan.text, "style": exportTextStyle(textSpan.style), "children": exportChildren(textSpan) }; } List<Map<String, dynamic>> exportChildren(TextSpan textSpan) { List<Map<String, dynamic>> rt = []; if (textSpan.children != null && textSpan.children!.isNotEmpty) { for (var span in textSpan.children!) { rt.add(export(span as TextSpan)); } } return rt; } }
dynamic_widget/lib/dynamic_widget/basic/selectabletext_widget_parser.dart/0
{ "file_path": "dynamic_widget/lib/dynamic_widget/basic/selectabletext_widget_parser.dart", "repo_id": "dynamic_widget", "token_count": 1615 }
42
<?xml version="1.0" encoding="UTF-8"?> <project version="4"> <component name="VcsDirectoryMappings"> <mapping directory="$PROJECT_DIR$" vcs="Git" /> </component> </project>
fancy_bottom_navigation/.idea/vcs.xml/0
{ "file_path": "fancy_bottom_navigation/.idea/vcs.xml", "repo_id": "fancy_bottom_navigation", "token_count": 66 }
43
import 'package:flutter/material.dart'; const double ICON_OFF = -3; const double ICON_ON = 0; const double TEXT_OFF = 3; const double TEXT_ON = 1; const double ALPHA_OFF = 0; const double ALPHA_ON = 1; const int ANIM_DURATION = 300; class TabItem extends StatelessWidget { TabItem( {required this.uniqueKey, required this.selected, required this.iconData, required this.title, required this.callbackFunction, required this.textColor, required this.iconColor}); final UniqueKey uniqueKey; final String title; final IconData iconData; final bool selected; final Function(UniqueKey uniqueKey) callbackFunction; final Color textColor; final Color iconColor; final double iconYAlign = ICON_ON; final double textYAlign = TEXT_OFF; final double iconAlpha = ALPHA_ON; @override Widget build(BuildContext context) { return Expanded( child: Stack( fit: StackFit.expand, children: [ Container( height: double.infinity, width: double.infinity, child: AnimatedAlign( duration: Duration(milliseconds: ANIM_DURATION), alignment: Alignment(0, (selected) ? TEXT_ON : TEXT_OFF), child: Padding( padding: const EdgeInsets.all(8.0), child: Text( title, overflow: TextOverflow.ellipsis, maxLines: 1, style: TextStyle( fontWeight: FontWeight.w600, color: textColor), ), )), ), Container( height: double.infinity, width: double.infinity, child: AnimatedAlign( duration: Duration(milliseconds: ANIM_DURATION), curve: Curves.easeIn, alignment: Alignment(0, (selected) ? ICON_OFF : ICON_ON), child: AnimatedOpacity( duration: Duration(milliseconds: ANIM_DURATION), opacity: (selected) ? ALPHA_OFF : ALPHA_ON, child: IconButton( highlightColor: Colors.transparent, splashColor: Colors.transparent, padding: EdgeInsets.all(0), alignment: Alignment(0, 0), icon: Icon( iconData, color: iconColor, ), onPressed: () { callbackFunction(uniqueKey); }, ), ), ), ) ], ), ); } }
fancy_bottom_navigation/lib/internal/tab_item.dart/0
{ "file_path": "fancy_bottom_navigation/lib/internal/tab_item.dart", "repo_id": "fancy_bottom_navigation", "token_count": 1341 }
44
analyze: flutter analyze checkFormat: dart format -o none --set-exit-if-changed . checkstyle: make analyze && make checkFormat format: dart format . runTests: flutter test checkoutToPR: git fetch origin pull/$(id)/head:pr-$(id) --force; \ git checkout pr-$(id) # Tells you in which version this commit has landed findVersion: git describe --contains $(commit) | sed 's/~.*//' # Runs both `make runTests` and `make checkstyle`. Use this before pushing your code. sure: make runTests && make checkstyle # To create generated files (for example mock files in unit_tests) codeGen: flutter pub run build_runner build --delete-conflicting-outputs showTestCoverage: flutter test --coverage genhtml coverage/lcov.info -o coverage/html source ./scripts/makefile_scripts.sh && open_link "coverage/html/index.html" buildRunner: flutter packages pub run build_runner build --delete-conflicting-outputs
fl_chart/Makefile/0
{ "file_path": "fl_chart/Makefile", "repo_id": "fl_chart", "token_count": 296 }
45
import 'dart:async'; import 'dart:math'; import 'package:fl_chart_app/presentation/resources/app_resources.dart'; import 'package:fl_chart_app/util/extensions/color_extensions.dart'; import 'package:fl_chart/fl_chart.dart'; import 'package:flutter/material.dart'; class BarChartSample1 extends StatefulWidget { BarChartSample1({super.key}); List<Color> get availableColors => const <Color>[ AppColors.contentColorPurple, AppColors.contentColorYellow, AppColors.contentColorBlue, AppColors.contentColorOrange, AppColors.contentColorPink, AppColors.contentColorRed, ]; final Color barBackgroundColor = AppColors.contentColorWhite.darken().withOpacity(0.3); final Color barColor = AppColors.contentColorWhite; final Color touchedBarColor = AppColors.contentColorGreen; @override State<StatefulWidget> createState() => BarChartSample1State(); } class BarChartSample1State extends State<BarChartSample1> { final Duration animDuration = const Duration(milliseconds: 250); int touchedIndex = -1; bool isPlaying = false; @override Widget build(BuildContext context) { return AspectRatio( aspectRatio: 1, child: Stack( children: <Widget>[ Padding( padding: const EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: <Widget>[ const Text( 'Mingguan', style: TextStyle( color: AppColors.contentColorGreen, fontSize: 24, fontWeight: FontWeight.bold, ), ), const SizedBox( height: 4, ), Text( 'Grafik konsumsi kalori', style: TextStyle( color: AppColors.contentColorGreen.darken(), fontSize: 18, fontWeight: FontWeight.bold, ), ), const SizedBox( height: 38, ), Expanded( child: Padding( padding: const EdgeInsets.symmetric(horizontal: 8), child: BarChart( isPlaying ? randomData() : mainBarData(), swapAnimationDuration: animDuration, ), ), ), const SizedBox( height: 12, ), ], ), ), Padding( padding: const EdgeInsets.all(8), child: Align( alignment: Alignment.topRight, child: IconButton( icon: Icon( isPlaying ? Icons.pause : Icons.play_arrow, color: AppColors.contentColorGreen, ), onPressed: () { setState(() { isPlaying = !isPlaying; if (isPlaying) { refreshState(); } }); }, ), ), ) ], ), ); } BarChartGroupData makeGroupData( int x, double y, { bool isTouched = false, Color? barColor, double width = 22, List<int> showTooltips = const [], }) { barColor ??= widget.barColor; return BarChartGroupData( x: x, barRods: [ BarChartRodData( toY: isTouched ? y + 1 : y, color: isTouched ? widget.touchedBarColor : barColor, width: width, borderSide: isTouched ? BorderSide(color: widget.touchedBarColor.darken(80)) : const BorderSide(color: Colors.white, width: 0), backDrawRodData: BackgroundBarChartRodData( show: true, toY: 20, color: widget.barBackgroundColor, ), ), ], showingTooltipIndicators: showTooltips, ); } List<BarChartGroupData> showingGroups() => List.generate(7, (i) { switch (i) { case 0: return makeGroupData(0, 5, isTouched: i == touchedIndex); case 1: return makeGroupData(1, 6.5, isTouched: i == touchedIndex); case 2: return makeGroupData(2, 5, isTouched: i == touchedIndex); case 3: return makeGroupData(3, 7.5, isTouched: i == touchedIndex); case 4: return makeGroupData(4, 9, isTouched: i == touchedIndex); case 5: return makeGroupData(5, 11.5, isTouched: i == touchedIndex); case 6: return makeGroupData(6, 6.5, isTouched: i == touchedIndex); default: return throw Error(); } }); BarChartData mainBarData() { return BarChartData( barTouchData: BarTouchData( touchTooltipData: BarTouchTooltipData( getTooltipColor: (_) => Colors.blueGrey, tooltipHorizontalAlignment: FLHorizontalAlignment.right, tooltipMargin: -10, getTooltipItem: (group, groupIndex, rod, rodIndex) { String weekDay; switch (group.x) { case 0: weekDay = 'Monday'; break; case 1: weekDay = 'Tuesday'; break; case 2: weekDay = 'Wednesday'; break; case 3: weekDay = 'Thursday'; break; case 4: weekDay = 'Friday'; break; case 5: weekDay = 'Saturday'; break; case 6: weekDay = 'Sunday'; break; default: throw Error(); } return BarTooltipItem( '$weekDay\n', const TextStyle( color: Colors.white, fontWeight: FontWeight.bold, fontSize: 18, ), children: <TextSpan>[ TextSpan( text: (rod.toY - 1).toString(), style: const TextStyle( color: Colors.white, //widget.touchedBarColor, fontSize: 16, fontWeight: FontWeight.w500, ), ), ], ); }, ), touchCallback: (FlTouchEvent event, barTouchResponse) { setState(() { if (!event.isInterestedForInteractions || barTouchResponse == null || barTouchResponse.spot == null) { touchedIndex = -1; return; } touchedIndex = barTouchResponse.spot!.touchedBarGroupIndex; }); }, ), titlesData: FlTitlesData( show: true, rightTitles: const AxisTitles( sideTitles: SideTitles(showTitles: false), ), topTitles: const AxisTitles( sideTitles: SideTitles(showTitles: false), ), bottomTitles: AxisTitles( sideTitles: SideTitles( showTitles: true, getTitlesWidget: getTitles, reservedSize: 38, ), ), leftTitles: const AxisTitles( sideTitles: SideTitles( showTitles: false, ), ), ), borderData: FlBorderData( show: false, ), barGroups: showingGroups(), gridData: const FlGridData(show: false), ); } Widget getTitles(double value, TitleMeta meta) { const style = TextStyle( color: Colors.white, fontWeight: FontWeight.bold, fontSize: 14, ); Widget text; switch (value.toInt()) { case 0: text = const Text('M', style: style); break; case 1: text = const Text('T', style: style); break; case 2: text = const Text('W', style: style); break; case 3: text = const Text('T', style: style); break; case 4: text = const Text('F', style: style); break; case 5: text = const Text('S', style: style); break; case 6: text = const Text('S', style: style); break; default: text = const Text('', style: style); break; } return SideTitleWidget( axisSide: meta.axisSide, space: 16, child: text, ); } BarChartData randomData() { return BarChartData( barTouchData: BarTouchData( enabled: false, ), titlesData: FlTitlesData( show: true, bottomTitles: AxisTitles( sideTitles: SideTitles( showTitles: true, getTitlesWidget: getTitles, reservedSize: 38, ), ), leftTitles: const AxisTitles( sideTitles: SideTitles( showTitles: false, ), ), topTitles: const AxisTitles( sideTitles: SideTitles( showTitles: false, ), ), rightTitles: const AxisTitles( sideTitles: SideTitles( showTitles: false, ), ), ), borderData: FlBorderData( show: false, ), barGroups: List.generate(7, (i) { switch (i) { case 0: return makeGroupData( 0, Random().nextInt(15).toDouble() + 6, barColor: widget.availableColors[ Random().nextInt(widget.availableColors.length)], ); case 1: return makeGroupData( 1, Random().nextInt(15).toDouble() + 6, barColor: widget.availableColors[ Random().nextInt(widget.availableColors.length)], ); case 2: return makeGroupData( 2, Random().nextInt(15).toDouble() + 6, barColor: widget.availableColors[ Random().nextInt(widget.availableColors.length)], ); case 3: return makeGroupData( 3, Random().nextInt(15).toDouble() + 6, barColor: widget.availableColors[ Random().nextInt(widget.availableColors.length)], ); case 4: return makeGroupData( 4, Random().nextInt(15).toDouble() + 6, barColor: widget.availableColors[ Random().nextInt(widget.availableColors.length)], ); case 5: return makeGroupData( 5, Random().nextInt(15).toDouble() + 6, barColor: widget.availableColors[ Random().nextInt(widget.availableColors.length)], ); case 6: return makeGroupData( 6, Random().nextInt(15).toDouble() + 6, barColor: widget.availableColors[ Random().nextInt(widget.availableColors.length)], ); default: return throw Error(); } }), gridData: const FlGridData(show: false), ); } Future<dynamic> refreshState() async { setState(() {}); await Future<dynamic>.delayed( animDuration + const Duration(milliseconds: 50), ); if (isPlaying) { await refreshState(); } } }
fl_chart/example/lib/presentation/samples/bar/bar_chart_sample1.dart/0
{ "file_path": "fl_chart/example/lib/presentation/samples/bar/bar_chart_sample1.dart", "repo_id": "fl_chart", "token_count": 6276 }
46
import 'package:fl_chart_app/presentation/resources/app_resources.dart'; import 'package:fl_chart/fl_chart.dart'; import 'package:flutter/material.dart'; class LineChartSample5 extends StatefulWidget { const LineChartSample5({ super.key, Color? gradientColor1, Color? gradientColor2, Color? gradientColor3, Color? indicatorStrokeColor, }) : gradientColor1 = gradientColor1 ?? AppColors.contentColorBlue, gradientColor2 = gradientColor2 ?? AppColors.contentColorPink, gradientColor3 = gradientColor3 ?? AppColors.contentColorRed, indicatorStrokeColor = indicatorStrokeColor ?? AppColors.mainTextColor1; final Color gradientColor1; final Color gradientColor2; final Color gradientColor3; final Color indicatorStrokeColor; @override State<LineChartSample5> createState() => _LineChartSample5State(); } class _LineChartSample5State extends State<LineChartSample5> { List<int> showingTooltipOnSpots = [1, 3, 5]; List<FlSpot> get allSpots => const [ FlSpot(0, 1), FlSpot(1, 2), FlSpot(2, 1.5), FlSpot(3, 3), FlSpot(4, 3.5), FlSpot(5, 5), FlSpot(6, 8), ]; Widget bottomTitleWidgets(double value, TitleMeta meta, double chartWidth) { final style = TextStyle( fontWeight: FontWeight.bold, color: AppColors.contentColorPink, fontFamily: 'Digital', fontSize: 18 * chartWidth / 500, ); String text; switch (value.toInt()) { case 0: text = '00:00'; break; case 1: text = '04:00'; break; case 2: text = '08:00'; break; case 3: text = '12:00'; break; case 4: text = '16:00'; break; case 5: text = '20:00'; break; case 6: text = '23:59'; break; default: return Container(); } return SideTitleWidget( axisSide: meta.axisSide, child: Text(text, style: style), ); } @override Widget build(BuildContext context) { final lineBarsData = [ LineChartBarData( showingIndicators: showingTooltipOnSpots, spots: allSpots, isCurved: true, barWidth: 4, shadow: const Shadow( blurRadius: 8, ), belowBarData: BarAreaData( show: true, gradient: LinearGradient( colors: [ widget.gradientColor1.withOpacity(0.4), widget.gradientColor2.withOpacity(0.4), widget.gradientColor3.withOpacity(0.4), ], ), ), dotData: const FlDotData(show: false), gradient: LinearGradient( colors: [ widget.gradientColor1, widget.gradientColor2, widget.gradientColor3, ], stops: const [0.1, 0.4, 0.9], ), ), ]; final tooltipsOnBar = lineBarsData[0]; return AspectRatio( aspectRatio: 2.5, child: Padding( padding: const EdgeInsets.symmetric( horizontal: 24.0, vertical: 10, ), child: LayoutBuilder(builder: (context, constraints) { return LineChart( LineChartData( showingTooltipIndicators: showingTooltipOnSpots.map((index) { return ShowingTooltipIndicators([ LineBarSpot( tooltipsOnBar, lineBarsData.indexOf(tooltipsOnBar), tooltipsOnBar.spots[index], ), ]); }).toList(), lineTouchData: LineTouchData( enabled: true, handleBuiltInTouches: false, touchCallback: (FlTouchEvent event, LineTouchResponse? response) { if (response == null || response.lineBarSpots == null) { return; } if (event is FlTapUpEvent) { final spotIndex = response.lineBarSpots!.first.spotIndex; setState(() { if (showingTooltipOnSpots.contains(spotIndex)) { showingTooltipOnSpots.remove(spotIndex); } else { showingTooltipOnSpots.add(spotIndex); } }); } }, mouseCursorResolver: (FlTouchEvent event, LineTouchResponse? response) { if (response == null || response.lineBarSpots == null) { return SystemMouseCursors.basic; } return SystemMouseCursors.click; }, getTouchedSpotIndicator: (LineChartBarData barData, List<int> spotIndexes) { return spotIndexes.map((index) { return TouchedSpotIndicatorData( const FlLine( color: Colors.pink, ), FlDotData( show: true, getDotPainter: (spot, percent, barData, index) => FlDotCirclePainter( radius: 8, color: lerpGradient( barData.gradient!.colors, barData.gradient!.stops!, percent / 100, ), strokeWidth: 2, strokeColor: widget.indicatorStrokeColor, ), ), ); }).toList(); }, touchTooltipData: LineTouchTooltipData( getTooltipColor: (touchedSpot) => Colors.pink, tooltipRoundedRadius: 8, getTooltipItems: (List<LineBarSpot> lineBarsSpot) { return lineBarsSpot.map((lineBarSpot) { return LineTooltipItem( lineBarSpot.y.toString(), const TextStyle( color: Colors.white, fontWeight: FontWeight.bold, ), ); }).toList(); }, ), ), lineBarsData: lineBarsData, minY: 0, titlesData: FlTitlesData( leftTitles: const AxisTitles( axisNameWidget: Text('count'), axisNameSize: 24, sideTitles: SideTitles( showTitles: false, reservedSize: 0, ), ), bottomTitles: AxisTitles( sideTitles: SideTitles( showTitles: true, interval: 1, getTitlesWidget: (value, meta) { return bottomTitleWidgets( value, meta, constraints.maxWidth, ); }, reservedSize: 30, ), ), rightTitles: const AxisTitles( axisNameWidget: Text('count'), sideTitles: SideTitles( showTitles: false, reservedSize: 0, ), ), topTitles: const AxisTitles( axisNameWidget: Text( 'Wall clock', textAlign: TextAlign.left, ), axisNameSize: 24, sideTitles: SideTitles( showTitles: true, reservedSize: 0, ), ), ), gridData: const FlGridData(show: false), borderData: FlBorderData( show: true, border: Border.all( color: AppColors.borderColor, ), ), ), ); }), ), ); } } /// Lerps between a [LinearGradient] colors, based on [t] Color lerpGradient(List<Color> colors, List<double> stops, double t) { if (colors.isEmpty) { throw ArgumentError('"colors" is empty.'); } else if (colors.length == 1) { return colors[0]; } if (stops.length != colors.length) { stops = []; /// provided gradientColorStops is invalid and we calculate it here colors.asMap().forEach((index, color) { final percent = 1.0 / (colors.length - 1); stops.add(percent * index); }); } for (var s = 0; s < stops.length - 1; s++) { final leftStop = stops[s]; final rightStop = stops[s + 1]; final leftColor = colors[s]; final rightColor = colors[s + 1]; if (t <= leftStop) { return leftColor; } else if (t < rightStop) { final sectionT = (t - leftStop) / (rightStop - leftStop); return Color.lerp(leftColor, rightColor, sectionT)!; } } return colors.last; }
fl_chart/example/lib/presentation/samples/line/line_chart_sample5.dart/0
{ "file_path": "fl_chart/example/lib/presentation/samples/line/line_chart_sample5.dart", "repo_id": "fl_chart", "token_count": 5146 }
47
import 'dart:math' as math; import 'package:url_launcher/url_launcher.dart'; class AppUtils { factory AppUtils() { return _singleton; } AppUtils._internal(); static final AppUtils _singleton = AppUtils._internal(); double degreeToRadian(double degree) { return degree * math.pi / 180; } double radianToDegree(double radian) { return radian * 180 / math.pi; } Future<bool> tryToLaunchUrl(String url) async { final uri = Uri.parse(url); if (await canLaunchUrl(uri)) { return await launchUrl(uri); } return false; } }
fl_chart/example/lib/util/app_utils.dart/0
{ "file_path": "fl_chart/example/lib/util/app_utils.dart", "repo_id": "fl_chart", "token_count": 217 }
48
<!DOCTYPE html> <html> <head> <!-- If you are serving your web app in a path other than the root, change the href value below to reflect the base path you are serving from. The path provided below has to start and end with a slash "/" in order for it to work correctly. For more details: * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base This is a placeholder for base href that will be replaced by the value of the `--base-href` argument provided to `flutter build`. --> <base href="$FLUTTER_BASE_HREF"> <meta charset="UTF-8"> <meta content="IE=Edge" http-equiv="X-UA-Compatible"> <meta name="description" content="FL Chart App is an application to demonstrate samples of the fl_chart (A Flutter package to draw charts)."> <!-- iOS meta tags & icons --> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-status-bar-style" content="black"> <meta name="apple-mobile-web-app-title" content="FL Chart App"> <link rel="apple-touch-icon" href="icons/Icon-192.png"> <!-- Favicon --> <link rel="icon" type="image/png" href="favicon.png"/> <title>FL Chart App</title> <link rel="manifest" href="manifest.json"> <script> // The value below is injected by flutter build, do not touch. var serviceWorkerVersion = null; </script> <!-- This script adds the flutter initialization JS code --> <script src="flutter.js" defer></script> </head> <style> .loading { display: flex; justify-content: center; align-items: center; margin: 0; position: absolute; top: 50%; left: 50%; -ms-transform: translate(-50%, -50%); transform: translate(-50%, -50%); } .loader { border-radius: 50%; border: 6px solid ; border-top: 6px solid transparent; border-right: 6px solid #50E4FF; border-bottom: 6px solid transparent; border-left: 6px solid #50E4FF; width: 52px; height: 52px; -webkit-animation: spin 2s linear infinite; animation: spin 2s linear infinite; } @-webkit-keyframes spin { 0% { -webkit-transform: rotate(0deg); } 100% { -webkit-transform: rotate(360deg); } } @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } body { background: #282E45; } </style> <body> <div class="loading"> <div class="loader"></div> </div> <script> window.addEventListener('load', function(ev) { // Download main.dart.js _flutter.loader.loadEntrypoint({ serviceWorker: { serviceWorkerVersion: serviceWorkerVersion, } }).then(function(engineInitializer) { return engineInitializer.initializeEngine(); }).then(function(appRunner) { return appRunner.runApp(); }); }); </script> </body> </html>
fl_chart/example/web/index.html/0
{ "file_path": "fl_chart/example/web/index.html", "repo_id": "fl_chart", "token_count": 1160 }
49
import 'package:fl_chart/fl_chart.dart'; import 'package:fl_chart/src/chart/base/axis_chart/axis_chart_helper.dart'; import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; /// Wraps a [child] widget and applies some default behaviours /// /// Recommended to be used in [SideTitles.getTitlesWidget] /// You need to pass [axisSide] value that provided by [TitleMeta] /// It forces the widget to be close to the chart. /// It also applies a [space] to the chart. /// You can also fill [angle] in radians if you need to rotate your widget. /// To force widget to be positioned within its axis bounding box, /// define [fitInside] by passing [SideTitleFitInsideData] class SideTitleWidget extends StatefulWidget { const SideTitleWidget({ super.key, required this.child, required this.axisSide, this.space = 8.0, this.angle = 0.0, this.fitInside = const SideTitleFitInsideData( enabled: false, distanceFromEdge: 0, parentAxisSize: 0, axisPosition: 0, ), }); final AxisSide axisSide; final double space; final Widget child; final double angle; /// Define fitInside options with [SideTitleFitInsideData] /// /// To makes things simpler, it's recommended to use /// [SideTitleFitInsideData.fromTitleMeta] and pass the /// TitleMeta provided from [SideTitles.getTitlesWidget] /// /// If [fitInside.enabled] is true, the widget will be placed /// inside the parent axis bounding box. /// /// Some translations will be applied to force /// children to be positioned inside the parent axis bounding box. /// /// Will override the [SideTitleWidget.space] and caused /// spacing between [SideTitles] children might be not equal. final SideTitleFitInsideData fitInside; @override State<SideTitleWidget> createState() => _SideTitleWidgetState(); } class _SideTitleWidgetState extends State<SideTitleWidget> { Alignment _getAlignment() { switch (widget.axisSide) { case AxisSide.left: return Alignment.centerRight; case AxisSide.top: return Alignment.bottomCenter; case AxisSide.right: return Alignment.centerLeft; case AxisSide.bottom: return Alignment.topCenter; } } EdgeInsets _getMargin() { switch (widget.axisSide) { case AxisSide.left: return EdgeInsets.only(right: widget.space); case AxisSide.top: return EdgeInsets.only(bottom: widget.space); case AxisSide.right: return EdgeInsets.only(left: widget.space); case AxisSide.bottom: return EdgeInsets.only(top: widget.space); } } /// Calculate child width/height final GlobalKey widgetKey = GlobalKey(); double? _childSize; void _getChildSize(_) { // If fitInside is false, no need to find child size if (!widget.fitInside.enabled) return; // If childSize is not null, no need to find the size anymore if (_childSize != null) return; final context = widgetKey.currentContext; if (context == null) return; // Set size based on its axis side final size = switch (widget.axisSide) { AxisSide.left || AxisSide.right => context.size?.height ?? 0, AxisSide.top || AxisSide.bottom => context.size?.width ?? 0, }; // If childSize is the same, no need to set new value if (_childSize == size) return; setState(() => _childSize = size); } @override void initState() { super.initState(); SchedulerBinding.instance.addPostFrameCallback(_getChildSize); } @override void didUpdateWidget(covariant SideTitleWidget oldWidget) { super.didUpdateWidget(oldWidget); SchedulerBinding.instance.addPostFrameCallback(_getChildSize); } @override Widget build(BuildContext context) { return Transform.translate( offset: !widget.fitInside.enabled ? Offset.zero : AxisChartHelper().calcFitInsideOffset( axisSide: widget.axisSide, childSize: _childSize, parentAxisSize: widget.fitInside.parentAxisSize, axisPosition: widget.fitInside.axisPosition, distanceFromEdge: widget.fitInside.distanceFromEdge, ), child: Transform.rotate( angle: widget.angle, child: Container( key: widgetKey, margin: _getMargin(), alignment: _getAlignment(), child: widget.child, ), ), ); } }
fl_chart/lib/src/chart/base/axis_chart/axis_chart_widgets.dart/0
{ "file_path": "fl_chart/lib/src/chart/base/axis_chart/axis_chart_widgets.dart", "repo_id": "fl_chart", "token_count": 1585 }
50
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
3