This is a test message to test the length of the message box.
Login

Flutter - Develop own packages (Part 2)

In the continuation of the series, we deal with the testing and further development of our own darts package from the last article.

Advertising

In the first part, we mainly dealt with the implementation and use of the package. However, it is less clear how to actually develop the package further. That is why we want to refer to the topic of testing and further development today. If you haven't read the first part of the article, we recommend that you do so, so that you know what it's about.

 

Creation

When developing packages, it is considered best practice to also create an example for the other developers. This example is in the package in the example directory and represents a working prototype.

In the first step, we can run the built-in command "flutter create example" in our project, so that a new flutter app is created directly in our package. With this method, certain files are also not created, which we do not need in this example (CHANGELOG or LICENECE).

 

In the example directory you will find your usual structures and the file main.dart, in which you can do your example implementation. But before you can start with the implementation, you have to register your package via the pubspec.yaml file.

 

By specifying the path, we do not have to download the package first, but refer directly to the main package. So we only need some code in the main.dart.


import 'package:flutter/material.dart';
import 'package:testflutterpackage/pages/LoginPage.dart';

void main() {
  runApp(TestApp());
}

class TestApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Test App',
    home: LoginPage(),
    );
  }
}

 

Run

Normally you have to expand the configuration, otherwise you cannot start the sample app. To do this, create a new entry with the "+" symbol via the menu under "Run -> Edit Configurations ...". Choose Flutter, because we want to start a Flutter application. We assign main.dart as the name and store the path to the file, which serves as the entry point for the application for Dart.

 

Now you can start your device as usual and start with the main.dart for the test and expand the code. The hot reload works in the sample project, but also in the overall package that we are currently developing. One of the strengths of Flutter can be used as usual.

 

Conclusion

If you have components that need to be issued and you are developing the package further, it is definitely recommended to create an example. However, since this procedure is also common practice, you should also do it for other developers who may also use your package.


Included topics:
FlutterPrivate packagesOwn packagesGitTest
Comments (0)
Advertising

Flutter - #FlutterEngage

Category - Flutter

The FlutterEngage event is over and there was again a lot of helpful and interesting information for all Flutter developers among us. We want to briefly summarize the most important points here.

03/05/2021

Flutter - Learning source

Category - Flutter

In this article we want to introduce you to some current learning sources that you can use as inspiration and for further education. Here we will mainly deal with YouTube channels and present some.

01/29/2021

Flutter - Websites

Category - Flutter

The creation of websites and PWAs has been in beta for quite a while, today we're going to show you a small productive example.

10/16/2020

Flutter Day 2020

Category - Flutter

The Flutter Day 2020 is over and we will briefly summarize the most important of the day and provide you with the resources.

07/31/2020

Flutter - Game Development

Category - Flutter

Flutter has many advantages for the rapid development of simple apps, but can the framework also be used to develop games?

05/22/2020

We use cookies for our services and functions. More informations