• [Flutter combat]2048 small game implementation
  • A dialog box is displayed on wechat

preface

In the following article, I learn flutter intermittently. Write down my small projects for practicing flutter and urge myself to study. The following can scan code experience. Project address: github.com/chencld/flu…

Introduction to the

This is the imitation of wechat dialog box, only a part of the function is as follows:

  • expression
  • The picture
  • location

expression

1. The GridView layout is used in the figure below. 2. When listing. Use RichText and WidgetSpan, and replace the expression with a regular match.

The picture

Images use multi_image_picker and photo_view to display images. The Uint8List and image.memory are used for the Image display of the list and the last screenshot mentioned.

location

Using the amap_all_fluttify Autonavi plugin, I get the list of surrounding locations in onMapMoveEnd. One thing to note is that when searching and selecting a list of maps, you need to make a judgment call, otherwise the map will float. This plugin is a bit complicated, and I have referred to several articles on the Internet.

screenshots

Screenshot is a function I added by myself, mainly to experience the RepaintBoundary. It is quite simple. You can wrap the widget you want to capture with RepaintBoundary, and then you can get the ByteData of the screenshot through key value and transformation

RenderRepaintBoundary boundary = repaintWidgetKey.currentContext
          .findRenderObject();
double dpr = window.devicePixelRatio;
var image = await boundary.toImage(pixelRatio: dpr);
ByteData _byteData = await image.toByteData(format: ImageByteFormat.png);
return _byteData;
Copy the code

You need to apply for permission to save screenshots. Androidmanifest.xml:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
Copy the code

Reply to copy

Automatic reply copywriting data is found on the Internet, if there is violation, please inform, thank you.

Afterword.

The biggest feeling of this little exercise is that it relies too much on plug-ins. At the beginning, I wanted to develop a plug-in by encapsulating the native SDK of Autonavi’s official website, but I only knew a little about client development and was not very friendly. Finally, I gave up and manually covered my face. Scott maps plugin author points more fine wrote several, I also contrast when searching for some time, but now there are charges version, I use this plugin is no longer updated, I this is just a practice, if a formal project requirements, finally want to resolve, so the development of plug-ins is a must. In general, functional functions such as image selection and location map are not officially provided in the form of API, but directly encapsulated into plug-ins, but their functions are not very perfect, so they are not very friendly to students like me who do not know much about client development, which will feel like a pit.