Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Efficient Event Tracking Mechanism with Flutter

Efficient Event Tracking Mechanism with Flutter

LINE DevDay 2020

November 26, 2020
Tweet

More Decks by LINE DevDay 2020

Other Decks in Technology

Transcript

  1. TrackingManager Third Party Plugin LINE Tracking Service Plugin Wrapper Class

    Wrapper Class Widget Architecture Internal External sendTrackingEvent()
  2. void main() { final mockTrackingManager = MockTrackingManager(); testWidgets(‘Test MyWidget exists.’,

    (tester) async { await tester.pumpWidget(MyWidget(mockTrackingManager)); await tester.tap(find.byType(MyWidget).first); expect(find.byType(MyWidget), findsOneWidget); verify(mockTrackingManager.sendTrackingEvent()).called(1); // More Other assertions… }); } import 'package:mockito/mockito.dart' class MockTrackingManager extends Mock implements TrackingManager {}
  3. void main() { final mockTrackingManager = MockTrackingManager(); testWidgets(‘Test MyWidget exists.’,

    (tester) async { await tester.pumpWidget(MyWidget(mockTrackingManager)); await tester.tap(find.byType(MyWidget).first); expect(find.byType(MyWidget), findsOneWidget); verify(mockTrackingManager.sendTrackingEvent()).called(1); // More Other assertions… }); } import 'package:mockito/mockito.dart' class MockTrackingManager extends Mock implements TrackingManager {}
  4. void main() { final mockTrackingManager = MockTrackingManager(); testWidgets(‘Test MyWidget exists.’,

    (tester) async { await tester.pumpWidget(MyWidget(mockTrackingManager)); await tester.tap(find.byType(MyWidget).first); expect(find.byType(MyWidget), findsOneWidget); verify(mockTrackingManager.sendTrackingEvent()).called(1); // More Other assertions… }); } import 'package:mockito/mockito.dart' class MockTrackingManager extends Mock implements TrackingManager {}
  5. void main() { final mockTrackingManager = MockTrackingManager(); testWidgets(‘Test MyWidget exists.’,

    (tester) async { await tester.pumpWidget(MyWidget(mockTrackingManager)); await tester.tap(find.byType(MyWidget).first); expect(find.byType(MyWidget), findsOneWidget); verify(mockTrackingManager.sendTrackingEvent()).called(1); // More Other assertions… }); } import 'package:mockito/mockito.dart' class MockTrackingManager extends Mock implements TrackingManager {}
  6. void main() { final mockTrackingManager = MockTrackingManager(); testWidgets(‘Test MyWidget exists.’,

    (tester) async { await tester.pumpWidget(MyWidget(mockTrackingManager)); await tester.tap(find.byType(MyWidget).first); expect(find.byType(MyWidget), findsOneWidget); verify(mockTrackingManager.sendTrackingEvent()).called(1); // More Other assertions… }); } import 'package:mockito/mockito.dart' class MockTrackingManager extends Mock implements TrackingManager {}
  7. Wrap Up › It may take extra time to build

    app using Flutter because some plugins may need to be built by your team due to it is not available. › Try to use Flutter’s widget tests to secure your code quality in every code change and release. › It’s alway challenging to use new tools or frameworks, but it’s a fun journey to learn.