Skip to content

Commit

Permalink
feat!: Rename getStrokeOrder to downloadStrokeOrder
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Pepe committed Jan 12, 2024
1 parent 909e072 commit 51b7fd7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:http/http.dart' as http;
import 'package:provider/provider.dart';
import 'package:stroke_order_animator/getStrokeOrder.dart';
import 'package:stroke_order_animator/download_stroke_order.dart';
import 'package:stroke_order_animator/strokeOrderAnimationController.dart';
import 'package:stroke_order_animator/strokeOrderAnimator.dart';
import 'package:stroke_order_animator/stroke_order.dart';
Expand Down Expand Up @@ -50,7 +50,7 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
Future<StrokeOrderAnimationController> _loadStrokeOrder(
String character,
) async {
return getStrokeOrder(character, _httpClient).then((value) {
return downloadStrokeOrder(character, _httpClient).then((value) {
final controller = StrokeOrderAnimationController(
StrokeOrder(value),
this,
Expand Down
4 changes: 1 addition & 3 deletions lib/getStrokeOrder.dart → lib/download_stroke_order.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// ignore_for_file: file_names

import 'package:http/http.dart';

Future<String> getStrokeOrder(String character, Client client) async {
Future<String> downloadStrokeOrder(String character, Client client) async {
const baseUrl = 'https://cdn.jsdelivr.net/npm/hanzi-writer-data@2.0.1/';

final url = Uri.parse('$baseUrl$character.json');
Expand Down
4 changes: 2 additions & 2 deletions lib/stroke_order.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'dart:convert';

import 'package:flutter/rendering.dart';
import 'package:stroke_order_animator/getStrokeOrder.dart';
import 'package:stroke_order_animator/download_stroke_order.dart';
import 'package:svg_path_parser/svg_path_parser.dart';

/// Represents the stroke order of a character.
Expand All @@ -11,7 +11,7 @@ import 'package:svg_path_parser/svg_path_parser.dart';
/// of the radical of the character ([radicalStrokeIndices]).
/// The number of strokes is stored in [nStrokes].
///
/// A JSON string retrieved via [getStrokeOrder] can be passed directly to
/// A JSON string retrieved via [downloadStrokeOrder] can be passed directly to
/// the constructor.
class StrokeOrder {
StrokeOrder(String strokeOrderJson) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:http/http.dart' as http;
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
import 'package:stroke_order_animator/getStrokeOrder.dart';
import 'package:stroke_order_animator/download_stroke_order.dart';

import 'get_stroke_order_test.mocks.dart';
import 'download_stroke_order_test.mocks.dart';
import 'test_strokes.dart';

@GenerateMocks([http.Client])
Expand All @@ -15,7 +15,7 @@ void main() {
when(client.get(any)).thenAnswer((_) async {
return http.Response(strokeOrderJsons['永']!, 200);
});
await getStrokeOrder('永', client);
await downloadStrokeOrder('永', client);

verify(
client.get(
Expand All @@ -29,7 +29,7 @@ void main() {
final client = MockClient();
when(client.get(any)).thenAnswer((_) async => http.Response('', 404));
expect(
() async => await getStrokeOrder('a', client),
() async => await downloadStrokeOrder('a', client),
throwsA(
predicate(
(e) =>
Expand Down

0 comments on commit 51b7fd7

Please sign in to comment.